ci: Build for PR

This commit is contained in:
Ahmad Ansori Palembani 2024-06-08 07:09:18 +07:00
parent 05e799a925
commit 45caff3ae0
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 58 additions and 8 deletions

50
.github/workflows/build_check.yml vendored Normal file
View file

@ -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

View file

@ -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 }}