Merge branch 'main' into portrait-mediapipe #119
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android CI/CD | |
on: | |
push: | |
branches: | |
- '**' # Trigger on all branches | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
# Checkout repository | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
# Set up JDK | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: wrapper | |
cache-read-only: false | |
# Cache Gradle dependencies | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# Change the version of the project | |
- name: Bump version | |
uses: Swisyn/android-version-generator-actions@v1.5 | |
with: | |
gradlePath: app/build.gradle.kts | |
versionCode: ${{github.run_number}} | |
versionName: 0.1.${{github.run_number}} | |
# Build and run unit tests | |
- name: Build | |
run: ./gradlew assembleRelease --no-daemon | |
- name: Run Tests | |
run: ./gradlew jacocoTestReport | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./build/reports/jacoco/jacocoTestReport.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Sign app APK | |
if: github.ref == 'refs/heads/main' | |
uses: ilharp/sign-android-release@nightly | |
id: sign_app | |
with: | |
releaseDir: app/build/outputs/apk/release | |
signingKey: ${{ secrets.ANDROID_SIGNING_KEY }} | |
keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }} | |
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
buildToolsVersion: 35.0.0 | |
# Publish APK to GitHub Releases only on main branch | |
- name: Publish to GitHub Releases | |
if: github.ref == 'refs/heads/main' | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: v${{ github.run_number }} | |
name: "Nightly ${{ github.run_number }}" | |
draft: false | |
prerelease: true | |
artifacts: ${{steps.sign_app.outputs.signedFile}} | |
token: ${{ secrets.GITHUB_TOKEN }} |