Bläddra i källkod

ci(cache-save): fix release not found when tag exists

Tag existed but gh release view failed -> gh release upload returned
release not found. Split check into tag vs release: ensure tag pushed
then create release if gh release view misses, verify creation

Co-Authored-By: internal-model
TheWildJames 1 vecka sedan
förälder
incheckning
2fc2b830c4
1 ändrade filer med 17 tillägg och 2 borttagningar
  1. 17 2
      .github/actions/cache-save/action.yml

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

@@ -68,13 +68,28 @@ runs:
         git fetch --tags --force
         
         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..."
           GIT_COMMITTER_DATE="2015-01-01T12:00:00" git tag -a "$TAG_NAME" -m "General Cache Storage"
           if git push origin "$TAG_NAME" --force; then
-            gh release create "$TAG_NAME" --title "General Cache" --notes "Automated storage for build assets" --repo "$TARGET_REPO" || true
+            echo "Tag pushed"
           else
             echo "Push failed, tag might have been created by a parallel job. Continuing..."
           fi
+        else
+          echo "Tag '$TAG_NAME' exists locally."
+        fi
+        if ! gh release view "$TAG_NAME" --repo "$TARGET_REPO" >/dev/null 2>&1; then
+          echo "Release '$TAG_NAME' not found. Creating release..."
+          # ensure tag is pushed before creating release
+          git push origin "$TAG_NAME" --force >/dev/null 2>&1 || true
+          gh release create "$TAG_NAME" --title "General Cache" --notes "Automated storage for build assets" --repo "$TARGET_REPO" || true
+          # verify
+          if gh release view "$TAG_NAME" --repo "$TARGET_REPO" >/dev/null 2>&1; then
+            echo "Release '$TAG_NAME' created."
+          else
+            echo "⚠ Failed to create release '$TAG_NAME' — will retry upload anyway"
+            gh release view "$TAG_NAME" --repo "$TARGET_REPO" 2>&1 | head -n 20 || true
+          fi
         else
           echo "Release '$TAG_NAME' already exists. Ready for upload."
         fi