diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4486ec..3616027 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,10 @@ -name: Build Android APK +name: Build and Release Android APK on: push: branches: [ main, master ] - pull_request: - branches: [ main, master ] + tags: + - 'v*' workflow_dispatch: jobs: @@ -24,11 +24,53 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew assembleDebug + - name: Build Release APK + run: ./gradlew assembleRelease - - name: Upload APK + - name: Upload APK as artifact uses: actions/upload-artifact@v4 with: - name: app-debug - path: app/build/outputs/apk/debug/app-debug.apk \ No newline at end of file + 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 + 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. \ No newline at end of file