|
58 | 58 | - name: Setup git branch |
59 | 59 | run: | |
60 | 60 | git fetch --all --tags --force |
| 61 | + git fetch origin '+refs/notes/*:refs/notes/*' || true |
61 | 62 | git checkout -B main |
62 | 63 | git branch --set-upstream-to=origin/main main |
63 | 64 |
|
@@ -85,18 +86,42 @@ jobs: |
85 | 86 | git config user.name "github-actions[bot]" |
86 | 87 | git config user.email "github-actions[bot]@users.noreply.github.com" |
87 | 88 |
|
| 89 | + - name: Ensure v1.0.0-beta.1 is in main history |
| 90 | + run: | |
| 91 | + set -e |
| 92 | + # semantic-release uses "git tag --merged main"; if the tag points to a commit not in main, it is ignored. |
| 93 | + 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. |
| 99 | + RELEASE_COMMIT=$(git log main -1 --format=%H --grep="chore(release): 1.0.0-beta.1" 2>/dev/null || true) |
| 100 | + if [ -z "$RELEASE_COMMIT" ]; then |
| 101 | + RELEASE_COMMIT=$(git merge-base main origin/master 2>/dev/null || git rev-parse HEAD~1) |
| 102 | + fi |
| 103 | + git tag -d v1.0.0-beta.1 2>/dev/null || true |
| 104 | + git tag -a v1.0.0-beta.1 "$RELEASE_COMMIT" -m "chore: 1.0.0-beta.1" |
| 105 | + if [ "${{ github.event.inputs.dry_run }}" != "true" ]; then |
| 106 | + git push origin v1.0.0-beta.1 --force |
| 107 | + fi |
| 108 | + echo "Moved v1.0.0-beta.1 to $RELEASE_COMMIT so it is in main history." |
| 109 | +
|
88 | 110 | - name: Add semantic-release note to v1.0.0-beta.1 if missing |
89 | 111 | run: | |
| 112 | + set -e |
90 | 113 | # Existing v1.0.0-beta.1 tag has no git note, so semantic-release ignores it and tries to re-release it. |
91 | 114 | # Add the note so it is treated as last release and the next version is 1.0.0-beta.2. |
92 | | - if git rev-parse --verify v1.0.0-beta.1 >/dev/null 2>&1; then |
93 | | - if ! git notes --ref semantic-release-v1.0.0-beta.1 show v1.0.0-beta.1 >/dev/null 2>&1; then |
94 | | - git notes --ref semantic-release-v1.0.0-beta.1 add -f -m '{"channels":["beta"]}' v1.0.0-beta.1 |
95 | | - if [ "${{ github.event.inputs.dry_run }}" != "true" ]; then |
96 | | - git push origin refs/notes/semantic-release-v1.0.0-beta.1 |
97 | | - fi |
98 | | - fi |
| 115 | + if ! git rev-parse --verify v1.0.0-beta.1 >/dev/null 2>&1; then |
| 116 | + echo "Tag v1.0.0-beta.1 not found, skipping note step." |
| 117 | + exit 0 |
| 118 | + fi |
| 119 | + # Always ensure the note exists (-f overwrites); required for get-last-release to see this tag on main. |
| 120 | + git notes --ref semantic-release-v1.0.0-beta.1 add -f -m '{"channels":["beta"]}' v1.0.0-beta.1 |
| 121 | + if [ "${{ github.event.inputs.dry_run }}" != "true" ]; then |
| 122 | + git push origin refs/notes/semantic-release-v1.0.0-beta.1 |
99 | 123 | fi |
| 124 | + echo "Added semantic-release note to v1.0.0-beta.1" |
100 | 125 |
|
101 | 126 | - name: Create initial tag if needed |
102 | 127 | if: github.event.inputs.dry_run != 'true' |
|
0 commit comments