chore(ci): Decouple versioncode (#2393)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-07-08 17:12:16 +00:00 committed by GitHub
parent db17815576
commit 1f0beb0fdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 3 deletions

View file

@ -50,6 +50,7 @@ jobs:
with:
ref: ${{ github.event.inputs.branch }}
submodules: 'recursive'
fetch-depth: 0
- name: Cache Gradle packages
uses: actions/cache@v4
@ -82,8 +83,20 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate Version Code with Git Commit Count and Offset
id: calculate_version_code
run: |
GIT_COMMIT_COUNT=$(git rev-list --count HEAD)
OFFSET=30630 # to ensure versionCode is above 30630
VERSION_CODE=$((GIT_COMMIT_COUNT + OFFSET))
echo "Calculated versionCode: $VERSION_CODE (from $GIT_COMMIT_COUNT commits + $OFFSET offset)"
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: Build F-Droid release
run: ./gradlew assembleFdroidRelease
env:
VERSION_CODE: ${{ env.VERSION_CODE }}
- name: Upload F-Droid APK artifact (for release job)
uses: actions/upload-artifact@v4
@ -108,6 +121,7 @@ jobs:
with:
ref: ${{ github.event.inputs.branch }}
submodules: 'recursive'
fetch-depth: 0
- name: Cache Gradle packages
uses: actions/cache@v4
@ -143,8 +157,19 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate Version Code with Git Commit Count and Offset
id: calculate_version_code
run: |
GIT_COMMIT_COUNT=$(git rev-list --count HEAD)
OFFSET=30630 # to ensure versionCode is above 30630
VERSION_CODE=$((GIT_COMMIT_COUNT + OFFSET))
echo "Calculated versionCode: $VERSION_CODE (from $GIT_COMMIT_COUNT commits + $OFFSET offset)"
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: Build Play Store release
run: ./gradlew bundleGoogleRelease assembleGoogleRelease
env:
VERSION_CODE: ${{ env.VERSION_CODE }}
- name: Upload Play Store AAB artifact (for release job)
uses: actions/upload-artifact@v4

View file

@ -20,6 +20,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
@ -55,8 +56,20 @@ jobs:
build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service'
build-scan-terms-of-use-agree: 'yes'
add-job-summary: always
- name: Calculate Version Code with Git Commit Count and Offset
id: calculate_version_code
run: |
GIT_COMMIT_COUNT=$(git rev-list --count HEAD)
OFFSET=30630 # to ensure versionCode is above 30630 (our last manual versionCode)
VERSION_CODE=$((GIT_COMMIT_COUNT + OFFSET))
echo "Calculated versionCode: $VERSION_CODE (from $GIT_COMMIT_COUNT commits + $OFFSET offset)"
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: Run Detekt, Build, Lint, and Local Tests
run: ./gradlew detekt lintFdroidDebug lintGoogleDebug assembleDebug testFdroidDebug testGoogleDebug --configuration-cache --scan
env:
VERSION_CODE: ${{ env.VERSION_CODE }}
- name: Upload F-Droid debug artifact
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v4