|
28 | 28 | - "gradlew" |
29 | 29 | - ".github/workflows/android-ci.yaml" |
30 | 30 |
|
| 31 | +# Cancel obsolete runs when new commits land on a PR / branch. Never |
| 32 | +# cancel runs on main (we want every commit's tag) or on tag refs. |
| 33 | +concurrency: |
| 34 | + group: android-ci-${{ github.ref }} |
| 35 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }} |
| 36 | + |
31 | 37 | jobs: |
32 | 38 | build: |
| 39 | + # Skip on tag pushes — the release job below handles them and the |
| 40 | + # commit was already built when it landed on main. |
| 41 | + if: ${{ !startsWith(github.ref, 'refs/tags/v') }} |
33 | 42 | runs-on: ubuntu-latest |
34 | 43 | permissions: |
35 | 44 | contents: write |
36 | 45 | steps: |
37 | | - - uses: actions/checkout@v4 |
38 | | - - uses: actions/setup-java@v4 |
| 46 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 47 | + - uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4 |
39 | 48 | with: |
40 | 49 | distribution: temurin |
41 | 50 | java-version: "17" |
42 | | - - uses: android-actions/setup-android@v3 |
| 51 | + - uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3 |
43 | 52 | with: |
44 | 53 | packages: "platform-tools platforms;android-34 build-tools;34.0.0" |
45 | | - - uses: gradle/actions/setup-gradle@v4 |
| 54 | + - uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4 |
46 | 55 | - name: Pin build date |
47 | 56 | run: echo "BUILD_DATE=$(date -u +%Y-%m-%d)" >> "$GITHUB_ENV" |
48 | 57 | - name: Compute version |
|
58 | 67 | run: ./gradlew lint --stacktrace |
59 | 68 | - name: Upload debug APK |
60 | 69 | if: github.ref == 'refs/heads/main' |
61 | | - uses: actions/upload-artifact@v4 |
| 70 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
62 | 71 | with: |
63 | 72 | name: app-debug-${{ env.VERSION_NAME }} |
64 | 73 | path: app/build/outputs/apk/debug/*.apk |
|
70 | 79 | git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
71 | 80 | git tag "v${VERSION_NAME}" |
72 | 81 | git push origin "v${VERSION_NAME}" |
| 82 | +
|
| 83 | + # Tag-triggered: builds a signed release APK and attaches it to a |
| 84 | + # GitHub Release. Tags come from the build job's "Tag release" step on |
| 85 | + # main. We do not depend on `build` because that job is skipped on tag |
| 86 | + # pushes (the same commit was already tested when it landed on main). |
| 87 | + release: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + if: startsWith(github.ref, 'refs/tags/v') |
| 90 | + permissions: |
| 91 | + contents: write |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 94 | + - uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4 |
| 95 | + with: |
| 96 | + distribution: temurin |
| 97 | + java-version: "17" |
| 98 | + - uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3 |
| 99 | + with: |
| 100 | + packages: "platform-tools platforms;android-34 build-tools;34.0.0" |
| 101 | + - uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4 |
| 102 | + - name: Decode keystore |
| 103 | + if: env.KEYSTORE_B64 != '' |
| 104 | + run: echo "$KEYSTORE_B64" | base64 -d > "$RUNNER_TEMP/release.keystore" |
| 105 | + env: |
| 106 | + KEYSTORE_B64: ${{ secrets.QUIRE_RELEASE_KEYSTORE_B64 }} |
| 107 | + - name: Assemble release APK |
| 108 | + env: |
| 109 | + QUIRE_RELEASE_KEYSTORE: ${{ secrets.QUIRE_RELEASE_KEYSTORE_B64 != '' && format('{0}/release.keystore', runner.temp) || '' }} |
| 110 | + QUIRE_RELEASE_KEYSTORE_PASSWORD: ${{ secrets.QUIRE_RELEASE_KEYSTORE_PASSWORD }} |
| 111 | + QUIRE_RELEASE_KEY_ALIAS: ${{ secrets.QUIRE_RELEASE_KEY_ALIAS }} |
| 112 | + QUIRE_RELEASE_KEY_PASSWORD: ${{ secrets.QUIRE_RELEASE_KEY_PASSWORD }} |
| 113 | + run: ./gradlew :app:assembleRelease --stacktrace |
| 114 | + - name: Create GitHub Release |
| 115 | + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 |
| 116 | + with: |
| 117 | + files: app/build/outputs/apk/release/*.apk |
| 118 | + generate_release_notes: true |
0 commit comments