Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

Commit 50ed23b

Browse files
committed
Update codemagic.yaml
1 parent 7899c92 commit 50ed23b

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

codemagic.yaml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,39 @@ workflows:
104104
./gradlew clean test --no-daemon
105105
- name: Build RIA DigiDoc
106106
script: |
107+
# Get latest build numbers from "internal" and "production" tracks
108+
LATEST_GOOGLE_PLAY_INTERNAL_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks internal)
109+
LATEST_GOOGLE_PLAY_PRODUCTION_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks production)
110+
111+
# Check that both tracks have valid build numbers (over 0) and select the highest.
112+
# Add +1 to the highest build number to submit to Google Play
113+
# If any are 0, use build number
114+
if [ "$LATEST_GOOGLE_PLAY_INTERNAL_BUILD_NUMBER" -gt 0 ] && [ "$LATEST_GOOGLE_PLAY_PRODUCTION_BUILD_NUMBER" -gt 0 ]; then
115+
if [ "$LATEST_GOOGLE_PLAY_INTERNAL_BUILD_NUMBER" -gt "$LATEST_GOOGLE_PLAY_PRODUCTION_BUILD_NUMBER" ]; then
116+
LATEST_BUILD_NUMBER=$(($LATEST_GOOGLE_PLAY_INTERNAL_BUILD_NUMBER + 1))
117+
echo "Internal build number is highest, new build number for this build: $LATEST_BUILD_NUMBER"
118+
echo LATEST_BUILD_NUMBER=$LATEST_BUILD_NUMBER >> $CM_ENV
119+
else
120+
LATEST_BUILD_NUMBER=$(($LATEST_GOOGLE_PLAY_PRODUCTION_BUILD_NUMBER + 1))
121+
echo "Release build number is highest, new build number for this build: $LATEST_BUILD_NUMBER"
122+
echo LATEST_BUILD_NUMBER=$LATEST_BUILD_NUMBER >> $CM_ENV
123+
fi
124+
else
125+
echo "One or both build numbers are 0, using build number"
126+
LATEST_BUILD_NUMBER="$APP_VERSION_NAME.$PROJECT_BUILD_NUMBER"
127+
fi
128+
129+
# Make latest build number be available in all build steps
130+
APP_VERSION="$APP_VERSION_NAME.$LATEST_BUILD_NUMBER"
131+
echo "APP_VERSION=$APP_VERSION" >> $CM_ENV
132+
echo "Using app version: $APP_VERSION"
133+
134+
# Build app
107135
# Not running 'fetchAndPackageDefaultConfiguration' for repo.ria as necessary files are already setup
108136
if [[ "${{ inputs.defaultCentralConfigurationTslUrl_input }}" == *"repo.ria"* ]]; then
109-
./gradlew clean --no-daemon -PappVersionName=$APP_VERSION_NAME.$PROJECT_BUILD_NUMBER assemble --debug
137+
./gradlew clean --no-daemon -PappVersionName=$APP_VERSION -PappVersionCode=$LATEST_BUILD_NUMBER assemble --debug
110138
else
111-
./gradlew clean --no-daemon fetchAndPackageDefaultConfiguration --args="${{ inputs.defaultCentralConfigurationUrl_input }} ${{ inputs.defaultCentralConfigurationUpdateInterval_input }}" -PappVersionName=$APP_VERSION_NAME.$PROJECT_BUILD_NUMBER assemble --debug
139+
./gradlew clean --no-daemon fetchAndPackageDefaultConfiguration --args="${{ inputs.defaultCentralConfigurationUrl_input }} ${{ inputs.defaultCentralConfigurationUpdateInterval_input }}" -PappVersionName=$APP_VERSION -PappVersionCode=$LATEST_BUILD_NUMBER assemble --debug
112140
fi
113141
- name: Align APK
114142
script: |
@@ -118,12 +146,10 @@ workflows:
118146
apksigner sign --ks $CM_KEYSTORE_PATH --ks-pass pass:$CM_KEYSTORE_PASSWORD --out app/build/outputs/apk/release/app-release_$APP_VERSION.apk app/build/outputs/apk/release/app-release-unsigned-aligned.apk
119147
- name: Rename and move APK
120148
script: |
121-
mkdir -p app/build/outputs/apk/release/signed/
149+
mkdir -p app/build/outputs/apk/release/signed-debug/
122150
mv app/build/outputs/apk/release/app-release_$APP_VERSION.apk app/build/outputs/apk/release/signed/RIA_DigiDoc_dev_$APP_VERSION.apk
123-
124-
aapt dump badging app/build/outputs/apk/release/signed/RIA_DigiDoc_$APP_VERSION.apk | grep versionCode
125151
artifacts:
126-
- app/build/outputs/apk/release/signed/*.apk
152+
- app/build/outputs/apk/release/signed-debug/*.apk
127153
publishing:
128154
email:
129155
recipients:
@@ -153,7 +179,7 @@ workflows:
153179
- name: Run tests
154180
script: |
155181
./gradlew clean test --no-daemon
156-
- name: Setup Gradle and Build RIA DigiDoc
182+
- name: Build RIA DigiDoc
157183
script: |
158184
# Get latest build numbers from "internal" and "production" tracks
159185
LATEST_GOOGLE_PLAY_INTERNAL_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks internal)
@@ -194,8 +220,6 @@ workflows:
194220
script: |
195221
mkdir -p app/build/outputs/apk/release/signed/
196222
mv app/build/outputs/apk/release/app-release_$APP_VERSION.apk app/build/outputs/apk/release/signed/RIA_DigiDoc_$APP_VERSION.apk
197-
198-
aapt dump badging app/build/outputs/apk/release/signed/RIA_DigiDoc_$APP_VERSION.apk | grep versionCode
199223
artifacts:
200224
- app/build/outputs/apk/release/signed/*.apk
201225
publishing:

0 commit comments

Comments
 (0)