@@ -207,16 +207,10 @@ COMMIT_MESSAGE="release: prepare ${VERSION}"
207207git commit -m " $COMMIT_MESSAGE "
208208echo -e " ${GREEN} Created commit: $COMMIT_MESSAGE ${NC} "
209209
210- # Create annotated tag
211- echo -e " ${YELLOW} Creating git tag ${VERSION} ...${NC} "
212- git tag -a " $VERSION " -m " Go ContextForge SDK $VERSION "
213- echo -e " ${GREEN} Created annotated tag: $VERSION ${NC} "
214-
215- # Check for GoReleaser and GITHUB_TOKEN
210+ # Check for GoReleaser and GITHUB_TOKEN (before creating tag)
216211if ! command -v goreleaser & > /dev/null; then
217212 echo -e " ${RED} Error: goreleaser is not installed${NC} "
218213 echo -e " ${YELLOW} Install with: go install github.com/goreleaser/goreleaser/v2@latest${NC} "
219- git tag -d " $VERSION "
220214 git reset --hard HEAD~1
221215 exit 1
222216fi
@@ -229,8 +223,7 @@ if [ -z "$GITHUB_TOKEN" ]; then
229223 echo -e " ${YELLOW} Continue anyway? Release will fail but you can retry later. (y/N)${NC} "
230224 read -r response
231225 if [[ ! " $response " =~ ^[Yy]$ ]]; then
232- echo -e " ${YELLOW} Undoing tag and commit...${NC} "
233- git tag -d " $VERSION "
226+ echo -e " ${YELLOW} Undoing commit...${NC} "
234227 git reset --hard HEAD~1
235228 exit 1
236229 fi
240233echo -e " ${YELLOW} Running GoReleaser...${NC} "
241234if ! goreleaser release --clean; then
242235 echo -e " ${RED} Error: GoReleaser failed${NC} "
243- echo -e " ${YELLOW} Undoing tag and commit...${NC} "
244- git tag -d " $VERSION "
236+ echo -e " ${YELLOW} Undoing commit...${NC} "
245237 git reset --hard HEAD~1
246238 exit 1
247239fi
@@ -252,8 +244,7 @@ echo -e "${GREEN}GoReleaser completed successfully!${NC}"
252244echo -e " ${YELLOW} Merging changelog...${NC} "
253245if ! merge_changelog " $VERSION " ; then
254246 echo -e " ${RED} Error: Changelog merge failed${NC} "
255- echo -e " ${YELLOW} Undoing tag and commit...${NC} "
256- git tag -d " $VERSION "
247+ echo -e " ${YELLOW} Undoing commit...${NC} "
257248 git reset --hard HEAD~1
258249 exit 1
259250fi
@@ -265,6 +256,11 @@ git add CHANGELOG.md
265256git commit --amend --no-edit
266257echo -e " ${GREEN} Updated release commit with changelog${NC} "
267258
259+ # Create annotated tag (after commit is amended so tag points to final commit)
260+ echo -e " ${YELLOW} Creating git tag ${VERSION} ...${NC} "
261+ git tag -a " $VERSION " -m " Go ContextForge SDK $VERSION "
262+ echo -e " ${GREEN} Created annotated tag: $VERSION ${NC} "
263+
268264# Display next steps
269265echo " "
270266echo -e " ${GREEN} ========================================${NC} "
@@ -287,8 +283,9 @@ echo " https://github.com/leefowlercu/go-contextforge/releases"
287283echo " "
288284echo " 3. If changes needed:"
289285echo " - Edit CHANGELOG.md locally and/or release notes on GitHub"
290- echo " - Amend commit: git add CHANGELOG.md && git commit --amend --no-edit"
291- echo " - Update tag: git tag -fa $VERSION -m \" Go ContextForge SDK $VERSION \" "
286+ echo " - Amend commit and update tag:"
287+ echo " git add CHANGELOG.md && git commit --amend --no-edit"
288+ echo " git tag -fa $VERSION -m \" Go ContextForge SDK $VERSION \" "
292289echo " - OR undo completely: git tag -d $VERSION && git reset --hard HEAD~1"
293290echo " "
294291echo " 4. When ready to publish:"
0 commit comments