Skip to content

Commit ae0b519

Browse files
committed
ci: tolerate existing codecane staging tag
1 parent 27b818a commit ae0b519

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

.github/workflows/cli-release-staging.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
if: contains(github.event.pull_request.title, '[codecane]')
1818
outputs:
1919
new_version: ${{ steps.bump_version.outputs.new_version }}
20-
tag_exists: ${{ steps.check_tag.outputs.exists }}
2120
steps:
2221
- uses: actions/checkout@v4
2322
with:
@@ -118,27 +117,36 @@ jobs:
118117
🤖 Generated with Codebuff
119118
Co-Authored-By: Codebuff <noreply@codebuff.com>"
120119
121-
- name: Check if staging tag exists
122-
id: check_tag
120+
- name: Create and push staging tag
123121
run: |
122+
set -euo pipefail
124123
TAG="v${{ steps.bump_version.outputs.new_version }}"
124+
125125
if git ls-remote --tags origin "$TAG" | grep -q "$TAG"; then
126-
echo "Tag $TAG already exists on origin; skipping tag creation."
127-
echo "exists=true" >> "$GITHUB_OUTPUT"
128-
else
129-
echo "exists=false" >> "$GITHUB_OUTPUT"
126+
echo "Tag $TAG already exists on origin; skipping push."
127+
exit 0
130128
fi
131129
132-
- name: Create and push staging tag
133-
if: steps.check_tag.outputs.exists != 'true'
134-
run: |
135-
git tag "v${{ steps.bump_version.outputs.new_version }}"
136-
git push origin "v${{ steps.bump_version.outputs.new_version }}"
130+
if git rev-parse "$TAG" >/dev/null 2>&1; then
131+
echo "Tag $TAG already exists locally; removing before re-tagging."
132+
git tag -d "$TAG"
133+
fi
137134
138-
- name: Tag already exists
139-
if: steps.check_tag.outputs.exists == 'true'
140-
run: |
141-
echo "Tag v${{ steps.bump_version.outputs.new_version }} already present on origin; continuing without pushing."
135+
git tag "$TAG"
136+
137+
if git push origin "$TAG"; then
138+
echo "Pushed tag $TAG to origin."
139+
exit 0
140+
fi
141+
142+
echo "Push failed, re-checking remote for $TAG..."
143+
if git ls-remote --tags origin "$TAG" | grep -q "$TAG"; then
144+
echo "Tag $TAG is present on origin after push attempt; continuing."
145+
exit 0
146+
fi
147+
148+
echo "Failed to push tag $TAG and it is not present on origin."
149+
exit 1
142150
143151
- name: Upload staging metadata
144152
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)