Build and release #4
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: Build and release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version' | |
required: true | |
jobs: | |
unit_tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Unit tests | |
run: ./gradlew testDebugUnitTest | |
- name: Generate code coverage | |
run: ./gradlew app:koverXmlReportDebug | |
- name: Upload test coverage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: code-coverage.xml | |
path: app/build/coverage-report/result.xml | |
build: | |
needs: unit_tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
format: [ | |
{ type: "apk", command: "assembleRelease" }, | |
{ type: "aab", os_version: "bundleRelease" } | |
] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Decode Keystore | |
env: | |
ENCODED_KEYSTORE: ${{ secrets.KEYSTORE_ENCODED }} | |
SIGNING_KEYSTORE_PATH: ${{ secrets.KEYSTORE_PATH }} | |
run: | | |
echo $ENCODED_KEYSTORE > keystore-b64.txt | |
base64 -d keystore-b64.txt > $SIGNING_KEYSTORE_PATH | |
- name: Build release | |
env: | |
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }} | |
KEYSTORE_PATH: ${{ secrets.KEYSTORE_PATH }} | |
run: ./gradlew ${{ matrix.command }} | |
- name: Upload Build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-release.${{ matrix.type }} | |
path: app/build/outputs/${{ matrix.type }}/release/*.${{ matrix.type }} | |
release: | |
needs: build | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Tag Release | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git tag ${{ github.event.inputs.version }} | |
git push origin ${{ github.event.inputs.version }} | |
- name: Download APK | |
uses: actions/download-artifact@v3 | |
with: | |
name: app-release.apk | |
- name: Download AAB | |
uses: actions/download-artifact@v3 | |
with: | |
name: app-release.aab | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifacts: "app-release.apk,app-release.aab" | |
draft: true | |
name: Release ${{ github.event.inputs.version }} | |
tag: ${{ github.event.inputs.version }} |