fix(ci): use git push --force to move latest-main tag to correct commit
CI / Build & Test (push) Successful in 1m48s
CI / Build & Test (push) Successful in 1m48s
Made-with: Cursor
This commit is contained in:
+12
-14
@@ -16,6 +16,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
|
||||||
- name: Check toolchain versions
|
- name: Check toolchain versions
|
||||||
run: |
|
run: |
|
||||||
@@ -136,20 +139,15 @@ 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 using git directly.
|
||||||
# Delete the old tag ref first, then recreate it pointing at the new SHA.
|
# Set remote URL with token so we can push.
|
||||||
echo "Deleting old tag ref ${TAG}..."
|
REPO_URL=$(git remote get-url origin | sed 's|https://|https://x-token:${{ secrets.RELEASE_TOKEN }}@|')
|
||||||
curl -s -X DELETE \
|
git remote set-url origin "${REPO_URL}"
|
||||||
-H "$AUTH" \
|
git config user.email "ci@holesail-browser"
|
||||||
"${API}/git/refs/tags/${TAG}" || true
|
git config user.name "CI"
|
||||||
|
git tag -f "${TAG}" "${{ github.sha }}"
|
||||||
sleep 1
|
git push origin "refs/tags/${TAG}" --force
|
||||||
|
echo "Tag ${TAG} force-pushed to ${{ github.sha }}"
|
||||||
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 }}\"}"
|
|
||||||
|
|
||||||
# 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