Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Generalize pre-release bump workflow (#779)

Juan José Mata7bc20e38e2a3
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 440bb39a4a..2c3479071a 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -329,9 +329,9 @@ jobs:
> **Note**: These are debug builds intended for testing purposes. For production use, please build from source with proper signing credentials.
- bump-alpha-version:
- name: Bump Alpha Version
- if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, 'alpha')
+ bump-pre_release-version:
+ name: Bump Pre-release Version
+ if: startsWith(github.ref, 'refs/tags/v') && (contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc'))
needs: [merge]
runs-on: ubuntu-latest
timeout-minutes: 10
@@ -346,7 +346,7 @@ jobs:
ref: main
token: ${{ secrets.GH_PAT }}
- - name: Bump alpha version
+ - name: Bump pre-release version
run: |
VERSION_FILE="config/initializers/version.rb"
@@ -357,20 +357,26 @@ jobs:
fi
# Extract current version
- CURRENT_VERSION=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+' "$VERSION_FILE")
+ CURRENT_VERSION=$(grep -oP '"\K[0-9]+\.[0-9]+\.[0-9]+-(alpha|beta|rc)\.[0-9]+' "$VERSION_FILE")
if [ -z "$CURRENT_VERSION" ]; then
echo "ERROR: Could not extract version from $VERSION_FILE"
exit 1
fi
echo "Current version: $CURRENT_VERSION"
-
- # Extract the alpha number and increment it
- ALPHA_NUM=$(echo "$CURRENT_VERSION" | grep -oP 'alpha\.\K[0-9]+')
- if [ -z "$ALPHA_NUM" ]; then
- echo "ERROR: Could not extract alpha number from $CURRENT_VERSION"
+
+ # Extract the pre-release tag and number, then increment it
+ PRE_RELEASE_TAG=$(echo "$CURRENT_VERSION" | grep -oP '(alpha|beta|rc)')
+ if [ -z "$PRE_RELEASE_TAG" ]; then
+ echo "ERROR: Could not extract pre-release tag from $CURRENT_VERSION"
+ exit 1
+ fi
+
+ PRE_RELEASE_NUM=$(echo "$CURRENT_VERSION" | grep -oP '(alpha|beta|rc)\.\K[0-9]+')
+ if [ -z "$PRE_RELEASE_NUM" ]; then
+ echo "ERROR: Could not extract pre-release number from $CURRENT_VERSION"
exit 1
fi
- NEW_ALPHA_NUM=$((ALPHA_NUM + 1))
+ NEW_PRE_RELEASE_NUM=$((PRE_RELEASE_NUM + 1))
# Create new version string
BASE_VERSION=$(echo "$CURRENT_VERSION" | grep -oP '^[0-9]+\.[0-9]+\.[0-9]+')
@@ -378,7 +384,7 @@ jobs:
echo "ERROR: Could not extract base version from $CURRENT_VERSION"
exit 1
fi
- NEW_VERSION="${BASE_VERSION}-alpha.${NEW_ALPHA_NUM}"
+ NEW_VERSION="${BASE_VERSION}-${PRE_RELEASE_TAG}.${NEW_PRE_RELEASE_NUM}"
echo "New version: $NEW_VERSION"
# Update the version file
@@ -401,7 +407,7 @@ jobs:
exit 0
fi
- git commit -m "Bump version to next alpha after ${{ github.ref_name }} release"
+ git commit -m "Bump version to next iteration after ${{ github.ref_name }} release"
# Push with retry logic
attempts=0