From d0e7e2aef4b1ca1714c2cf93a2d3c2be496fc2da Mon Sep 17 00:00:00 2001 From: dusy4 <56517228+dusy4@users.noreply.github.com> Date: Fri, 8 May 2026 22:31:16 +0200 Subject: [PATCH] ci(android): simplify release workflow and harden conditions --- .github/workflows/android-release.yml | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/android-release.yml diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml new file mode 100644 index 0000000..f2f5f53 --- /dev/null +++ b/.github/workflows/android-release.yml @@ -0,0 +1,70 @@ +name: Android Release APK + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + release_tag: + description: 'Release tag (example: v1.0.0). Optional on manual runs.' + required: false + default: '' + +permissions: + contents: write + +jobs: + build_and_release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Resolve release tag + shell: bash + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.release_tag }}" ]; then + echo "RELEASE_TAG=${{ github.event.inputs.release_tag }}" >> "$GITHUB_ENV" + else + echo "RELEASE_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" + fi + + - name: Create/push tag for manual runs + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '' }} + shell: bash + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git tag "$RELEASE_TAG" "${{ github.sha }}" || true + git push origin "$RELEASE_TAG" + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '17' + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build release APK + working-directory: android + run: ./gradlew --no-daemon assembleRelease + + - name: Upload APK artifact + uses: actions/upload-artifact@v4 + with: + name: app-release-apk + path: android/app/build/outputs/apk/release/app-release.apk + + - name: Publish APK to GitHub Release + if: ${{ startsWith(env.RELEASE_TAG, 'v') }} + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.RELEASE_TAG }} + generate_release_notes: true + files: android/app/build/outputs/apk/release/app-release.apk