Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit 710318b

Browse files
roottoolclaude
andauthored
refactor: replace prepublishOnly with explicit publish workflow (#46)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 97ad436 commit 710318b

5 files changed

Lines changed: 96 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Initialize
3939
uses: ./.github/actions/setup-environment
4040

41+
- name: Validate and build package
42+
run: bun run prepare:publish
43+
4144
- name: Setup Node.js
4245
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
4346
with:

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ bun run test # All tests must pass
9292
bun run build # Build must succeed
9393
```
9494

95+
For local validation before pushing (mimics publish workflow):
96+
97+
```bash
98+
bun run prepare:publish # Runs all checks: type checking, tests, build, package validation
99+
```
100+
95101
### 3. Testing
96102

97103
- Write tests for all new functionality

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ export interface ParseIssue {
252252
v0.x focuses exclusively on establishing and clarifying the FormData boundary.
253253
No inference or convenience features will be added within v0.x.
254254

255+
## Contributing
256+
257+
Contributions are welcome! Please see:
258+
259+
- [CONTRIBUTING.md](CONTRIBUTING.md) - Contributor guide
260+
- [docs/PUBLISHING.md](docs/PUBLISHING.md) - Publishing guide (for maintainers)
261+
255262
## License
256263

257264
MIT

docs/PUBLISHING.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Publishing Process
2+
3+
> **For Maintainers**: This guide describes the NPM publishing workflow for safe-formdata.
4+
5+
safe-formdata uses an explicit, transparent publishing workflow that aligns with the library's design principles.
6+
7+
## Table of Contents
8+
9+
- [Local Validation](#local-validation)
10+
- [Workflow Overview](#workflow-overview)
11+
- [Why prepublishOnly was removed](#why-prepublishonly-was-removed)
12+
13+
---
14+
15+
## Local Validation
16+
17+
Before creating a release PR, validate locally:
18+
19+
```bash
20+
bun run prepare:publish
21+
```
22+
23+
This runs:
24+
25+
1. TypeScript type checking (`check:type:source`)
26+
2. Test suite with coverage (`test:coverage`)
27+
3. Build (`build`)
28+
4. Package validation (`check:package`: publint + attw)
29+
30+
---
31+
32+
## Workflow Overview
33+
34+
1. **Prepare Release PR**: Bump version → Create release branch → Open PR for review
35+
2. **Review & Merge**: Maintainer reviews and merges release PR to main
36+
3. **Publish**: Manual trigger of publish workflow → All checks run → NPM publish
37+
38+
The publish workflow is defined in `.github/workflows/publish.yml` and runs the following steps:
39+
40+
1. Setup environment (Bun + dependencies)
41+
2. **Validate and build package** (`bun run prepare:publish`)
42+
3. Setup Node.js for NPM
43+
4. Publish to NPM with provenance
44+
5. Create and push git tag
45+
6. Create GitHub Release (draft)
46+
47+
---
48+
49+
## Why prepublishOnly was removed
50+
51+
Previous versions used `npm run prepublishOnly` in package.json, which ran automatically during `npm publish`.
52+
This violated the boundary principle: **explicit over implicit**.
53+
54+
The publish workflow now declares all validation steps explicitly:
55+
56+
- TypeScript type checking
57+
- Test execution
58+
- Build process
59+
- Package validation
60+
- NPM publication
61+
62+
This ensures the publishing process is **transparent** and **traceable** in the workflow file.
63+
64+
### Design principles alignment
65+
66+
| Principle | Implementation |
67+
| ----------------------------- | ----------------------------------------------------------------------------------- |
68+
| **Explicit over implicit** | `prepare:publish` is called explicitly in the workflow, not triggered automatically |
69+
| **Security over convenience** | All validation steps are visible and traceable |
70+
| **Boundary-focused** | Clear separation between development and publishing processes |
71+
| **No silent fixes** | No hidden automation; every step is declared |
72+
73+
---
74+
75+
## Related Files
76+
77+
- [`.github/workflows/publish.yml`](../.github/workflows/publish.yml) - Publish workflow implementation
78+
- [`package.json`](../package.json) - Package configuration and scripts
79+
- [`CONTRIBUTING.md`](../CONTRIBUTING.md) - Contributor guide

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"test:coverage": "vitest run --coverage",
5858
"build": "tsup",
5959
"check:package": "publint && attw --pack . --ignore-rules cjs-resolves-to-esm",
60-
"prepublishOnly": "bun run check:type:source && bun run test:coverage && bun run build && bun run check:package"
60+
"prepare:publish": "npm-run-all2 check:type:source test:coverage build check:package"
6161
},
6262
"devDependencies": {
6363
"@arethetypeswrong/cli": "0.18.2",

0 commit comments

Comments
 (0)