Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
chore(workflow): build release APK in separate job
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Oct 27, 2023
1 parent 6ba102b commit b524adc
Showing 1 changed file with 52 additions and 25 deletions.
77 changes: 52 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ on:
workflow_dispatch: { }

jobs:
build_apk:
name: Build APK
build_debug_apk:
name: Build Debug APK
runs-on: ubuntu-latest
if: ${{ github.ref != 'refs/heads/main' }}
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
Expand All @@ -45,7 +46,6 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Assemble Debug
if: ${{ github.ref != 'refs/heads/main' }}
run: ./gradlew assembleDebug
env:
ReleaseAndroidIDE: false
Expand All @@ -57,13 +57,50 @@ jobs:
IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }}
IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }}
- name: Copy debug APK
if: ${{ github.ref != 'refs/heads/main' }}
run: cp app/build/outputs/apk/**/debug/*.apk ./
- name: Upload arm64-v8a-debug APK
uses: actions/upload-artifact@v3
with:
name: apk-arm64-v8a-debug
path: app-arm64-v8a-arm64-v8a-debug.apk
- name: Upload armeabi-v7a-debug APK
uses: actions/upload-artifact@v3
with:
name: apk-armeabi-v7a-debug
path: app-armeabi-v7a-armeabi-v7a-debug.apk

build_release_apk:
name: Build Release APK
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Change Gradle wrapper permissions
run: chmod +x ./gradlew
- name: Restore cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Assemble Release
if: ${{ github.ref == 'refs/heads/main' }}
run: ./gradlew assembleRelease
env:
ReleaseAndroidIDE: true
ReleaseAndroidIDE: ${{ github.ref == 'refs/heads/main' }}
IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }}
IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }}
IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }}
Expand All @@ -72,32 +109,22 @@ jobs:
IDE_SIGNING_URL: ${{ secrets.IDE_SIGNING_URL }}
IDE_SIGNING_KEY_BIN: ${{ secrets.IDE_SIGNING_KEY_BIN }}
- name: Copy release APK
if: ${{ github.ref == 'refs/heads/main' }}
run: cp app/build/outputs/apk/**/release/*.apk ./
- name: Upload arm64-v8a-debug APK
if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: apk-arm64-v8a-debug
path: app-arm64-v8a-arm64-v8a-debug.apk
- name: Upload armeabi-v7a-debug APK
if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: apk-armeabi-v7a-debug
path: app-armeabi-v7a-armeabi-v7a-debug.apk
- name: Upload arm64-v8a-release APK
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: apk-arm64-v8a-release
path: app-arm64-v8a-arm64-v8a-release.apk
- name: Upload armeabi-v7a-release APK
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: apk-armeabi-v7a-release
path: app-armeabi-v7a-armeabi-v7a-release.apk
- name: Upload mappings
uses: actions/upload-artifact@v3
with:
name: release-mappings
path: '**/build/outputs/mapping'

unit_test_debug:
name: Run local tests
Expand Down Expand Up @@ -197,8 +224,8 @@ jobs:
publish:
name: Publish release
runs-on: ubuntu-latest
needs: [ build_apk, unit_test_debug, unit_test_tooling_api ]
if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.build_apk.result == 'success' && needs.unit_test_debug.result == 'success' && needs.unit_test_tooling_api.result == 'success' }}
needs: [ build_release_apk, unit_test_debug, unit_test_tooling_api ]
if: ${{ always() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && needs.build_release_apk.result == 'success' && needs.unit_test_debug.result == 'success' && needs.unit_test_tooling_api.result == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -248,8 +275,8 @@ jobs:
publish_snapshots:
name: Publish package snapshots
runs-on: ubuntu-latest
needs: [ build_apk ]
if: ${{ always() && github.ref != 'refs/heads/main' && github.event_name != 'pull_request' && needs.build_apk.result == 'success' }}
needs: [ build_debug_apk ]
if: ${{ always() && github.ref != 'refs/heads/main' && github.event_name != 'pull_request' && needs.build_debug_apk.result == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down

0 comments on commit b524adc

Please sign in to comment.