|
| 1 | +# NPM Publishing Setup |
| 2 | + |
| 3 | +This repository is configured to use NPM's [Trusted Publishers](https://docs.npmjs.com/trusted-publishers) feature with OIDC authentication via GitHub Actions. |
| 4 | + |
| 5 | +## How It Works |
| 6 | + |
| 7 | +When a new release is created on GitHub, the workflow automatically publishes the package to NPM using short-lived OIDC tokens instead of long-lived NPM tokens. This provides better security and includes cryptographic provenance attestations. |
| 8 | + |
| 9 | +## Setup Instructions |
| 10 | + |
| 11 | +To complete the trusted publisher configuration, a package maintainer needs to: |
| 12 | + |
| 13 | +1. Go to [npmjs.com](https://www.npmjs.com) and log in |
| 14 | +2. Navigate to the package: [@kulkul/tinyurl-client](https://www.npmjs.com/package/@kulkul/tinyurl-client) |
| 15 | +3. Go to **Settings** → **Publishing** (or access directly at: `https://www.npmjs.com/package/@kulkul/tinyurl-client/access`) |
| 16 | +4. Click **"Add trusted publisher"** |
| 17 | +5. Configure with these details: |
| 18 | + - **Provider**: GitHub Actions |
| 19 | + - **Organization**: `kulkultech` |
| 20 | + - **Repository**: `tinyurl-client` |
| 21 | + - **Workflow**: `test-and-publish.yml` |
| 22 | + - **Environment**: Leave blank (not using deployment environments) |
| 23 | + |
| 24 | +## Publishing a New Version |
| 25 | + |
| 26 | +1. Update the version in `package.json` |
| 27 | +2. Commit the change |
| 28 | +3. Create a new release on GitHub with a tag (e.g., `v1.0.9`) |
| 29 | +4. The GitHub Actions workflow will automatically: |
| 30 | + - Run tests |
| 31 | + - Build the package |
| 32 | + - Publish to NPM with provenance attestations |
| 33 | + |
| 34 | +## Benefits |
| 35 | + |
| 36 | +- 🔒 **Enhanced Security**: No long-lived NPM tokens stored as secrets |
| 37 | +- ✅ **Provenance**: Cryptographic proof of where and how the package was built |
| 38 | +- 🤖 **Automated**: Fully automated publishing on release creation |
| 39 | +- 🔍 **Transparent**: Build logs and provenance are publicly verifiable |
| 40 | + |
| 41 | +## Troubleshooting |
| 42 | + |
| 43 | +If publishing fails: |
| 44 | +1. Ensure the trusted publisher is configured on npmjs.com |
| 45 | +2. Verify the repository, workflow name, and organization match exactly |
| 46 | +3. Check that the release was created (not just a tag) |
| 47 | +4. Review the GitHub Actions logs for detailed error messages |
0 commit comments