From 45caff3ae0fdfe58a36dbdeeff91656a365a10d6 Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Sat, 8 Jun 2024 07:09:18 +0700 Subject: [PATCH] ci: Build for PR --- .github/workflows/build_check.yml | 50 +++++++++++++++++++++++++++++++ .github/workflows/build_push.yml | 16 +++++----- 2 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build_check.yml diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml new file mode 100644 index 0000000000..3fa38e087b --- /dev/null +++ b/.github/workflows/build_check.yml @@ -0,0 +1,50 @@ +name: Build PR + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: [pull_request] + +jobs: + build: + name: Build app + runs-on: ubuntu-latest + + steps: + - name: Clone repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Android SDK + run: | + ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3" + + - name: Setup Gradle + uses: null2264/actions/gradle-setup@c63d62af63686cb442114b979d4bedb96a514881 + with: + java: 17 + distro: adopt + + - name: Copy CI gradle.properties + run: | + mkdir -p ~/.gradle + cp .github/runner-files/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Build and run tests + if: startsWith(env.VERSION_TAG, 'r') != true && startsWith(env.VERSION_TAG, 'v') != true + run: ./gradlew assembleDevDebug testDevDebugUnitTest + + - name: Publish test report + uses: mikepenz/action-junit-report@v4 + if: success() || failure() + with: + include_passed: true + detailed_summary: true + report_paths: '**/build/test-results/test*/TEST-*.xml' + + - name: Upload APK to artifact + uses: actions/upload-artifact@v4 + with: + path: app/build/outputs/apk/dev/debug/*.apk diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 723518208a..40275a2849 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -1,4 +1,4 @@ -name: CI +name: Build release on: push: branches: @@ -99,8 +99,8 @@ jobs: report_paths: '**/build/test-results/test*/TEST-*.xml' - name: Sign APK - if: env.VERSION_TAG != '' uses: null2264/actions/android-signer@c63d62af63686cb442114b979d4bedb96a514881 + if: env.VERSION_TAG != '' with: releaseDir: app/build/outputs/apk/standard/${{ startsWith(env.VERSION_TAG, 'v') && 'release' || 'nightly' }} signingKeyBase64: ${{ secrets.SIGNING_KEY }} @@ -109,6 +109,12 @@ jobs: keyPassword: ${{ secrets.KEY_PASSWORD }} summarise: true + - name: Upload APK to artifact + uses: actions/upload-artifact@v4 + if: startsWith(env.VERSION_TAG, 'r') != true && startsWith(env.VERSION_TAG, 'v') != true + with: + path: app/build/outputs/apk/standard/debug/*.apk + - name: Clean up build artifacts if: env.VERSION_TAG != '' run: | @@ -213,9 +219,3 @@ jobs: prerelease: false env: GITHUB_TOKEN: ${{ secrets.NIGHTLY_PAT }} - - # - name: Delete Old Nightly - # if: startsWith(env.VERSION_TAG, 'r') && env.PREV_TAG != '' - # run: gh release delete ${{ env.PREV_TAG }} --cleanup-tag - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}