Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install deps
run: pnpm install --frozen-lockfile

- name: Lint (biome)
run: pnpm run lint

- name: Typecheck
run: pnpm run typecheck

- name: Test
run: pnpm run test

- name: Build
run: pnpm run build
83 changes: 83 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Publish

on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
registry-url: https://registry.npmjs.org

- name: Install deps
run: pnpm install --frozen-lockfile

- name: Lint (biome)
run: pnpm run lint

- name: Typecheck
run: pnpm run typecheck

- name: Test
run: pnpm run test

- name: Build
run: pnpm run build

- name: Verify tag/version lock
run: |
NPM_VERSION=$(node -p "require('./package.json').version")
if [[ "${GITHUB_REF:-}" == refs/tags/v* ]]; then
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
if [ "$TAG_VERSION" != "$NPM_VERSION" ]; then
echo "::error::Tag/version mismatch: tag=$TAG_VERSION package=$NPM_VERSION."
exit 1
fi
fi
echo "Version locked: $NPM_VERSION"

publish-npm:
needs: verify
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
registry-url: https://registry.npmjs.org

- run: pnpm install --frozen-lockfile
- run: pnpm run build

# Idempotent: re-running a tag whose npm version is already published
# must not fail the workflow.
- name: Publish to npm (skip if already published)
run: |
NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
if npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
echo "$NAME@$VERSION already on registry; skipping publish"
else
pnpm publish --no-git-checks --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading
Loading