From cc6375099b9a585b7067f422f528d4de3da66d57 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Tue, 3 Nov 2026 17:00:03 +0100 Subject: [PATCH 1/3] Use the run number as Android version code Adds a prepare-release composite action that writes the run number (plus an optional offset) to appVersionCode in gradle.properties. The workflow passed -Papp.versionCodeOverride, which no build script read, so every build got version code 1. Co-Authored-By: Claude Opus 5.5 --- .github/actions/prepare-release/action.yml | 29 ++++++++++++++++++++++ .github/workflows/android-release.yml | 8 +++--- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 .github/actions/prepare-release/action.yml diff --git a/.github/actions/prepare-release/action.yml b/.github/actions/prepare-release/action.yml new file mode 100644 index 0000000..d76a4ab --- /dev/null +++ b/.github/actions/prepare-release/action.yml @@ -0,0 +1,29 @@ +name: 'Prepare Release' +description: 'Sets appVersionCode in gradle.properties to the workflow run number plus an offset' +inputs: + versioncode_offset: + description: 'Offset for version code' + required: false + default: '0' +outputs: + version_code: + description: 'The version code that was set' + value: ${{ steps.calculate.outputs.final_version }} +runs: + using: "composite" + steps: + - name: Calculate Version Code + id: calculate + shell: bash + run: | + # Use $(( )) for bash arithmetic + TOTAL_VERSION=$(( ${{ inputs.versioncode_offset }} + ${{ github.run_number }} )) + echo "final_version=$TOTAL_VERSION" >> $GITHUB_OUTPUT + + # androidApp and shared (BuildKonfig, printAppVersionMetadata) both read appVersionCode from gradle.properties + - name: Update Version Code + shell: bash + run: | + sed -i.bak 's/^appVersionCode=.*/appVersionCode=${{ steps.calculate.outputs.final_version }}/' gradle.properties + rm gradle.properties.bak + grep -q '^appVersionCode=${{ steps.calculate.outputs.final_version }}$' gradle.properties diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml index b2601d9..6e2b308 100644 --- a/.github/workflows/android-release.yml +++ b/.github/workflows/android-release.yml @@ -27,6 +27,10 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v6 + # Uses the run number as version code, so every build can be installed over the previous one + - name: Prepare release + uses: ./.github/actions/prepare-release + - name: Resolve app version metadata id: app_meta shell: bash @@ -89,8 +93,6 @@ jobs: ./gradlew \ :androidApp:assembleRelease \ :androidApp:bundleRelease \ - -Papp.versionNameOverride=${{ steps.app_meta.outputs.version_name }} \ - -Papp.versionCodeOverride=${{ steps.app_meta.outputs.version_code }} \ --stacktrace - name: List generated release outputs @@ -129,8 +131,6 @@ jobs: echo "$FIREBASE_CREDENTIALS" > "$RUNNER_TEMP/firebase-credentials.json" export GOOGLE_APPLICATION_CREDENTIALS="$RUNNER_TEMP/firebase-credentials.json" ./gradlew :androidApp:appDistributionUploadRelease \ - -Papp.versionNameOverride=${{ steps.app_meta.outputs.version_name }} \ - -Papp.versionCodeOverride=${{ steps.app_meta.outputs.version_code }} \ --stacktrace | tee "$RUNNER_TEMP/firebase-upload.log" RELEASE_URL=$(grep -o 'https://console.firebase.google.com/[^ ]*' "$RUNNER_TEMP/firebase-upload.log" | head -n 1 || true) From 5a1e8abe1990f9ef8bfa7b7d68aeb5ed8928ba68 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Tue, 3 Nov 2026 17:07:50 +0100 Subject: [PATCH 2/3] Override the version code with an environment variable The prepare-release action now sets ORG_GRADLE_PROJECT_appVersionCode instead of rewriting gradle.properties. It applies to every later Gradle call in the job, without changing tracked files. Co-Authored-By: Claude Opus 5.5 --- .github/actions/prepare-release/action.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/actions/prepare-release/action.yml b/.github/actions/prepare-release/action.yml index d76a4ab..5b841a6 100644 --- a/.github/actions/prepare-release/action.yml +++ b/.github/actions/prepare-release/action.yml @@ -1,5 +1,5 @@ name: 'Prepare Release' -description: 'Sets appVersionCode in gradle.properties to the workflow run number plus an offset' +description: 'Overrides appVersionCode with the workflow run number plus an offset for all later Gradle calls in the job' inputs: versioncode_offset: description: 'Offset for version code' @@ -20,10 +20,8 @@ runs: TOTAL_VERSION=$(( ${{ inputs.versioncode_offset }} + ${{ github.run_number }} )) echo "final_version=$TOTAL_VERSION" >> $GITHUB_OUTPUT - # androidApp and shared (BuildKonfig, printAppVersionMetadata) both read appVersionCode from gradle.properties + # Gradle reads ORG_GRADLE_PROJECT_* as project properties, which take precedence over gradle.properties. + # This also applies to Gradle calls started by Xcode. - name: Update Version Code shell: bash - run: | - sed -i.bak 's/^appVersionCode=.*/appVersionCode=${{ steps.calculate.outputs.final_version }}/' gradle.properties - rm gradle.properties.bak - grep -q '^appVersionCode=${{ steps.calculate.outputs.final_version }}$' gradle.properties + run: echo "ORG_GRADLE_PROJECT_appVersionCode=${{ steps.calculate.outputs.final_version }}" >> "$GITHUB_ENV" From 7b864047d0a4cbaa249f16627a831b20fc97f09d Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Tue, 3 Nov 2026 17:13:18 +0100 Subject: [PATCH 3/3] Use the run number as iOS build number Runs the prepare-release action in the iOS release workflow, so CURRENT_PROJECT_VERSION and BuildKonfig's APP_VERSION_CODE use the run number instead of the version code 1 from gradle.properties. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ios-release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ios-release.yml b/.github/workflows/ios-release.yml index 614d3f1..508175a 100644 --- a/.github/workflows/ios-release.yml +++ b/.github/workflows/ios-release.yml @@ -48,6 +48,10 @@ jobs: with: xcode-version: ${{ env.XCODE_VERSION }} + # Uses the run number as version code (build number), so every build can be uploaded to TestFlight + - name: Prepare release + uses: ./.github/actions/prepare-release + - name: Resolve app version metadata id: app_meta shell: bash @@ -61,6 +65,7 @@ jobs: echo "version_name=$VERSION_NAME" >> "$GITHUB_OUTPUT" echo "version_code=$VERSION_CODE" >> "$GITHUB_OUTPUT" + echo "Version name: $VERSION_NAME, version code: $VERSION_CODE" - name: Cache Swift Package Manager dependencies uses: actions/cache@v5