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 }}"
|
API="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
||||||
AUTH="Authorization: token ${{ secrets.RELEASE_TOKEN }}"
|
AUTH="Authorization: token ${{ secrets.RELEASE_TOKEN }}"
|
||||||
|
|
||||||
# Force-move the git tag to the current commit
|
# Force-move the git tag to the current commit.
|
||||||
# Try to update existing ref first, create if it doesn't exist
|
# Delete the old tag ref first, then recreate it pointing at the new SHA.
|
||||||
UPDATE=$(curl -s -o /dev/null -w "%{http_code}" -X PATCH \
|
echo "Deleting old tag ref ${TAG}..."
|
||||||
-H "$AUTH" -H "Content-Type: application/json" \
|
curl -s -X DELETE \
|
||||||
"${API}/git/refs/tags/${TAG}" \
|
-H "$AUTH" \
|
||||||
-d "{\"sha\": \"${{ github.sha }}\", \"force\": true}")
|
"${API}/git/refs/tags/${TAG}" || true
|
||||||
echo "Tag update HTTP: $UPDATE"
|
|
||||||
|
|
||||||
if [ "$UPDATE" != "200" ]; then
|
sleep 1
|
||||||
echo "Tag doesn't exist yet, creating..."
|
|
||||||
|
echo "Creating tag ref ${TAG} at ${{ github.sha }}..."
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "$AUTH" -H "Content-Type: application/json" \
|
-H "$AUTH" -H "Content-Type: application/json" \
|
||||||
"${API}/git/refs" \
|
"${API}/git/refs" \
|
||||||
-d "{\"ref\": \"refs/tags/${TAG}\", \"sha\": \"${{ github.sha }}\"}"
|
-d "{\"ref\": \"refs/tags/${TAG}\", \"sha\": \"${{ github.sha }}\"}"
|
||||||
fi
|
|
||||||
|
|
||||||
# Get existing release by tag (if any)
|
# Get existing release by tag (if any)
|
||||||
EXISTING=$(curl -s -H "$AUTH" "${API}/releases/tags/${TAG}")
|
EXISTING=$(curl -s -H "$AUTH" "${API}/releases/tags/${TAG}")
|
||||||
|
|||||||
Reference in New Issue
Block a user