Skip to content

Commit 3487e6b

Browse files
author
strausr
committed
chore(release): add dry run option to release workflow
1 parent ebd8291 commit 3487e6b

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
dry_run:
7+
description: 'Dry run only (no git push, no tags, no npm publish)'
8+
required: false
9+
default: true
10+
type: boolean
511

612
permissions:
713
contents: write
@@ -47,6 +53,7 @@ jobs:
4753
with:
4854
ref: main
4955
fetch-depth: 0
56+
token: ${{ secrets.RELEASE_TOKEN }}
5057

5158
- name: Setup git branch
5259
run: |
@@ -86,6 +93,7 @@ jobs:
8693
git config user.email "github-actions[bot]@users.noreply.github.com"
8794
8895
- name: Create initial tag if needed
96+
if: github.event.inputs.dry_run != 'true'
8997
run: |
9098
if ! git rev-parse --verify "v1.0.0-beta.1" >/dev/null 2>&1; then
9199
echo "Creating initial tag v1.0.0-beta.1"
@@ -95,6 +103,16 @@ jobs:
95103
echo "Tag v1.0.0-beta.1 already exists"
96104
fi
97105
106+
- name: Dry run mode notice
107+
if: github.event.inputs.dry_run == 'true'
108+
run: |
109+
echo "=============================================="
110+
echo " DRY RUN MODE - No commits, tags, or publish"
111+
echo "=============================================="
112+
echo "Semantic-release will show what WOULD happen."
113+
echo "To perform a real release, run again and uncheck 'Dry run only'."
114+
echo ""
115+
98116
- name: Debug semantic-release config
99117
run: |
100118
echo "=== .releaserc.json ==="
@@ -119,10 +137,18 @@ jobs:
119137
- name: Release with semantic-release
120138
id: release
121139
env:
122-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123-
run: npx semantic-release
140+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
141+
run: |
142+
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
143+
echo "Running semantic-release in DRY RUN mode..."
144+
npx semantic-release --dry-run
145+
else
146+
echo "Running semantic-release (REAL release)..."
147+
npx semantic-release
148+
fi
124149
125150
- name: Publish to npm using trusted publishing
151+
if: github.event.inputs.dry_run != 'true'
126152
run: |
127153
echo "=== Publishing to npm with trusted publishing (OIDC) ==="
128154
@@ -151,3 +177,12 @@ jobs:
151177
echo "No version change detected (version: $VERSION_AFTER)"
152178
echo "Skipping npm publish - no new release was created"
153179
fi
180+
181+
- name: Dry run - skip npm publish
182+
if: github.event.inputs.dry_run == 'true'
183+
run: |
184+
echo "=============================================="
185+
echo " DRY RUN - Skipping npm publish"
186+
echo "=============================================="
187+
echo "Version that WOULD have been published: $(node -p "require('./package.json').version")"
188+
echo "To publish for real, run the workflow again with 'Dry run only' unchecked."

.releaserc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"prerelease": "beta"
66
}
77
],
8+
"tagFormat": "v${version}",
89
"plugins": [
910
"@semantic-release/commit-analyzer",
1011
"@semantic-release/release-notes-generator",

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ This project uses [Conventional Commits](https://www.conventionalcommits.org/) f
5959

6060
Releases are triggered manually via GitHub Actions workflow. The workflow uses npm trusted publishing (OIDC) for secure package publishing.
6161

62+
**Dry run (default):** When you run the workflow, "Dry run only" is checked by default. This runs semantic-release in dry-run mode—**no git push, no tags, no npm publish**. Use this to verify the next version and release notes before doing a real release. To publish for real, run the workflow again and **uncheck** "Dry run only".
63+
6264
### Commit Format
6365

6466
```

0 commit comments

Comments
 (0)