Skip to content

Commit 2844cbf

Browse files
committed
#133: Update publishing documentation for automated workflow
Updated docs/development/publishing.md to reflect tag-based automated publishing workflow instead of manual npm publish commands. Changes: - Automated publishing via git tag push - NPM_TOKEN secret management and renewal process - Provenance verification steps - Emergency manual publishing fallback - Updated quick reference commands
1 parent 3df5c70 commit 2844cbf

1 file changed

Lines changed: 81 additions & 40 deletions

File tree

docs/development/publishing.md

Lines changed: 81 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -123,35 +123,48 @@ npm run test:coverage
123123
npm run test:mutation
124124
```
125125

126-
### 5. Publish to npm
126+
### 5. Push Tag to Trigger Automated Publishing
127127

128128
```bash
129-
# Login to npm (if not already)
130-
npm login
129+
# Push tag to GitHub (triggers automated workflow)
130+
git push origin v0.4.0
131131

132-
# Publish (dry run first)
133-
npm publish --dry-run
134-
135-
# Publish for real
136-
npm publish --access public
132+
# Or push commit and tag together
133+
git push origin master --tags
137134
```
138135

136+
**What happens automatically:**
137+
1. GitHub Actions workflow triggers on tag push
138+
2. Installs dependencies (`npm ci`)
139+
3. Runs build and tests (via `prepublishOnly` hook)
140+
4. Publishes to npm with provenance
141+
5. Package appears on npm with cryptographic signature
142+
143+
**Monitor the workflow:**
144+
- GitHub → Actions → "Publish to npm"
145+
- Check logs if publish fails
146+
139147
### 6. Post-Publication
140148

141-
1. **Push to GitHub**
149+
1. **Create GitHub Release**
142150
```bash
143-
git push origin master --tags
151+
# Create release from tag
152+
gh release create v0.4.0 --generate-notes
153+
154+
# Or manually via GitHub UI
155+
# Go to GitHub → Releases → "Draft a new release"
156+
# Select the version tag
157+
# Title: v0.4.0
158+
# Description: Copy from CHANGELOG.md
144159
```
145160

146-
2. **Create GitHub Release**
147-
- Go to GitHub → Releases → "Draft a new release"
148-
- Select the version tag
149-
- Title: `v0.4.0`
150-
- Description: Copy from CHANGELOG.md
151-
- Attach any binaries if needed
161+
2. **Verify npm Package**
162+
- Visit https://www.npmjs.com/package/@migration-script-runner/core
163+
- Verify new version is published
164+
- Check for "Provenance" badge (cryptographic proof)
152165

153166
3. **Announce Release**
154-
- Update project README
167+
- Update project README if needed
155168
- Post in discussions if major release
156169
- Tweet/social media if significant
157170

@@ -245,31 +258,57 @@ v1.0.0
245258

246259
## Release Automation
247260

248-
### CI/CD Pipeline
261+
### Automated Publishing Workflow
262+
263+
**Workflow:** `.github/workflows/npm-publish.yml`
264+
265+
**Triggers:**
266+
- Push of version tags (e.g., `v0.8.0`, `v1.0.0`)
267+
- Manual trigger via GitHub Actions UI
268+
269+
**Process:**
270+
1. Checkout repository
271+
2. Setup Node.js 20
272+
3. Install dependencies (`npm ci`)
273+
4. Run build and tests (via `prepublishOnly` hook)
274+
5. Publish to npm with provenance signature
275+
6. Authenticate using `NPM_TOKEN` secret (granular access token)
249276

250-
**On Push to Master:**
251-
1. Run tests
252-
2. Check coverage (must be 100%)
253-
3. Run linting
254-
4. Build package
255-
5. Run mutation tests (optional)
277+
**Security Features:**
278+
- ✅ Cryptographic provenance (build transparency)
279+
- ✅ Granular npm token (package-specific permissions)
280+
- ✅ 90-day token expiration (enforced security)
281+
- ✅ No long-lived credentials in code
256282

257-
**On Tag Push:**
258-
1. All of the above
259-
2. Publish to npm (if tests pass)
260-
3. Create GitHub release
283+
### Token Management
261284

262-
### NPM Scripts for Release
285+
**NPM_TOKEN Secret:**
286+
- Type: Granular Access Token
287+
- Scope: `@migration-script-runner/core` (read/write)
288+
- Expiration: 90 days
289+
- Bypass 2FA: Enabled (for CI/CD automation)
290+
291+
**Renewal Process:**
292+
1. Create new token on npmjs.com 80 days before expiration
293+
2. Update GitHub secret: `gh secret set NPM_TOKEN`
294+
3. Delete old token on npmjs.com
295+
296+
### Manual Publishing (Emergency)
297+
298+
If automated workflow fails, you can publish manually:
263299

264300
```bash
265-
# Pre-release checks
266-
npm run prerelease
267-
268-
# This could run:
269-
# - npm test
270-
# - npm run test:coverage
271-
# - npm run lint
272-
# - npm run build
301+
# Ensure you're on the tagged commit
302+
git checkout v0.8.0
303+
304+
# Build and test
305+
npm ci
306+
npm run build
307+
npm test
308+
309+
# Publish with provenance
310+
npm publish --access public
311+
# Will prompt for 2FA code
273312
```
274313

275314
---
@@ -411,7 +450,9 @@ npm publish
411450
| Bump patch version | `npm version patch` |
412451
| Bump minor version | `npm version minor` |
413452
| Bump major version | `npm version major` |
414-
| Publish (dry run) | `npm publish --dry-run` |
415-
| Publish to npm | `npm publish --access public` |
416-
| Deprecate version | `npm deprecate <pkg>@<version> "<message>"` |
453+
| Push tag (triggers publish) | `git push origin v0.8.0` |
454+
| Create GitHub release | `gh release create v0.8.0 --generate-notes` |
455+
| Manual publish (emergency) | `npm publish --access public` |
456+
| Deprecate version | `npm deprecate @migration-script-runner/[email protected] "message"` |
417457
| View published versions | `npm view @migration-script-runner/core versions` |
458+
| Check workflow status | GitHub → Actions → "Publish to npm" |

0 commit comments

Comments
 (0)