Просмотр исходного кода

fix(action): enhance release handling by checking for existing releases and creating backdated tags if necessary

TheWildJames 4 месяцев назад
Родитель
Сommit
9db835c740
1 измененных файлов с 8 добавлено и 2 удалено
  1. 8 2
      .github/actions/cache-save/action.yml

+ 8 - 2
.github/actions/cache-save/action.yml

@@ -85,8 +85,13 @@ runs:
           
           
           git fetch --tags --force
           git fetch --tags --force
           
           
+          if gh release view "$tag_name" --repo "$TARGET_REPO" >/dev/null 2>&1; then
+            echo "Release '$tag_name' already exists. Ready for upload."
+            return 0
+          fi
+
           if ! git rev-parse "$tag_name" >/dev/null 2>&1; then
           if ! git rev-parse "$tag_name" >/dev/null 2>&1; then
-            echo "Tag '$tag_name' not found. Creating backdated release..."
+            echo "Tag '$tag_name' not found. Creating backdated tag and release..."
             GIT_COMMITTER_DATE="2015-01-01T12:00:00" git tag -a "$tag_name" -m "Build Cache Storage"
             GIT_COMMITTER_DATE="2015-01-01T12:00:00" git tag -a "$tag_name" -m "Build Cache Storage"
             if git push origin "$tag_name" --force; then
             if git push origin "$tag_name" --force; then
               gh release create "$tag_name" --title "Build Cache" --notes "Automated storage for build assets" --repo "$TARGET_REPO" || true
               gh release create "$tag_name" --title "Build Cache" --notes "Automated storage for build assets" --repo "$TARGET_REPO" || true
@@ -94,7 +99,8 @@ runs:
               echo "Push failed, tag might have been created by a parallel job. Continuing..."
               echo "Push failed, tag might have been created by a parallel job. Continuing..."
             fi
             fi
           else
           else
-            echo "Release '$tag_name' already exists. Ready for upload."
+            echo "Tag '$tag_name' already exists but release is missing. Creating release..."
+            gh release create "$tag_name" --title "Build Cache" --notes "Automated storage for build assets" --repo "$TARGET_REPO" || true
           fi
           fi
         }
         }