👷 ci(android): build APK + CalVer auto-versioning #2
Workflow file for this run
This file contains hidden or 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 | |
| on: | |
| push: | |
| paths: | |
| - "app/**" | |
| - "auth/**" | |
| - "core/**" | |
| - "data/**" | |
| - "reader/**" | |
| - "build.gradle.kts" | |
| - "settings.gradle.kts" | |
| - "gradle.properties" | |
| - "gradle/**" | |
| - "gradlew" | |
| - ".github/workflows/android-ci.yaml" | |
| pull_request: | |
| paths: | |
| - "app/**" | |
| - "auth/**" | |
| - "core/**" | |
| - "data/**" | |
| - "reader/**" | |
| - "build.gradle.kts" | |
| - "settings.gradle.kts" | |
| - "gradle.properties" | |
| - "gradle/**" | |
| - "gradlew" | |
| - ".github/workflows/android-ci.yaml" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "17" | |
| - uses: android-actions/setup-android@v3 | |
| with: | |
| packages: "platform-tools platforms;android-34 build-tools;34.0.0" | |
| - uses: gradle/actions/setup-gradle@v4 | |
| - name: Pin build date | |
| run: echo "BUILD_DATE=$(date -u +%Y-%m-%d)" >> "$GITHUB_ENV" | |
| - name: Compute version | |
| run: | | |
| VERSION="${BUILD_DATE//-/.}.${GITHUB_RUN_NUMBER}" | |
| echo "VERSION_NAME=$VERSION" >> "$GITHUB_ENV" | |
| echo "Building version $VERSION" | |
| - name: Assemble debug APK | |
| run: ./gradlew assembleDebug --stacktrace | |
| - name: Unit tests | |
| run: ./gradlew test --stacktrace | |
| - name: Lint | |
| run: ./gradlew lint --stacktrace | |
| - name: Upload debug APK | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-debug-${{ env.VERSION_NAME }} | |
| path: app/build/outputs/apk/debug/*.apk | |
| if-no-files-found: error | |
| - name: Tag release | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag "v${VERSION_NAME}" | |
| git push origin "v${VERSION_NAME}" |