Skip to content

Commit 63ae3b1

Browse files
committed
fix(release): create temporary tag for goreleaser validation
1 parent 8cb1bed commit 63ae3b1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/prepare-release.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,16 @@ COMMIT_MESSAGE="release: prepare ${VERSION}"
207207
git commit -m "$COMMIT_MESSAGE"
208208
echo -e "${GREEN}Created commit: $COMMIT_MESSAGE${NC}"
209209

210-
# Check for GoReleaser and GITHUB_TOKEN (before creating tag)
210+
# Create temporary tag for GoReleaser validation (will be recreated after amending)
211+
echo -e "${YELLOW}Creating temporary git tag ${VERSION} for GoReleaser...${NC}"
212+
git tag -a "$VERSION" -m "Go ContextForge SDK $VERSION"
213+
echo -e "${GREEN}Created temporary tag: $VERSION${NC}"
214+
215+
# Check for GoReleaser and GITHUB_TOKEN
211216
if ! command -v goreleaser &> /dev/null; then
212217
echo -e "${RED}Error: goreleaser is not installed${NC}"
213218
echo -e "${YELLOW}Install with: go install github.com/goreleaser/goreleaser/v2@latest${NC}"
219+
git tag -d "$VERSION"
214220
git reset --hard HEAD~1
215221
exit 1
216222
fi
@@ -223,7 +229,8 @@ if [ -z "$GITHUB_TOKEN" ]; then
223229
echo -e "${YELLOW}Continue anyway? Release will fail but you can retry later. (y/N)${NC}"
224230
read -r response
225231
if [[ ! "$response" =~ ^[Yy]$ ]]; then
226-
echo -e "${YELLOW}Undoing commit...${NC}"
232+
echo -e "${YELLOW}Undoing tag and commit...${NC}"
233+
git tag -d "$VERSION"
227234
git reset --hard HEAD~1
228235
exit 1
229236
fi
@@ -233,7 +240,8 @@ fi
233240
echo -e "${YELLOW}Running GoReleaser...${NC}"
234241
if ! goreleaser release --clean; then
235242
echo -e "${RED}Error: GoReleaser failed${NC}"
236-
echo -e "${YELLOW}Undoing commit...${NC}"
243+
echo -e "${YELLOW}Undoing tag and commit...${NC}"
244+
git tag -d "$VERSION"
237245
git reset --hard HEAD~1
238246
exit 1
239247
fi
@@ -244,7 +252,8 @@ echo -e "${GREEN}GoReleaser completed successfully!${NC}"
244252
echo -e "${YELLOW}Merging changelog...${NC}"
245253
if ! merge_changelog "$VERSION"; then
246254
echo -e "${RED}Error: Changelog merge failed${NC}"
247-
echo -e "${YELLOW}Undoing commit...${NC}"
255+
echo -e "${YELLOW}Undoing tag and commit...${NC}"
256+
git tag -d "$VERSION"
248257
git reset --hard HEAD~1
249258
exit 1
250259
fi
@@ -256,10 +265,11 @@ git add CHANGELOG.md
256265
git commit --amend --no-edit
257266
echo -e "${GREEN}Updated release commit with changelog${NC}"
258267

259-
# Create annotated tag (after commit is amended so tag points to final commit)
260-
echo -e "${YELLOW}Creating git tag ${VERSION}...${NC}"
268+
# Delete temporary tag and recreate on amended commit (so tag points to final commit hash)
269+
echo -e "${YELLOW}Recreating git tag ${VERSION} on final commit...${NC}"
270+
git tag -d "$VERSION"
261271
git tag -a "$VERSION" -m "Go ContextForge SDK $VERSION"
262-
echo -e "${GREEN}Created annotated tag: $VERSION${NC}"
272+
echo -e "${GREEN}Created final tag: $VERSION${NC}"
263273

264274
# Display next steps
265275
echo ""

0 commit comments

Comments
 (0)