Skip to content

Android RELEASE

Android RELEASE #34

name: Android RELEASE
on: workflow_dispatch
jobs:
test:
name: Test source code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load Gradle from cache
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Run tests
run: ./gradlew testDebugUnitTest --continue --stacktrace
- name: Upload reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: test-reports
path:
./app/build/reports/tests/**
lint:
name: Lint source code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load Gradle from cache
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Run linting
run: ./gradlew lintDebug --stacktrace
- name: Upload reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: lint-reports
path:
./app/build/reports/lint*
test-android:
name: Test source code on Android
runs-on: macos-latest
strategy:
matrix:
api-level: [27, 28, 29]
steps:
- uses: actions/checkout@v3
- name: Load Gradle from cache
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Run android tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb logcat -c
adb logcat & ./gradlew connectedDebugAndroidTest --continue --stacktrace
- name: Upload reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: test-android-reports
path:
./app/build/reports/androidTests/**
build:
name: Build APK
needs: [test, lint, test-android]
runs-on: ubuntu-latest
env:
VERSION_SUFFIX: RELEASE
steps:
- uses: actions/checkout@v3
- name: Load Gradle from cache
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Build APK
id: buildApk
run: ./gradlew assembleRelease --stacktrace
- name: Sign APK
id: signApk
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: ./app/build/outputs/apk/release
alias: ${{ secrets.ALIAS }}
signingKeyBase64: ${{ secrets.KEYSTORE }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.PASSWORD }}
env:
BUILD_TOOLS_VERSION: 30.0.3
- name: Cache APK
uses: actions/cache@v3
with:
path: app/build/outputs/apk/release/
key: ${{ runner.os }}-apk-app-schedule-${{ hashFiles('**/build.gradle', '**/app-versioning.gradle') }}
restore-keys: |
- ${{ runner.os }}-apk-app-schedule-
release:
name: Release APK
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Load Gradle from cache
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle
- id: appVersion
run: echo "::set-output name=VERSION::$(./gradlew -q printVersion)"
- name: Use cached APK
uses: actions/cache@v3
with:
path: app/build/outputs/apk/release/
key: ${{ runner.os }}-apk-app-schedule-${{ hashFiles('**/build.gradle', '**/app-versioning.gradle') }}
restore-keys: |
- ${{ runner.os }}-apk-app-schedule-
id: cache-apk
- name: Upload binariy to artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: apk-v${{ steps.appVersion.outputs.version }}
path: ./app/build/outputs/apk/release/*-signed.apk
- name: Upload binary to release
uses: softprops/action-gh-release@v1
if: steps.cache-apk.outputs.cache-hit == 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: true
generate_release_notes: true
tag_name: v${{ steps.appVersion.outputs.version }}
name: v${{ steps.appVersion.outputs.version }}
files: ./app/build/outputs/apk/release/*-signed.apk