name: Build and Release Android APK on: push: branches: [ main, master ] tags: - 'v*' workflow_dispatch: # Add permissions needed to create releases permissions: contents: write packages: read jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17' cache: gradle - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build Release APK run: ./gradlew assembleRelease - name: Upload APK as artifact uses: actions/upload-artifact@v4 with: name: app-release 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 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.