mirror of
https://github.com/we-promise/sure.git
synced 2026-04-14 17:44:07 +00:00
Generalize pre-release bump workflow (#779)
* Generalize pre-release bump workflow Handle alpha, beta, and rc tags when incrementing the version. * Change commit message for version bump in workflow Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
32
.github/workflows/publish.yml
vendored
32
.github/workflows/publish.yml
vendored
@@ -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
|
||||
NEW_ALPHA_NUM=$((ALPHA_NUM + 1))
|
||||
|
||||
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_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
|
||||
|
||||
Reference in New Issue
Block a user