|
| 1 | +# Publishing promptopskit |
| 2 | + |
| 3 | +## The Only Three Commands You Need |
| 4 | + |
| 5 | +```powershell |
| 6 | +npm version patch # or minor or major |
| 7 | +git push --follow-tags |
| 8 | +# done. go get a coffee. |
| 9 | +``` |
| 10 | + |
| 11 | +That's it. The GitHub Action does the rest — lint, test, build, publish to npm with provenance. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Wait, Which Version Bump Do I Use? |
| 16 | + |
| 17 | +| Command | When to use it | Example | |
| 18 | +|----------------------|-----------------------------------------------------|------------------| |
| 19 | +| `npm version patch` | Bug fixes, typos, small tweaks | 0.0.1 → 0.0.2 | |
| 20 | +| `npm version minor` | New features that don't break existing usage | 0.0.2 → 0.1.0 | |
| 21 | +| `npm version major` | Breaking changes (renamed exports, removed options) | 0.1.0 → 1.0.0 | |
| 22 | + |
| 23 | +## What Happens Behind the Scenes |
| 24 | + |
| 25 | +1. `npm version patch` bumps the version in `package.json` and creates a git commit + tag (`v0.0.2`) |
| 26 | +2. `git push --follow-tags` pushes the commit and tag to GitHub |
| 27 | +3. The `v*` tag triggers the **Publish** workflow (`.github/workflows/publish.yml`) |
| 28 | +4. The workflow runs lint → test → build → publint → attw → `npm publish --provenance` |
| 29 | +5. The package appears on npm |
| 30 | + |
| 31 | +## Pre-flight Checklist |
| 32 | + |
| 33 | +Before running the commands: |
| 34 | + |
| 35 | +- [ ] You're on the `main` branch |
| 36 | +- [ ] All your changes are committed (`git status` shows clean) |
| 37 | +- [ ] Tests pass locally (`npm test`) |
| 38 | + |
| 39 | +## Troubleshooting |
| 40 | + |
| 41 | +### "Git working directory not clean" |
| 42 | + |
| 43 | +You have uncommitted changes. Commit them first: |
| 44 | + |
| 45 | +```powershell |
| 46 | +git add -A |
| 47 | +git commit -m "describe what you changed" |
| 48 | +``` |
| 49 | + |
| 50 | +Then try `npm version patch` again. |
| 51 | + |
| 52 | +### Publish workflow didn't trigger |
| 53 | + |
| 54 | +Go to `github.com/PredictabilityAtScale/promptopskit/actions` and check if you see the **Publish** workflow. If not, delete and re-push the tag: |
| 55 | + |
| 56 | +```powershell |
| 57 | +git tag -d v0.0.X |
| 58 | +git push origin :refs/tags/v0.0.X |
| 59 | +git tag v0.0.X |
| 60 | +git push origin v0.0.X |
| 61 | +``` |
| 62 | + |
| 63 | +(Replace `v0.0.X` with your actual version.) |
| 64 | + |
| 65 | +### Publish workflow failed |
| 66 | + |
| 67 | +1. Check the Actions log for the error |
| 68 | +2. If it says `NPM_TOKEN` is missing, add it: **Repo Settings → Secrets and variables → Actions → New repository secret** → Name: `NPM_TOKEN`, Value: your npm token |
| 69 | +3. Re-run the failed workflow from the Actions page |
| 70 | + |
| 71 | +### I need a new npm token |
| 72 | + |
| 73 | +1. Go to [npmjs.com](https://www.npmjs.com) → avatar → **Access Tokens** |
| 74 | +2. **Generate New Token** → **Granular Access Token** |
| 75 | +3. Name: `promptopskit-publish`, Packages: **Read and write**, Scope: `promptopskit` only |
| 76 | +4. Copy the token and add it as the `NPM_TOKEN` secret in GitHub (see above) |
| 77 | + |
| 78 | +## Do NOT |
| 79 | + |
| 80 | +- Run `npm publish` manually from your laptop |
| 81 | +- Skip tests before publishing (the `prepublishOnly` script blocks you anyway) |
| 82 | +- Push to npm and then realise you forgot to commit something |
0 commit comments