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

+ 19 - 0
.github/workflows/main.yml

@@ -60,8 +60,26 @@ jobs:
           VERSION=$(grep '^version:' manifest.yml | awk '{print $2}')
           echo "VERSION=${VERSION}" >> $GITHUB_ENV
 
+      - name: Check if Release Exists
+        id: check_release
+        run: |
+          REPO="luu176/Metroflip"
+          TAG="v${{ env.VERSION }}"
+          RELEASE_EXISTS=$(curl -s https://api.github.com/repos/$REPO/releases/tags/$TAG)
+          echo "RELEASE_EXISTS=$RELEASE_EXISTS"
+          if [[ $RELEASE_EXISTS == *"Not Found"* ]]; then
+            echo "Release not found. Creating new release."
+            echo "create=true" >> $GITHUB_ENV
+          else
+            echo "Release found. Deleting existing release."
+            RELEASE_ID=$(echo $RELEASE_EXISTS | jq -r '.[0].id')
+            curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/releases/$RELEASE_ID
+            echo "create=true" >> $GITHUB_ENV
+          fi
+
       - name: Create Release
         id: create_release
+        if: env.create == 'true'
         uses: actions/create-release@v1
         with:
           tag_name: v${{ env.VERSION }}
@@ -75,6 +93,7 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Upload FAP File to Release
+        if: env.create == 'true'
         uses: actions/upload-release-asset@v1
         with:
           upload_url: ${{ steps.create_release.outputs.upload_url }}