fix(ci): delete and recreate tag ref to move latest-main to correct commit
CI / Build & Test (push) Successful in 1m36s
CI / Build & Test (push) Successful in 1m36s
Made-with: Cursor
This commit is contained in:
+9
-10
@@ -136,21 +136,20 @@ jobs:
|
||||
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
||||
AUTH="Authorization: token ${{ secrets.RELEASE_TOKEN }}"
|
||||
|
||||
# Force-move the git tag to the current commit
|
||||
# Try to update existing ref first, create if it doesn't exist
|
||||
UPDATE=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH \
|
||||
-H "$AUTH" -H "Content-Type: application/json" \
|
||||
"${API}/git/refs/tags/${TAG}" \
|
||||
-d "{\"sha\": \"${{ github.sha }}\", \"force\": true}")
|
||||
echo "Tag update HTTP: $UPDATE"
|
||||
# Force-move the git tag to the current commit.
|
||||
# Delete the old tag ref first, then recreate it pointing at the new SHA.
|
||||
echo "Deleting old tag ref ${TAG}..."
|
||||
curl -s -X DELETE \
|
||||
-H "$AUTH" \
|
||||
"${API}/git/refs/tags/${TAG}" || true
|
||||
|
||||
if [ "$UPDATE" != "200" ]; then
|
||||
echo "Tag doesn't exist yet, creating..."
|
||||
sleep 1
|
||||
|
||||
echo "Creating tag ref ${TAG} at ${{ github.sha }}..."
|
||||
curl -s -X POST \
|
||||
-H "$AUTH" -H "Content-Type: application/json" \
|
||||
"${API}/git/refs" \
|
||||
-d "{\"ref\": \"refs/tags/${TAG}\", \"sha\": \"${{ github.sha }}\"}"
|
||||
fi
|
||||
|
||||
# Get existing release by tag (if any)
|
||||
EXISTING=$(curl -s -H "$AUTH" "${API}/releases/tags/${TAG}")
|
||||
|
||||
Reference in New Issue
Block a user