Skip to content

Commit 767dc50

Browse files
author
strausr
committed
fix(release): correct dry-run next version and branch config
- Use master as release branch in .releaserc to avoid EDUPLICATEBRANCHES and satisfy at least-one-release-branch requirement; main stays prerelease beta - In dry run, create v1.0.0-beta.1 locally when missing so semantic-release sees a previous release and reports 1.0.0-beta.2 for new commits
1 parent beed14e commit 767dc50

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ jobs:
113113
echo "To perform a real release, run again and uncheck 'Dry run only'."
114114
echo ""
115115
116+
- name: Ensure v1.0.0-beta.1 exists locally (dry run only)
117+
if: github.event.inputs.dry_run == 'true'
118+
run: |
119+
if ! git rev-parse --verify "v1.0.0-beta.1" >/dev/null 2>&1; then
120+
# So semantic-release sees a "previous release" and suggests 1.0.0-beta.2 for new commits
121+
PARENT=$(git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD)
122+
git tag -a "v1.0.0-beta.1" "$PARENT" -m "chore: initial beta release (dry-run placeholder)"
123+
echo "Created local tag v1.0.0-beta.1 at $PARENT so semantic-release can compute next version (1.0.0-beta.2)."
124+
else
125+
echo "Tag v1.0.0-beta.1 already exists."
126+
fi
127+
116128
- name: Debug semantic-release config
117129
run: |
118130
echo "=== .releaserc.json ==="
@@ -141,7 +153,9 @@ jobs:
141153
run: |
142154
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
143155
echo "Running semantic-release in DRY RUN mode..."
144-
npx semantic-release --dry-run
156+
npx semantic-release --dry-run 2>&1 | tee semantic-release.log || true
157+
# Extract "The next release version is X" for use in summary step
158+
grep -oE "The next release version is [^[:space:]]+" semantic-release.log 2>/dev/null | sed 's/The next release version is //' > next-version.txt || echo "" > next-version.txt
145159
else
146160
echo "Running semantic-release (REAL release)..."
147161
npx semantic-release
@@ -184,5 +198,12 @@ jobs:
184198
echo "=============================================="
185199
echo " DRY RUN - Skipping npm publish"
186200
echo "=============================================="
187-
echo "Version that WOULD have been published: $(node -p "require('./package.json').version")"
201+
NEXT_VERSION=$(cat next-version.txt 2>/dev/null || echo "")
202+
if [ -n "$NEXT_VERSION" ]; then
203+
echo "Version that WOULD have been published: $NEXT_VERSION"
204+
else
205+
echo "Version that WOULD have been published: (check semantic-release output above; might be no new release)"
206+
echo "Current package.json: $(node -p "require('./package.json').version")"
207+
fi
208+
echo ""
188209
echo "To publish for real, run the workflow again with 'Dry run only' unchecked."

.releaserc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"branches": [
3-
"main",
3+
"master",
44
{
55
"name": "main",
66
"prerelease": "beta"

0 commit comments

Comments
 (0)