Skip to content

Commit 24c83cb

Browse files
author
strausr
committed
fix: remove broken v1.0.0-beta.1 tag so semantic-release can create it (one-time)
Delete existing v1.0.0-beta.1 tag in workflow so semantic-release recreates it with channel note; avoids 'tag already exists' error.
1 parent a314fa3 commit 24c83cb

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,22 @@ jobs:
9595
git notes --ref semantic-release-v1.0.0-beta.1 add -f -m '{"channels":["beta"]}' v1.0.0-beta.1
9696
echo "Added semantic-release note to v1.0.0-beta.1 (local only for dry run)."
9797
98-
# One-time migration: v1.0.0-beta.1 existed before semantic-release was configured
99-
# with channel notes. Semantic-release prepares all other versions itself (tags + notes).
100-
# This step only fixes that one tag so semantic-release can see it as "last release".
101-
- name: Migrate v1.0.0-beta.1 tag for semantic-release (one-time)
98+
# One-time fix: v1.0.0-beta.1 existed before semantic-release (manual publish).
99+
# It has no channel note, so semantic-release ignores it and tries to create the tag again → "tag already exists".
100+
# Fix: delete the broken tag so semantic-release can create it properly (with note). After this run, remove this step.
101+
- name: Remove broken v1.0.0-beta.1 tag so semantic-release can create it (one-time)
102102
if: github.event.inputs.dry_run != 'true'
103103
run: |
104104
set -e
105-
echo "=== Migrating v1.0.0-beta.1 so semantic-release sees it as last release ==="
106-
# semantic-release treats a tag as "last release" only if: 1) tag is in "git tag --merged main", 2) tag has note {"channels":["beta"]} in ref semantic-release-<tag>
107-
if ! git rev-parse --verify "v1.0.0-beta.1" >/dev/null 2>&1; then
108-
echo "Tag v1.0.0-beta.1 does not exist; creating at HEAD."
109-
git tag -a "v1.0.0-beta.1" HEAD -m "chore: initial beta release"
110-
git push origin "v1.0.0-beta.1"
111-
git notes --ref semantic-release-v1.0.0-beta.1 add -f -m '{"channels":["beta"]}' v1.0.0-beta.1
112-
git push origin refs/notes/semantic-release-v1.0.0-beta.1
113-
echo "Created v1.0.0-beta.1 and note."
105+
if git rev-parse --verify "v1.0.0-beta.1" >/dev/null 2>&1; then
106+
echo "Removing existing v1.0.0-beta.1 (no channel note); semantic-release will recreate it with note."
107+
git tag -d v1.0.0-beta.1 2>/dev/null || true
108+
git push origin ":refs/tags/v1.0.0-beta.1" || true
109+
git push origin ":refs/notes/semantic-release-v1.0.0-beta.1" 2>/dev/null || true
110+
echo "Done. semantic-release will create v1.0.0-beta.1 from scratch."
114111
else
115-
echo "Tag v1.0.0-beta.1 exists."
116-
if ! git tag --merged main | grep -qx v1.0.0-beta.1; then
117-
RELEASE_COMMIT=$(git log main -1 --format=%H --grep="chore(release): 1.0.0-beta.1" 2>/dev/null || true)
118-
[ -z "$RELEASE_COMMIT" ] && RELEASE_COMMIT=$(git merge-base main origin/master 2>/dev/null || git rev-parse HEAD~1)
119-
echo "Moving tag into main history (was not merged into main) to $RELEASE_COMMIT"
120-
git tag -d v1.0.0-beta.1 2>/dev/null || true
121-
git tag -a v1.0.0-beta.1 "$RELEASE_COMMIT" -m "chore: 1.0.0-beta.1"
122-
git push origin v1.0.0-beta.1 --force
123-
fi
124-
git notes --ref semantic-release-v1.0.0-beta.1 add -f -m '{"channels":["beta"]}' v1.0.0-beta.1
125-
git push origin refs/notes/semantic-release-v1.0.0-beta.1
126-
git fetch origin '+refs/tags/*:refs/tags/*' '+refs/notes/*:refs/notes/*'
127-
echo "Tags merged into main: $(git tag --merged main | tr '\n' ' ')"
128-
git notes --ref semantic-release-v1.0.0-beta.1 show v1.0.0-beta.1 2>/dev/null && echo "Note present for v1.0.0-beta.1" || echo "WARN: no note for v1.0.0-beta.1"
112+
echo "Tag v1.0.0-beta.1 does not exist; semantic-release will create it."
129113
fi
130-
echo "=== Done; semantic-release will see v1.0.0-beta.1 as last release ==="
131114
132115
- name: Dry run mode notice
133116
if: github.event.inputs.dry_run == 'true'

0 commit comments

Comments
 (0)