ci: add a check pipeline and a tag-driven npm release

ci runs typecheck + unit tests + build + scripts/smoke.sh and asserts the
publishable tarball embeds dist/ and web/dist/ without leaking src/ or test/.

release verifies the tag matches package.json, runs the tests and publishes
with provenance.
This commit is contained in:
yuez committed 2026-10-22 17:19:38 +08:00
1 parent 7c98510fea
commit e32e86a377
2 files changed
+142

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
name: release
on:
push:
tags: ["v*"]
permissions:
contents: read
id-token: write # npm provenance
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
cache: pnpm
cache-dependency-path: |
pnpm-lock.yaml
web/pnpm-lock.yaml
- name: Tag must match package.json version
run: |
tag="${GITHUB_REF_NAME#v}"
pkg="$(node -p 'require("./package.json").version')"
if [ "$tag" != "$pkg" ]; then
echo "tag $GITHUB_REF_NAME does not match package.json $pkg" >&2
exit 1
fi
- name: Install deps
run: |
pnpm install --frozen-lockfile
pnpm --dir web install --frozen-lockfile
- name: Test
run: |
pnpm typecheck
pnpm test
pnpm --dir web exec vitest run
# `prepack` builds dist/ and web/dist/ as part of pack+publish, so the
# published tarball is always built from the tagged source.
- name: Publish to npm
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
body: |
`npm i -g pi2d@${{ github.ref_name }}`
Compatible pi2.nvim: protocol v1 (see `docs/protocol.md`).