Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/actions/prepare-release/action.yml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a repository with reusable Actions here: https://github.com/Q42/actions
If this is a GitHub Action that we want to use for every project, it might make sense to put it there, so we can update it in a single place and not have the code duplicated in every project repo.

@ninovanhooff ninovanhooff Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So your suggestion is to create an action there called q42/gradle-version-number and update the current PR to use it in the prepare-release action, right? I think I like that idea

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Prepare Release'
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'
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

# 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: echo "ORG_GRADLE_PROJECT_appVersionCode=${{ steps.calculate.outputs.final_version }}" >> "$GITHUB_ENV"
8 changes: 4 additions & 4 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ios-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading