|
@@ -2,29 +2,39 @@
|
|
|
# Workflow: Bump Dev Version
|
|
# Workflow: Bump Dev Version
|
|
|
#
|
|
#
|
|
|
# Description:
|
|
# Description:
|
|
|
-# This GitHub Actions workflow automatically increments the version number
|
|
|
|
|
-# defined in `Config.xcconfig` on every push to the `dev` branch.
|
|
|
|
|
|
|
+# This GitHub Actions workflow automatically manages and increments the
|
|
|
|
|
+# `APP_DEV_VERSION` defined in `Config.xcconfig` on every push to `dev` branch.
|
|
|
|
|
+# This version is used for internal tracking and diagnostics (e.g. in
|
|
|
|
|
+# Crashlytics) and follows a 4-digit semantic versioning format:
|
|
|
|
|
+# `MAJOR.MINOR.PATCH.FEATURE`.
|
|
|
#
|
|
#
|
|
|
# Versioning Logic:
|
|
# Versioning Logic:
|
|
|
-# - Reads the `APP_VERSION` from `Config.xcconfig`.
|
|
|
|
|
-# - If the version is in `MAJOR.MINOR.PATCH.BUILD` format (4 digits),
|
|
|
|
|
-# the `BUILD` number is incremented by 1.
|
|
|
|
|
-# - If the version is in `MAJOR.MINOR.PATCH` format (3 digits),
|
|
|
|
|
-# a `.1` is appended to start a `BUILD` count.
|
|
|
|
|
|
|
+# - Reads the base version from `APP_VERSION = x.y.z`
|
|
|
|
|
+# - Reads the last internal dev version from `APP_DEV_VERSION`
|
|
|
#
|
|
#
|
|
|
-# Example:
|
|
|
|
|
-# - `0.5.0` → `0.5.0.1`
|
|
|
|
|
-# - `0.5.0.3` → `0.5.0.4`
|
|
|
|
|
|
|
+# Behavior:
|
|
|
|
|
+# - If `APP_DEV_VERSION` matches `APP_VERSION` (e.g. both are `0.5.0`),
|
|
|
|
|
+# it assumes the first dev push after a release and sets `APP_DEV_VERSION`
|
|
|
|
|
+# to `APP_VERSION.1` (e.g. `0.5.0.1`)
|
|
|
|
|
+# - If `APP_DEV_VERSION` is already in 4-digit form (e.g. `0.5.0.3`),
|
|
|
|
|
+# it increments the fourth digit (e.g. → `0.5.0.4`)
|
|
|
#
|
|
#
|
|
|
-# The updated version is then committed and pushed back to the `dev` branch.
|
|
|
|
|
|
|
+# Example Progression:
|
|
|
|
|
+# - Release sets `APP_VERSION = 0.5.0`, `APP_DEV_VERSION = 0.5.0`
|
|
|
|
|
+# - First push to `dev`: → `APP_DEV_VERSION = 0.5.0.1`
|
|
|
|
|
+# - Second push to `dev`: → `APP_DEV_VERSION = 0.5.0.2`
|
|
|
|
|
+# - ...
|
|
|
|
|
+#
|
|
|
|
|
+# The updated value is committed and pushed back to the `dev` branch.
|
|
|
#
|
|
#
|
|
|
# Prerequisites:
|
|
# Prerequisites:
|
|
|
-# - `APP_VERSION` must exist and be defined using the format:
|
|
|
|
|
-# APP_VERSION = x.y.z or x.y.z.w
|
|
|
|
|
-# - GitHub Actions bot must have workflow permission to push to `dev`.
|
|
|
|
|
|
|
+# - `APP_VERSION` must be present in `Config.xcconfig` in the form `x.y.z`
|
|
|
|
|
+# - `APP_DEV_VERSION` must either match `APP_VERSION` or be `x.y.z.w`
|
|
|
|
|
+# - GitHub Actions must have write permission to push to `dev`
|
|
|
|
|
+# - This workflow only runs when the repository owner is `nightscout`
|
|
|
# -----------------------------------------------------------------------------
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-name: Bump Dev Version
|
|
|
|
|
|
|
+name: Bump APP_DEV_VERSION on dev push
|
|
|
|
|
|
|
|
on:
|
|
on:
|
|
|
push:
|
|
push:
|
|
@@ -32,12 +42,12 @@ on:
|
|
|
- dev
|
|
- dev
|
|
|
|
|
|
|
|
jobs:
|
|
jobs:
|
|
|
- bump-version:
|
|
|
|
|
- if: github.repository_owner == 'nightscout'
|
|
|
|
|
|
|
+ bump-dev-version:
|
|
|
|
|
+ if: github.repository.owner == 'nightscout'
|
|
|
runs-on: ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
steps:
|
|
|
- - name: Checkout repository
|
|
|
|
|
|
|
+ - name: Checkout repo
|
|
|
uses: actions/checkout@v4
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Git
|
|
- name: Set up Git
|
|
@@ -45,43 +55,46 @@ jobs:
|
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.name "github-actions[bot]"
|
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
|
|
|
|
|
|
- - name: Bump dev version number in Config.xcconfig
|
|
|
|
|
|
|
+ - name: Bump APP_DEV_VERSION
|
|
|
run: |
|
|
run: |
|
|
|
FILE=Config.xcconfig
|
|
FILE=Config.xcconfig
|
|
|
|
|
|
|
|
- # Find the line with APP_VERSION and extract the value
|
|
|
|
|
- VERSION_LINE=$(grep -E '^APP_VERSION *= *[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?' "$FILE")
|
|
|
|
|
- CURRENT_VERSION=$(echo "$VERSION_LINE" | sed -E 's/^APP_VERSION *= *//')
|
|
|
|
|
-
|
|
|
|
|
- # Split version into components (up to 4)
|
|
|
|
|
- IFS='.' read -r MAJOR MINOR FIX BUILD <<< "$CURRENT_VERSION"
|
|
|
|
|
|
|
+ # Read current APP_VERSION
|
|
|
|
|
+ BASE_VERSION=$(grep '^APP_VERSION' "$FILE" | cut -d '=' -f2 | xargs)
|
|
|
|
|
|
|
|
- # If 4th digit not present, start at 1; else increment
|
|
|
|
|
- if [ -z "$BUILD" ]; then
|
|
|
|
|
- BUILD=1
|
|
|
|
|
|
|
+ # Read existing APP_DEV_VERSION, if any
|
|
|
|
|
+ DEV_LINE=$(grep '^APP_DEV_VERSION' "$FILE" || echo "")
|
|
|
|
|
+ if [ -z "$DEV_LINE" ]; then
|
|
|
|
|
+ CURRENT_DEV_VERSION="$BASE_VERSION"
|
|
|
else
|
|
else
|
|
|
- BUILD=$((BUILD + 1))
|
|
|
|
|
|
|
+ CURRENT_DEV_VERSION=$(echo "$DEV_LINE" | cut -d '=' -f2 | xargs)
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
- # Construct new version
|
|
|
|
|
- NEW_VERSION="$MAJOR.$MINOR.$FIX.$BUILD"
|
|
|
|
|
- echo "New version: $NEW_VERSION"
|
|
|
|
|
-
|
|
|
|
|
- # Escape dots in current version for sed replacement
|
|
|
|
|
- ESCAPED_CURRENT_VERSION=$(echo "$CURRENT_VERSION" | sed 's/\./\\./g')
|
|
|
|
|
|
|
+ echo "APP_VERSION = $BASE_VERSION"
|
|
|
|
|
+ echo "APP_DEV_VERSION = $CURRENT_DEV_VERSION"
|
|
|
|
|
|
|
|
- # Replace the APP_VERSION line in-place with new version
|
|
|
|
|
- if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
|
- sed -i '' -E "s/APP_VERSION *= *$ESCAPED_CURRENT_VERSION/APP_VERSION = $NEW_VERSION/" "$FILE"
|
|
|
|
|
|
|
+ # Decide next dev version
|
|
|
|
|
+ if [ "$CURRENT_DEV_VERSION" = "$BASE_VERSION" ]; then
|
|
|
|
|
+ # First post-release commit to dev → bump to .1
|
|
|
|
|
+ NEW_DEV_VERSION="${BASE_VERSION}.1"
|
|
|
|
|
+ if [ -z "$DEV_LINE" ]; then
|
|
|
|
|
+ echo "APP_DEV_VERSION = $NEW_DEV_VERSION" >> "$FILE"
|
|
|
|
|
+ else
|
|
|
|
|
+ sed -i -E "s|^APP_DEV_VERSION *= *.*|APP_DEV_VERSION = $NEW_DEV_VERSION|" "$FILE"
|
|
|
|
|
+ fi
|
|
|
else
|
|
else
|
|
|
- sed -i -E "s/APP_VERSION *= *$ESCAPED_CURRENT_VERSION/APP_VERSION = $NEW_VERSION/" "$FILE"
|
|
|
|
|
|
|
+ # Already in .X form → bump last digit
|
|
|
|
|
+ IFS='.' read -r MAJOR MINOR PATCH FEATURE <<< "$CURRENT_DEV_VERSION"
|
|
|
|
|
+ FEATURE=$((FEATURE + 1))
|
|
|
|
|
+ NEW_DEV_VERSION="$MAJOR.$MINOR.$PATCH.$FEATURE"
|
|
|
|
|
+ sed -i -E "s|^APP_DEV_VERSION *= *.*|APP_DEV_VERSION = $NEW_DEV_VERSION|" "$FILE"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
- # Export version so it's available in the next step
|
|
|
|
|
- echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
|
|
|
|
|
|
|
+ echo "NEW APP_DEV_VERSION = $NEW_DEV_VERSION"
|
|
|
|
|
+ echo "NEW_DEV_VERSION=$NEW_DEV_VERSION" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- - name: Commit and push changes
|
|
|
|
|
|
|
+ - name: Commit and push updated dev version
|
|
|
run: |
|
|
run: |
|
|
|
git add Config.xcconfig
|
|
git add Config.xcconfig
|
|
|
- git commit -m "CI: Bump dev version to $NEW_VERSION"
|
|
|
|
|
|
|
+ git commit -m "CI: Bump APP_DEV_VERSION to $NEW_DEV_VERSION"
|
|
|
git push
|
|
git push
|