Skip to content

Commit ee8eeb7

Browse files
authored
fix release-tag workflow for release tag on main (#85)
The release-tag workflow checks out a commit (not a branch), leaving git in detached HEAD state. `git push origin HEAD` fails because git cannot resolve the bare `HEAD` symbolic ref to a remote branch name. Create a temporary local branch before committing and use an explicit refspec (`tmp/release-vX.Y.Z:refs/heads/main`) so the push is an unambiguous fast-forward to main.
1 parent d519639 commit ee8eeb7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/release-tag.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ jobs:
141141
git config user.name "github-actions[bot]"
142142
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
143143
144+
# workflow_call checkouts may leave us in detached HEAD when the
145+
# caller is triggered from a tag ref. Create a temporary local
146+
# branch so that `git commit` works and we can push to main.
147+
TEMP_BRANCH="tmp/release-${TAG}"
148+
git checkout -B "${TEMP_BRANCH}"
149+
144150
# Stage version-bearing files and lockfile changes
145151
git add -A
146152
# Ensure CodeQL-generated artifacts are not staged for commit
@@ -154,7 +160,7 @@ jobs:
154160
else
155161
git commit -m "Release ${TAG}: update versions to ${RELEASE_NAME}"
156162
CURRENT_SHA=$(git rev-parse HEAD)
157-
git push origin HEAD
163+
git push origin "${TEMP_BRANCH}:refs/heads/main"
158164
echo "✅ Committed version changes at ${CURRENT_SHA:0:8}"
159165
fi
160166

0 commit comments

Comments
 (0)