This repo publishes two artifacts for each release:
- npm package:
@agegr/pi-web - GitHub Release:
agegr/pi-web
Use this checklist from a clean main checkout.
git fetch origin
git status --short --branch
git log --oneline --decorate -5
git rev-list --left-right --count main...origin/main
gh auth status
npm whoami
node -e "const p=require('./package.json'); console.log(p.version)"
lsof -nP -iTCP:30141 -sTCP:LISTEN
ls .next/server/route-cacheExpected:
git statusis clean, or only contains changes you intentionally plan to release.mainandorigin/mainare aligned (0 0).- GitHub is authenticated as an account that can push and create releases.
- npm is authenticated as an account that can publish
@agegr/pi-web. - No dev server is listening on 30141: the production build rewrites
.next/and breaks a runningnpm run dev. Stop it first. .next/server/route-cache/does not exist. An e2e run instartmode writes it (next startdoes, the build does not), and it would be published. Delete it if present.
Before bumping, confirm the next version is free (replace <version>):
npm view @agegr/pi-web@<version> version --registry https://registry.npmjs.org/ # expect E404
git ls-remote --tags origin v<version> # expect emptyPatch release:
npm run releaseThe release script runs:
npm version patch --no-git-tag-version && npm run build && npm publish --access publicnpm run release only bumps the patch number. For a minor (or major) release, set the version yourself and run the other two steps separately:
npm version <x.y.0> --no-git-tag-version
npm run build
npm publish --access publicChoosing the bump: look at git log --oneline v<previous>..HEAD. A batch of feat: commits (new UI, new commands, new settings) is a minor; only fixes and small adjustments is a patch. Decide before running the script, since a published version cannot be reused.
Notes:
- This bumps
package.jsonandpackage-lock.json. - It intentionally runs a production build. Do not run
next buildduring normal development; release work is the exception. - A newly published version may take a few minutes to show up.
npm view @agegr/pi-web@<version> versioncan return E404 andnpm view @agegr/pi-web versioncan show the previous version even though the publish printed+ @agegr/pi-web@<version>. This is registry propagation, not a failed publish: do not publish again. Poll the registry until the version appears:
curl -s https://registry.npmjs.org/@agegr%2Fpi-web/<version> | head -c 80 # JSON once it exists, "version not found" before
npm view @agegr/pi-web dist-tags --registry https://registry.npmjs.org/
npm view @agegr/pi-web versions --json --registry https://registry.npmjs.org/Replace <version> with the new package version, for example 0.7.5.
git diff -- package.json package-lock.json
git add package.json package-lock.json
git commit -m "Release v<version>"git tag -a v<version> -m "v<version>"
git push origin main v<version>Push the release tag by name. Do not use git push --tags: the local checkout holds tags fetched from contributor forks that are not on origin, and --tags publishes them (it leaked a stray v0.10.5, on a commit that is on no branch, during the v0.11.0 release). If you ever need --tags, compare git tag with git ls-remote --tags origin first.
Confirm the tag does not already exist before creating it when unsure:
git ls-remote --tags origin v<version>
gh release view v<version> --repo agegr/pi-webUse the previous release tag as the base.
git log --oneline --decorate v<previous>..v<version>
git log --format='%h%x09%s%n%b' v<previous>..v<version>
git diff --stat v<previous>..v<version>Write the release notes from those commits, not from memory. Include both Chinese and English sections. Keep commit hashes or PR numbers next to each item when useful.
- Check commands, flags and setting names against
README.mdand the code before writing them down. - Thank outside contributors by name:
git log --format='%h %an | %s' v<previous>..v<version>lists authors, and the previous release's notes show the style. - Open with the install/upgrade command (
npm install -g @agegr/pi-web@latest), as earlier releases did. - Write the notes to a file outside the repo (for example
NOTES=$(mktemp)), or pass them through stdin as shown below. Arelease-notes.mdin the repo root is an untracked file in the next release'sgit status.
Suggested structure:
## 中文
基于 `v<previous>..v<version>` 的提交整理。
### 新增
- ...
### 修复
- ...
### 改进
- ...
### 内部调整
- 发布 npm 包 `@agegr/pi-web@<version>`。
## English
Prepared from commits in `v<previous>..v<version>`.
### Added
- ...
### Fixed
- ...
### Improved
- ...
### Internal
- Published npm package `@agegr/pi-web@<version>`.Create a new release:
gh release create v<version> \
--repo agegr/pi-web \
--verify-tag \
--title "v<version>" \
--notes-file "$NOTES"If the release already exists and only the notes need updating:
gh release edit v<version> \
--repo agegr/pi-web \
--notes-file "$NOTES"You can avoid a temporary file by passing notes through stdin:
gh release edit v<version> --repo agegr/pi-web --notes-file - <<'EOF'
## 中文
...
## English
...
EOFgh release view v<version> --repo agegr/pi-web
npm view @agegr/pi-web@<version> version --registry https://registry.npmjs.org/
npm view @agegr/pi-web dist-tags --registry https://registry.npmjs.org/
git status --short --branch
git log --oneline --decorate -3
git ls-remote --tags originExpected:
- GitHub Release exists and is not a draft unless intentionally published as one.
- npm exact version resolves and
latestpoints at it (allow a few minutes, see step 2). git ls-remote --tags originshows no tag you did not mean to publish.mainis aligned withorigin/main.HEADpoints at the release commit andv<version>tag.