Luu 1 год назад
Родитель
Сommit
e7bb51a625
1 измененных файлов с 44 добавлено и 17 удалено
  1. 44 17
      .github/workflows/main.yml

+ 44 - 17
.github/workflows/main.yml

@@ -1,16 +1,12 @@
-name: UFBT Build and Test
+name: Build and Release Metroflip
 
 
 on:
 on:
   push:
   push:
-    branches:
-      - main
-  pull_request:
-    branches:
-      - main
+    tags:
+      - 'v*.*.*'
 
 
 jobs:
 jobs:
   build:
   build:
-    name: Build and Test Application
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
 
 
     steps:
     steps:
@@ -20,23 +16,54 @@ jobs:
       - name: Set up Python
       - name: Set up Python
         uses: actions/setup-python@v4
         uses: actions/setup-python@v4
         with:
         with:
-          python-version: '3.x'
+          python-version: 3.x
 
 
       - name: Install UFBT
       - name: Install UFBT
+        run: pip install ufbt
+
+      - name: Parse Version from Manifest
+        id: version
         run: |
         run: |
-          python3 -m pip install --upgrade pip
-          pip install ufbt
+          VERSION=$(grep '^version:' manifest.yml | awk '{print $2}')
+          echo "VERSION=${VERSION}" >> $GITHUB_ENV
+          echo "::set-output name=version::${VERSION}"
 
 
-      - name: Initialize UFBT Environment
+      - name: Build Metroflip
         run: |
         run: |
           ufbt update
           ufbt update
-          ufbt vscode_dist
+          ufbt fap_metroflip
 
 
-      - name: Build FAP Applications
-        run: ufbt faps
+      - name: Prepare Release Directory
+        run: |
+          mkdir -p releases/${VERSION}
+          mv build/fap/metroflip.fap releases/${VERSION}/metroflip.fap
 
 
-      - name: Upload Build Artifacts
+      - name: Upload Build Artifact
         uses: actions/upload-artifact@v3
         uses: actions/upload-artifact@v3
         with:
         with:
-          name: build-output
-          path: build/
+          name: metroflip-${{ env.VERSION }}
+          path: releases/${{ env.VERSION }}/metroflip.fap
+
+  release:
+    needs: build
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Download Build Artifact
+        uses: actions/download-artifact@v3
+        with:
+          name: metroflip-${{ env.VERSION }}
+
+      - name: Create GitHub Release
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: ${{ github.ref_name }}
+          release_name: Metroflip ${{ github.ref_name }}
+          draft: false
+          prerelease: false
+          files: releases/${{ env.VERSION }}/metroflip.fap
+          body: |
+            ## Changes
+            See the [CHANGELOG.md](https://github.com/luu176/Metroflip/blob/${{ github.ref_name }}/CHANGELOG.md) for details.