Update workflow to build release APK and create GitHub releases

This commit is contained in:
cmclark00 2025-03-20 15:16:24 -04:00
parent 313db4ee3b
commit ad18d34cd0

View file

@ -1,10 +1,10 @@
name: Build Android APK name: Build and Release Android APK
on: on:
push: push:
branches: [ main, master ] branches: [ main, master ]
pull_request: tags:
branches: [ main, master ] - 'v*'
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@ -24,11 +24,53 @@ jobs:
- name: Grant execute permission for gradlew - name: Grant execute permission for gradlew
run: chmod +x gradlew run: chmod +x gradlew
- name: Build with Gradle - name: Build Release APK
run: ./gradlew assembleDebug run: ./gradlew assembleRelease
- name: Upload APK - name: Upload APK as artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: app-debug name: app-release
path: app/build/outputs/apk/debug/app-debug.apk path: app/build/outputs/apk/release/app-release-unsigned.apk
- name: Get version name from build.gradle
id: version
run: |
VERSION_NAME=$(grep -o 'versionName = "[^"]*' app/build.gradle.kts | cut -d'"' -f2)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "APP_VERSION=$VERSION_NAME" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: Release ${{ env.VERSION_NAME }}
draft: false
prerelease: false
files: app/build/outputs/apk/release/app-release-unsigned.apk
body: |
TetriStats Android App Release v${{ env.VERSION_NAME }}
Automatically generated release from GitHub Actions.
Download the APK from the assets below.
- name: Create Release on Push
id: create_release_on_push
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.event_name == 'push' }}
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION_NAME }}-${{ github.run_number }}
name: Release v${{ env.VERSION_NAME }}-${{ github.run_number }}
draft: false
prerelease: false
files: app/build/outputs/apk/release/app-release-unsigned.apk
body: |
TetriStats Android App Release v${{ env.VERSION_NAME }}-${{ github.run_number }}
Automatically generated release from GitHub Actions.
Download the APK from the assets below.