Skip to content

Commit 9b57cce

Browse files
author
strausr
committed
fix(release): always move v1.0.0-beta.1 to release commit when present
Drop the "already in main history" skip; that check could pass on the runner while semantic-release still sees "No git tag version found". Instead, whenever the tag exists, move it to the chore(release): 1.0.0-beta.1 commit (or a known-in-history fallback) so it is always in "git tag --merged main". Only push when not dry run.
1 parent f4c8035 commit 9b57cce

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,27 @@ jobs:
8686
git config user.name "github-actions[bot]"
8787
git config user.email "github-actions[bot]@users.noreply.github.com"
8888
89-
- name: Ensure v1.0.0-beta.1 is in main history
89+
- name: Ensure v1.0.0-beta.1 points to a commit in main history
9090
run: |
9191
set -e
92-
# semantic-release uses "git tag --merged main"; if the tag points to a commit not in main, it is ignored.
92+
# semantic-release uses "git tag --merged main"; the tag must point to a commit in main's history.
93+
# Always move the tag to the 1.0.0-beta.1 release commit so it is visible to semantic-release.
9394
if ! git rev-parse --verify v1.0.0-beta.1 >/dev/null 2>&1; then exit 0; fi
94-
if git tag --merged main | grep -qx v1.0.0-beta.1; then
95-
echo "v1.0.0-beta.1 is already in main history."
96-
exit 0
97-
fi
98-
# Tag exists but is not merged into main; move it to the release commit so semantic-release sees it.
9995
RELEASE_COMMIT=$(git log main -1 --format=%H --grep="chore(release): 1.0.0-beta.1" 2>/dev/null || true)
10096
if [ -z "$RELEASE_COMMIT" ]; then
10197
RELEASE_COMMIT=$(git merge-base main origin/master 2>/dev/null || git rev-parse HEAD~1)
10298
fi
99+
CURRENT=$(git rev-parse v1.0.0-beta.1)
100+
if [ "$CURRENT" = "$RELEASE_COMMIT" ]; then
101+
echo "v1.0.0-beta.1 already points to $RELEASE_COMMIT."
102+
exit 0
103+
fi
103104
git tag -d v1.0.0-beta.1 2>/dev/null || true
104105
git tag -a v1.0.0-beta.1 "$RELEASE_COMMIT" -m "chore: 1.0.0-beta.1"
105106
if [ "${{ github.event.inputs.dry_run }}" != "true" ]; then
106107
git push origin v1.0.0-beta.1 --force
107108
fi
108-
echo "Moved v1.0.0-beta.1 to $RELEASE_COMMIT so it is in main history."
109+
echo "Moved v1.0.0-beta.1 from $CURRENT to $RELEASE_COMMIT."
109110
110111
- name: Add semantic-release note to v1.0.0-beta.1 if missing
111112
run: |

0 commit comments

Comments
 (0)