|
1 | 1 | name: Build Authenticator
|
2 | 2 |
|
3 | 3 | on:
|
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
4 | 7 | workflow_dispatch:
|
| 8 | + inputs: |
| 9 | + version-name: |
| 10 | + description: "Optional. Version string to use, in X.Y.Z format. Overrides default in the project." |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + version-code: |
| 14 | + description: "Optional. Build number to use. Overrides default of GitHub run number." |
| 15 | + required: false |
| 16 | + type: number |
| 17 | + distribute-to-firebase: |
| 18 | + description: "Optional. Distribute artifacts to Firebase." |
| 19 | + required: false |
| 20 | + default: false |
| 21 | + type: boolean |
| 22 | + publish-to-play-store: |
| 23 | + description: "Optional. Deploy bundle artifact to Google Play Store" |
| 24 | + required: false |
| 25 | + default: false |
| 26 | + type: boolean |
| 27 | + |
| 28 | +env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + JAVA_VERSION: 17 |
5 | 31 |
|
6 | 32 | jobs:
|
7 |
| - placeholder: |
8 |
| - name: Placeholder Job |
| 33 | + build: |
| 34 | + name: Build Authenticator |
| 35 | + runs-on: ubuntu-24.04 |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Check out repo |
| 39 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 40 | + |
| 41 | + - name: Validate Gradle wrapper |
| 42 | + uses: gradle/actions/wrapper-validation@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2 |
| 43 | + |
| 44 | + - name: Cache Gradle files |
| 45 | + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 46 | + with: |
| 47 | + path: | |
| 48 | + ~/.gradle/caches |
| 49 | + ~/.gradle/wrapper |
| 50 | + key: ${{ runner.os }}-gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }} |
| 51 | + restore-keys: | |
| 52 | + ${{ runner.os }}-gradle-v2- |
| 53 | +
|
| 54 | + - name: Cache build output |
| 55 | + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 56 | + with: |
| 57 | + path: | |
| 58 | + ${{ github.workspace }}/build-cache |
| 59 | + key: ${{ runner.os }}-build-cache-${{ github.sha }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-build- |
| 62 | +
|
| 63 | + - name: Configure JDK |
| 64 | + uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 |
| 65 | + with: |
| 66 | + distribution: "temurin" |
| 67 | + java-version: ${{ env.JAVA_VERSION }} |
| 68 | + |
| 69 | + - name: Configure Ruby |
| 70 | + uses: ruby/setup-ruby@28c4deda893d5a96a6b2d958c5b47fc18d65c9d3 # v1.213.0 |
| 71 | + with: |
| 72 | + bundler-cache: true |
| 73 | + |
| 74 | + - name: Install Fastlane |
| 75 | + run: | |
| 76 | + gem install bundler:2.2.27 |
| 77 | + bundle config path vendor/bundle |
| 78 | + bundle install --jobs 4 --retry 3 |
| 79 | +
|
| 80 | + - name: Check Authenticator |
| 81 | + run: bundle exec fastlane checkAuthenticator |
| 82 | + |
| 83 | + - name: Build Authenticator |
| 84 | + run: bundle exec fastlane buildAuthenticatorDebug |
| 85 | + |
| 86 | + publish_playstore: |
| 87 | + name: Publish Authenticator Play Store artifacts |
| 88 | + needs: |
| 89 | + - build |
9 | 90 | runs-on: ubuntu-24.04
|
| 91 | + strategy: |
| 92 | + fail-fast: false |
| 93 | + matrix: |
| 94 | + variant: ["aab", "apk"] |
10 | 95 |
|
11 | 96 | steps:
|
12 |
| - - name: Placeholder Step |
13 |
| - run: echo "placeholder workflow" |
| 97 | + - name: Check out repo |
| 98 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 99 | + |
| 100 | + - name: Configure Ruby |
| 101 | + uses: ruby/setup-ruby@28c4deda893d5a96a6b2d958c5b47fc18d65c9d3 # v1.213.0 |
| 102 | + with: |
| 103 | + bundler-cache: true |
| 104 | + |
| 105 | + - name: Install Fastlane |
| 106 | + run: | |
| 107 | + gem install bundler:2.2.27 |
| 108 | + bundle config path vendor/bundle |
| 109 | + bundle install --jobs 4 --retry 3 |
| 110 | +
|
| 111 | + - name: Log in to Azure |
| 112 | + uses: Azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1.6.1 |
| 113 | + with: |
| 114 | + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} |
| 115 | + |
| 116 | + - name: Retrieve secrets |
| 117 | + env: |
| 118 | + ACCOUNT_NAME: bitwardenci |
| 119 | + CONTAINER_NAME: mobile |
| 120 | + run: | |
| 121 | + mkdir -p ${{ github.workspace }}/secrets |
| 122 | + mkdir -p ${{ github.workspace }}/keystores |
| 123 | +
|
| 124 | + az storage blob download --account-name $ACCOUNT_NAME --container-name $CONTAINER_NAME \ |
| 125 | + --name authenticator_apk-keystore.jks --file ${{ github.workspace }}/keystores/authenticator_apk-keystore.jks --output none |
| 126 | +
|
| 127 | + az storage blob download --account-name $ACCOUNT_NAME --container-name $CONTAINER_NAME \ |
| 128 | + --name authenticator_aab-keystore.jks --file ${{ github.workspace }}/keystores/authenticator_aab-keystore.jks --output none |
| 129 | +
|
| 130 | + az storage blob download --account-name $ACCOUNT_NAME --container-name $CONTAINER_NAME \ |
| 131 | + --name com.bitwarden.authenticator-google-services.json --file ${{ github.workspace }}/authenticator/src/google-services.json --output none |
| 132 | +
|
| 133 | + az storage blob download --account-name $ACCOUNT_NAME --container-name $CONTAINER_NAME \ |
| 134 | + --name com.bitwarden.authenticator.dev-google-services.json --file ${{ github.workspace }}/authenticator/src/debug/google-services.json --output none |
| 135 | +
|
| 136 | + - name: Download Firebase credentials |
| 137 | + if : ${{ inputs.distribute-to-firebase || github.event_name == 'push' }} |
| 138 | + env: |
| 139 | + ACCOUNT_NAME: bitwardenci |
| 140 | + CONTAINER_NAME: mobile |
| 141 | + run: | |
| 142 | + mkdir -p ${{ github.workspace }}/secrets |
| 143 | +
|
| 144 | + az storage blob download --account-name $ACCOUNT_NAME --container-name $CONTAINER_NAME \ |
| 145 | + --name authenticator_play_firebase-creds.json --file ${{ github.workspace }}/secrets/authenticator_play_firebase-creds.json --output none |
| 146 | +
|
| 147 | + - name: Download Play Store credentials |
| 148 | + if: ${{ inputs.publish-to-play-store }} |
| 149 | + env: |
| 150 | + ACCOUNT_NAME: bitwardenci |
| 151 | + CONTAINER_NAME: mobile |
| 152 | + run: | |
| 153 | + mkdir -p ${{ github.workspace }}/secrets |
| 154 | +
|
| 155 | + az storage blob download --account-name $ACCOUNT_NAME --container-name $CONTAINER_NAME \ |
| 156 | + --name authenticator_play_store-creds.json --file ${{ github.workspace }}/secrets/authenticator_play_store-creds.json --output none |
| 157 | +
|
| 158 | + - name: Verify Play Store credentials |
| 159 | + if: ${{ inputs.publish-to-play-store }} |
| 160 | + run: | |
| 161 | + bundle exec fastlane run validate_play_store_json_key \ |
| 162 | + json_key:${{ github.workspace }}/secrets/authenticator_play_store-creds.json }} |
| 163 | +
|
| 164 | + - name: Validate Gradle wrapper |
| 165 | + uses: gradle/actions/wrapper-validation@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2 |
| 166 | + |
| 167 | + - name: Cache Gradle files |
| 168 | + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 169 | + with: |
| 170 | + path: | |
| 171 | + ~/.gradle/caches |
| 172 | + ~/.gradle/wrapper |
| 173 | + key: ${{ runner.os }}-gradle-v2-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/libs.versions.toml') }} |
| 174 | + restore-keys: | |
| 175 | + ${{ runner.os }}-gradle-v2- |
| 176 | +
|
| 177 | + - name: Cache build output |
| 178 | + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 179 | + with: |
| 180 | + path: | |
| 181 | + ${{ github.workspace }}/build-cache |
| 182 | + key: ${{ runner.os }}-build-cache-${{ github.sha }} |
| 183 | + restore-keys: | |
| 184 | + ${{ runner.os }}-build- |
| 185 | +
|
| 186 | + - name: Configure JDK |
| 187 | + uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 |
| 188 | + with: |
| 189 | + distribution: "temurin" |
| 190 | + java-version: ${{ env.JAVA_VERSION }} |
| 191 | + |
| 192 | + - name: Increment version |
| 193 | + run: | |
| 194 | + DEFAULT_VERSION_CODE=$GITHUB_RUN_NUMBER |
| 195 | + VERSION_CODE="${{ inputs.version-code || '$DEFAULT_VERSION_CODE' }}" |
| 196 | + bundle exec fastlane setAuthenticatorBuildVersionInfo \ |
| 197 | + versionCode:$VERSION_CODE \ |
| 198 | + versionName:${{ inputs.version-name || '' }} |
| 199 | +
|
| 200 | + regex='versionName = "([^"]+)"' |
| 201 | + if [[ "$(cat authenticator/build.gradle.kts)" =~ $regex ]]; then |
| 202 | + VERSION_NAME="${BASH_REMATCH[1]}" |
| 203 | + fi |
| 204 | + echo "Version Name: ${VERSION_NAME}" >> $GITHUB_STEP_SUMMARY |
| 205 | + echo "Version Number: $VERSION_CODE" >> $GITHUB_STEP_SUMMARY |
| 206 | +
|
| 207 | + - name: Generate release Play Store bundle |
| 208 | + if: ${{ matrix.variant == 'aab' }} |
| 209 | + run: | |
| 210 | + bundle exec fastlane bundleAuthenticatorRelease \ |
| 211 | + storeFile:${{ github.workspace }}/keystores/authenticator_aab-keystore.jks \ |
| 212 | + storePassword:'${{ secrets.BWA_AAB_KEYSTORE_STORE_PASSWORD }}' \ |
| 213 | + keyAlias:authenticatorupload \ |
| 214 | + keyPassword:'${{ secrets.BWA_AAB_KEYSTORE_KEY_PASSWORD }}' |
| 215 | +
|
| 216 | + - name: Generate release Play Store APK |
| 217 | + if: ${{ matrix.variant == 'apk' }} |
| 218 | + run: | |
| 219 | + bundle exec fastlane buildAuthenticatorRelease \ |
| 220 | + storeFile:${{ github.workspace }}/keystores/authenticator_apk-keystore.jks \ |
| 221 | + storePassword:'${{ secrets.BWA_APK_KEYSTORE_STORE_PASSWORD }}' \ |
| 222 | + keyAlias:bitwardenauthenticator \ |
| 223 | + keyPassword:'${{ secrets.BWA_APK_KEYSTORE_KEY_PASSWORD }}' |
| 224 | +
|
| 225 | + - name: Upload release Play Store .aab artifact |
| 226 | + if: ${{ matrix.variant == 'aab' }} |
| 227 | + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 |
| 228 | + with: |
| 229 | + name: com.bitwarden.authenticator.aab |
| 230 | + path: authenticator/build/outputs/bundle/release/com.bitwarden.authenticator.aab |
| 231 | + if-no-files-found: error |
| 232 | + |
| 233 | + - name: Upload release .apk artifact |
| 234 | + if: ${{ matrix.variant == 'apk' }} |
| 235 | + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 |
| 236 | + with: |
| 237 | + name: com.bitwarden.authenticator.apk |
| 238 | + path: authenticator/build/outputs/apk/release/com.bitwarden.authenticator.apk |
| 239 | + if-no-files-found: error |
| 240 | + |
| 241 | + - name: Create checksum file for Release AAB |
| 242 | + if: ${{ matrix.variant == 'aab' }} |
| 243 | + run: | |
| 244 | + sha256sum "authenticator/build/outputs/bundle/release/com.bitwarden.authenticator.aab" \ |
| 245 | + > ./authenticator-android-aab-sha256.txt |
| 246 | +
|
| 247 | + - name: Create checksum for release .apk artifact |
| 248 | + if: ${{ matrix.variant == 'apk' }} |
| 249 | + run: | |
| 250 | + sha256sum "authenticator/build/outputs/apk/release/com.bitwarden.authenticator.apk" \ |
| 251 | + > ./authenticator-android-apk-sha256.txt |
| 252 | +
|
| 253 | + - name: Upload .apk SHA file for release |
| 254 | + if: ${{ matrix.variant == 'apk' }} |
| 255 | + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 |
| 256 | + with: |
| 257 | + name: authenticator-android-apk-sha256.txt |
| 258 | + path: ./authenticator-android-apk-sha256.txt |
| 259 | + if-no-files-found: error |
| 260 | + |
| 261 | + - name: Upload .aab SHA file for release |
| 262 | + if: ${{ matrix.variant == 'aab' }} |
| 263 | + uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 |
| 264 | + with: |
| 265 | + name: authenticator-android-aab-sha256.txt |
| 266 | + path: ./authenticator-android-aab-sha256.txt |
| 267 | + if-no-files-found: error |
| 268 | + |
| 269 | + - name: Install Firebase app distribution plugin |
| 270 | + if: ${{ inputs.distribute-to-firebase || github.event_name == 'push' }} |
| 271 | + run: bundle exec fastlane add_plugin firebase_app_distribution |
| 272 | + |
| 273 | + - name: Publish release bundle to Firebase |
| 274 | + if: ${{ matrix.variant == 'aab' && (inputs.distribute-to-firebase || github.event_name == 'push') }} |
| 275 | + env: |
| 276 | + FIREBASE_CREDS_PATH: ${{ github.workspace }}/secrets/authenticator_play_firebase-creds.json |
| 277 | + run: | |
| 278 | + bundle exec fastlane distributeAuthenticatorReleaseBundleToFirebase \ |
| 279 | + serviceCredentialsFile:${{ env.FIREBASE_CREDS_PATH }} |
| 280 | +
|
| 281 | + # Only publish bundles to Play Store when `publish-to-play-store` is true while building |
| 282 | + # bundles |
| 283 | + - name: Publish release bundle to Google Play Store |
| 284 | + if: ${{ inputs.publish-to-play-store && matrix.variant == 'aab' }} |
| 285 | + env: |
| 286 | + PLAY_STORE_CREDS_FILE: ${{ github.workspace }}/secrets/authenticator_play_store-creds.json |
| 287 | + run: | |
| 288 | + bundle exec fastlane publishAuthenticatorReleaseToGooglePlayStore \ |
| 289 | + serviceCredentialsFile:${{ env.PLAY_STORE_CREDS_FILE }} \ |
0 commit comments