|
| 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 |
0 commit comments