Skip to content

Commit 9458516

Browse files
authored
Update tag-with-gitversion.yml
1 parent f904d5b commit 9458516

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/tag-with-gitversion.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,26 @@ jobs:
2828

2929
- name: Create and push annotated tag (minor+1, patch=0)
3030
env:
31-
GH_TOKEN: ${{ secrets.GIST_AUTH_TOKEN }}
31+
PERSONAL_ACCESS_TOKEN: ${{ secrets.GIST_AUTH_TOKEN }}
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3233
run: |
3334
set -euo pipefail
3435
MAJOR="${{ steps.gitversion.outputs.major }}"
3536
MINOR="${{ steps.gitversion.outputs.minor }}"
3637
# increment minor and set patch to 0
3738
NEW_MINOR=$((MINOR + 1))
3839
TAG="v${MAJOR}.${NEW_MINOR}.0"
39-
git config user.name github-actions[bot]
40-
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
41-
git tag -a $TAG -m "Tag created by GitHub Actions using GitVersion (incremented minor)"
42-
git push origin $TAG
40+
echo "Computed tag: $TAG"
41+
git config user.name "github-actions[bot]"
42+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
43+
# create annotated tag (fail if exists)
44+
git tag -a "$TAG" -m "Tag created by GitHub Actions using GitVersion (incremented minor)"
45+
# choose token: use PAT if provided (recommended), otherwise fallback to GITHUB_TOKEN
46+
TOKEN="${PERSONAL_ACCESS_TOKEN:-${GITHUB_TOKEN}}"
47+
if [ -z "$TOKEN" ]; then
48+
echo "No token available to push tag"
49+
exit 1
50+
fi
51+
# Push the tag using the chosen token over HTTPS to ensure it triggers other workflows
52+
git push "https://x-access-token:${TOKEN}@github.com/${{ github.repository }}" "$TAG"
4353

0 commit comments

Comments
 (0)