workflows: android-workflow: name: Ionic Capacitor Android Workflow max_build_duration: 120 environment: android_signing: - keystore_reference groups: - google_play vars: PACKAGE_NAME: "com.gpr.gabinetedigital" GOOGLE_PLAY_TRACK: alpha node: latest scripts: - name: Install npm dependencies for Ionic Capacitor project script: | npm install - name: Set up local.properties script: | echo "sdk.dir=$ANDROID_SDK_ROOT" > "$CM_BUILD_DIR/android/local.properties" - name: Update dependencies and copy web assets to native project script: | # if you don't need to update native dependencies, use this: # npx cap copy # # to update native dependencies, use this command: npx cap sync - name: Build Android release script: | LATEST_GOOGLE_PLAY_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME") if [ -z $LATEST_GOOGLE_PLAY_BUILD_NUMBER ]; then # fallback in case no build number was found from Google Play. # Alternatively, you can `exit 1` to fail the build # BUILD_NUMBER is a Codemagic built-in variable tracking the number # of times this workflow has been built UPDATED_BUILD_NUMBER=$BUILD_NUMBER else UPDATED_BUILD_NUMBER=$(($LATEST_GOOGLE_PLAY_BUILD_NUMBER + 1)) fi cd android ./gradlew bundleRelease \ -PversionCode=$UPDATED_BUILD_NUMBER \ -PversionName=1.0.$UPDATED_BUILD_NUMBER artifacts: - android/app/build/outputs/**/*.apk publishing: email: recipients: - user_1@example.com - user_2@example.com notify: success: true failure: false google_play: credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS track: internal submit_as_draft: true