fix: use commit-count based versionCode to prevent downgrade on Firebase

CI_BUILD_ID was using github.run_number which is per-workflow, causing
different workflows to produce different versionCodes (144 vs 9).
Now computed from git commit count + offset, consistent across all workflows.
Also added bundle task to local auto-increment.
This commit is contained in:
2026-03-10 02:18:55 +03:00
parent 8d150266fb
commit c965746f8f
3 changed files with 10 additions and 6 deletions
+8 -2
View File
@@ -130,8 +130,6 @@ env:
POLKASSEMBLY_SUMMARY_API_KEY: ${{ secrets.POLKASSEMBLY_SUMMARY_API_KEY }} POLKASSEMBLY_SUMMARY_API_KEY: ${{ secrets.POLKASSEMBLY_SUMMARY_API_KEY }}
CI_BUILD_ID: ${{ github.run_number }}
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{inputs.upload-name}} group: ${{ github.workflow }}-${{ github.ref }}-${{inputs.upload-name}}
cancel-in-progress: true cancel-in-progress: true
@@ -146,6 +144,14 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ inputs.branch }} ref: ${{ inputs.branch }}
fetch-depth: 0
- name: Compute version code from commit count
run: |
COMMIT_COUNT=$(git rev-list --count HEAD)
VERSION_CODE=$((COMMIT_COUNT + 100))
echo "CI_BUILD_ID=$VERSION_CODE" >> $GITHUB_ENV
echo "Version code: $VERSION_CODE (commits: $COMMIT_COUNT + offset 100)"
- name: 📂 Set up DEV Google Services - name: 📂 Set up DEV Google Services
uses: davidSchuppa/base64Secret-toFile-action@v3 uses: davidSchuppa/base64Secret-toFile-action@v3
-2
View File
@@ -29,6 +29,4 @@ app/*.apk
google-services.json google-services.json
**/google-services.json **/google-services.json
# Version properties
version.properties
.kotlin/ .kotlin/
+1 -1
View File
@@ -25,7 +25,7 @@ def computeVersionCode() {
return Integer.valueOf(System.env.CI_BUILD_ID) return Integer.valueOf(System.env.CI_BUILD_ID)
} }
// Local build - auto increment // Local build - auto increment
if (gradle.startParameter.taskNames.any { it.contains('assemble') || it.contains('install') }) { if (gradle.startParameter.taskNames.any { it.contains('assemble') || it.contains('install') || it.contains('bundle') }) {
return incrementVersionCode() return incrementVersionCode()
} }
return getVersionCodeFromFile() return getVersionCodeFromFile()