From 50e33110dfaa1ebe02893591c8bd0dc1b9216df6 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Tue, 16 Apr 2024 01:18:12 +0200
Subject: [PATCH] github: create release on tag

---
 .github/workflows/build.yml | 39 ++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1c45562..102501c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -51,19 +51,52 @@ jobs:
       - name: Upload APK Debug
         uses: actions/upload-artifact@v4
         with:
-          name: APK(s) debug generated
+          name: apk-debug
           path: ${{ env.main_project_module }}/build/outputs/apk/debug/
 
       # Noted For Output [main_project_module]/build/outputs/apk/release/
       - name: Upload APK Release
         uses: actions/upload-artifact@v4
         with:
-          name: APK(s) release generated
+          name: apk-release
           path: ${{ env.main_project_module }}/build/outputs/apk/release/
 
       # Noted For Output [main_project_module]/build/outputs/bundle/release/
       - name: Upload AAB (App Bundle) Release
         uses: actions/upload-artifact@v4
         with:
-          name: App bundle(s) AAB release generated
+          name: aab-bundles
           path: ${{ env.main_project_module }}/build/outputs/bundle/release/
+
+  release:
+    runs-on: ubuntu-22.04
+    needs: build
+    # Only run if tag pushed
+    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
+    steps:
+      - name: Download Artifact (Debug)
+        uses: actions/download-artifact@v4
+        with:
+          name: apk-debug
+          path: ${{ github.workspace }}/artifacts-debug
+
+      - name: Download APK (Release)
+        uses: actions/download-artifact@v4
+        with:
+          name: apk-release
+          path: ${{ github.workspace }}/artifacts-release
+
+      - name: Download App Bundle
+        uses: actions/download-artifact@v4
+        with:
+          name: aab-bundles
+          path: ${{ github.workspace }}/artifacts-bundle
+
+      - name: Create GitHub Release
+        uses: softprops/action-gh-release@v2
+        with:
+          draft: true
+          files: |
+            ${{ github.workspace }}/artifacts-release/app-release-unsigned.apk
+            ${{ github.workspace }}/artifacts-debug/app-debug.apk
+            ${{ github.workspace }}/artifacts-bundle/app-release.aab
\ No newline at end of file