|
17 | 17 | if: contains(github.event.pull_request.title, '[codecane]') |
18 | 18 | outputs: |
19 | 19 | new_version: ${{ steps.bump_version.outputs.new_version }} |
20 | | - tag_exists: ${{ steps.check_tag.outputs.exists }} |
21 | 20 | steps: |
22 | 21 | - uses: actions/checkout@v4 |
23 | 22 | with: |
@@ -118,27 +117,36 @@ jobs: |
118 | 117 | 🤖 Generated with Codebuff |
119 | 118 | Co-Authored-By: Codebuff <noreply@codebuff.com>" |
120 | 119 |
|
121 | | - - name: Check if staging tag exists |
122 | | - id: check_tag |
| 120 | + - name: Create and push staging tag |
123 | 121 | run: | |
| 122 | + set -euo pipefail |
124 | 123 | TAG="v${{ steps.bump_version.outputs.new_version }}" |
| 124 | +
|
125 | 125 | 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 |
130 | 128 | fi |
131 | 129 |
|
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 |
137 | 134 |
|
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 |
142 | 150 |
|
143 | 151 | - name: Upload staging metadata |
144 | 152 | uses: actions/upload-artifact@v4 |
|
0 commit comments