Build Release #20
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: Build Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| versionName: | |
| required: true | |
| description: This releases version name | |
| default: "1.0.0" | |
| versionCode: | |
| required: true | |
| description: This releases version code | |
| default: "1000" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@master | |
| - name: Setup JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: 17 | |
| distribution: 'temurin' | |
| cache: 'gradle' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v2.0.10 | |
| - name: Set Version | |
| uses: chkfung/android-version-actions@v1.1 | |
| with: | |
| gradlePath: app/build.gradle.kts | |
| versionCode: ${{github.event.inputs.versionCode}} | |
| versionName: ${{github.event.inputs.versionName}} | |
| - name: Bump Version | |
| continue-on-error: true | |
| run: | | |
| git config --local user.email "actions@github.com" | |
| git config --local user.name "GitHub Actions" | |
| git add app/build.gradle.kts | |
| if ! git diff --quiet app/build.gradle.kts; then | |
| git commit -m "chore: Bump version to ${{github.event.inputs.versionName}} (${{github.event.inputs.versionCode}})" | |
| git push | |
| else | |
| echo "No changes to version file, skipping commit" | |
| fi | |
| - name: Build Signed APK | |
| run: | | |
| echo "${{ secrets.keystore }}" | base64 -d > $GITHUB_WORKSPACE/signing-key.jks | |
| chmod +x ./gradlew | |
| ./gradlew packageReleaseUniversalApk \ | |
| -Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/signing-key.jks \ | |
| -Pandroid.injected.signing.store.password=${{ secrets.keystore_password }} \ | |
| -Pandroid.injected.signing.key.alias=${{ secrets.key_alias }} \ | |
| -Pandroid.injected.signing.key.password=${{ secrets.key_password }} | |
| - name: Release | |
| run: | | |
| mv app/build/outputs/apk_from_bundle/release/app-release-universal.apk ./app-release.apk | |
| git config --local user.email "actions@github.com" | |
| git config --local user.name "GitHub Actions" | |
| tag="${{ github.event.inputs.versionCode }}" | |
| git tag "$tag" | |
| git push origin "$tag" | |
| gh release create "$tag" \ | |
| --title "${{ github.event.inputs.versionName }}" \ | |
| --generate-notes \ | |
| ./*.apk | |
| env: | |
| GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |