88 description : ' Version number (e.g., 1.2.3 - no v prefix)'
99 required : true
1010 type : string
11+ dry_run :
12+ description : ' Dry run mode (test without publishing)'
13+ required : false
14+ type : boolean
15+ default : false
1116
1217# Required permissions for version commits, tags, releases, and npm provenance
1318permissions :
2227 outputs :
2328 commit_sha : ${{ steps.commit.outputs.sha }}
2429 steps :
30+ - name : Check dry run mode
31+ run : |
32+ if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
33+ echo "🔍 DRY RUN MODE ENABLED - No changes will be pushed to remote"
34+ echo "================================================"
35+ fi
36+
2537 - name : Checkout
2638 uses : actions/checkout@v4
2739 with :
8698
8799 - name : Push version commit
88100 run : |
89- git push origin HEAD
90- echo "✓ Version commit pushed to remote"
101+ if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
102+ echo "🔍 DRY RUN: Would push version commit to remote"
103+ echo " Commit SHA: $(git rev-parse HEAD)"
104+ echo " Branch: $(git branch --show-current)"
105+ else
106+ git push origin HEAD
107+ echo "✓ Version commit pushed to remote"
108+ fi
91109
92110 # Job 2: Create and push version tag
93111 create-version-tag :
@@ -99,15 +117,35 @@ jobs:
99117 uses : actions/checkout@v4
100118 with :
101119 fetch-depth : 0
102- ref : ${{ needs.create-version-commit.outputs.commit_sha }}
120+ ref : ${{ github.event.inputs.dry_run == 'true' && github.ref || needs.create-version-commit.outputs.commit_sha }}
103121 token : ${{ secrets.GITHUB_TOKEN }}
104122
123+ - name : Setup Node.js (Dry Run)
124+ if : github.event.inputs.dry_run == 'true'
125+ uses : actions/setup-node@v4
126+ with :
127+ node-version : ' 20'
128+ cache : ' yarn'
129+
130+ - name : Update package.json version (Dry Run)
131+ if : github.event.inputs.dry_run == 'true'
132+ run : |
133+ VERSION="${{ github.event.inputs.version }}"
134+ echo "Updating package.json to version $VERSION (dry run)"
135+ npm version $VERSION --no-git-tag-version
136+ echo "✓ package.json updated to version $VERSION"
137+
105138 - name : Create and push tag
106139 run : |
107140 VERSION="${{ github.event.inputs.version }}"
108- git tag "v$VERSION"
109- git push origin "v$VERSION"
110- echo "✓ Tag v$VERSION created and pushed"
141+ if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
142+ echo "🔍 DRY RUN: Would create and push tag v$VERSION"
143+ echo " Current commit: $(git rev-parse HEAD)"
144+ else
145+ git tag "v$VERSION"
146+ git push origin "v$VERSION"
147+ echo "✓ Tag v$VERSION created and pushed"
148+ fi
111149
112150 # Job 3: Publish to NPM
113151 publish-npm :
@@ -122,7 +160,7 @@ jobs:
122160 uses : actions/checkout@v4
123161 with :
124162 fetch-depth : 0
125- ref : ${{ needs.create-version-commit.outputs.commit_sha }}
163+ ref : ${{ github.event.inputs.dry_run == 'true' && github.ref || needs.create-version-commit.outputs.commit_sha }}
126164
127165 - name : Setup Node.js
128166 uses : actions/setup-node@v4
@@ -134,6 +172,14 @@ jobs:
134172 - name : Install dependencies
135173 run : yarn install --frozen-lockfile
136174
175+ - name : Update package.json version (Dry Run)
176+ if : github.event.inputs.dry_run == 'true'
177+ run : |
178+ VERSION="${{ github.event.inputs.version }}"
179+ echo "Updating package.json to version $VERSION (dry run)"
180+ npm version $VERSION --no-git-tag-version
181+ echo "✓ package.json updated to version $VERSION"
182+
137183 - name : Build library
138184 run : yarn prepare
139185
@@ -147,9 +193,15 @@ jobs:
147193
148194 - name : Publish to NPM
149195 run : |
150- echo "Publishing to NPM with provenance..."
151- npm publish --provenance --access public
152- echo "✓ Package published to NPM registry"
196+ if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
197+ echo "🔍 DRY RUN: Testing NPM publish..."
198+ npm publish --dry-run --access public
199+ echo "✓ Dry run completed - package would be published to NPM registry"
200+ else
201+ echo "Publishing to NPM with provenance..."
202+ npm publish --provenance --access public
203+ echo "✓ Package published to NPM registry"
204+ fi
153205 env :
154206 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
155207
@@ -165,7 +217,7 @@ jobs:
165217 uses : actions/checkout@v4
166218 with :
167219 fetch-depth : 0
168- ref : ${{ needs.create-version-commit.outputs.commit_sha }}
220+ ref : ${{ github.event.inputs.dry_run == 'true' && github.ref || needs.create-version-commit.outputs.commit_sha }}
169221
170222 - name : Generate Release Notes
171223 id : release_notes
@@ -232,9 +284,18 @@ jobs:
232284 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
233285
234286 - name : Create Release
287+ if : github.event.inputs.dry_run != 'true'
235288 uses : softprops/action-gh-release@v1
236289 with :
237290 tag_name : v${{ github.event.inputs.version }}
238291 body : ${{ steps.release_notes.outputs.release_notes }}
239292 env :
240293 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
294+
295+ - name : Display Release Notes (Dry Run)
296+ if : github.event.inputs.dry_run == 'true'
297+ run : |
298+ echo "🔍 DRY RUN: Would create GitHub release with the following notes:"
299+ echo "---"
300+ cat release_notes.md
301+ echo "---"
0 commit comments