fix: fix failed to read app version in gh-actions #14
Workflow file for this run
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 Release | |
on: | |
push: | |
tags: | |
- v[0-9]+.[0-9]+.[0-9]+** | |
workflow_dispatch: | |
inputs: | |
sshDebug: | |
description: "Setup an ssh connection for debugging." | |
required: true | |
type: boolean | |
default: false | |
env: | |
VERSION_BRANCH: version | |
VERSION_FILE: version.properties | |
ARTIFACT_APK: release.apk | |
ARTIFACT_MAPPINGS: mappings | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
QNEVO_SIGNING_STORE_PATH: ${{ github.workspace }}/release.jks | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'gradle' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Write KeyStore File | |
uses: RollyPeres/base64-to-path@v1 | |
with: | |
filePath: ${{ env.QNEVO_SIGNING_STORE_PATH }} | |
encodedString: ${{ secrets.SIGNING_KEYSTORE }} | |
- name: Setup Debug Session | |
if: ${{ inputs.sshDebug }} | |
uses: csexton/debugger-action@master | |
- name: Generate version properties | |
run: ./gradlew appVersion | |
- name: Assemble Release APK | |
run: ./gradlew assembleRelease | |
env: | |
QNEVO_SIGNING_STORE_PWD: ${{ secrets.SIGNING_STORE_PASSWORD }} | |
QNEVO_SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} | |
QNEVO_SIGNING_KEY_PWD: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
- name: Upload APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_APK }} | |
path: "app/build/outputs/apk/release/app-release.apk" | |
if-no-files-found: error | |
- name: Upload Mapping Files | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_MAPPINGS }} | |
path: "app/build/outputs/mapping/release" | |
if-no-files-found: error | |
- name: Generate Version Info | |
run: ./gradlew appVersion | |
- name: Upload version.properties | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.VERSION_FILE }} | |
path: ${{ env.VERSION_FILE }} | |
if-no-files-found: error | |
retention-days: 1 | |
draft-release: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: write | |
steps: | |
- name: Download APK | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_APK }} | |
- name: Download Mappings | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_MAPPINGS }} | |
path: mappings | |
- name: Tar Mapping Files | |
run: | | |
cd mappings | |
tar -zcf mappings.tar.gz ./* | |
mv mappings.tar.gz ../ | |
cd .. | |
- name: Release | |
uses: ncipollo/release-action@v1 | |
with: | |
draft: true | |
artifactErrorsFailBuild: true | |
artifacts: "app-release.apk,mappings.tar.gz" | |
# commit the version file to 'version' branch so that F-Droid can utilize it for new version detecting | |
update-version: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout version branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.VERSION_BRANCH }} | |
fetch-depth: 0 | |
- name: Delete version.properties | |
run: rm -f $VERSION_FILE | |
- name: Download version.properties | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.VERSION_FILE }} | |
- name: Show version info | |
run: cat $VERSION_FILE | |
- name: Commit and push | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Update version.properties | |
push_options: '--force' | |
skip_fetch: true |