Minimal, reliable setup to auto-version, create GitHub Releases, and publish to npm from main using Changesets. No GitHub App required (uses GITHUB_TOKEN).
- Opens a "Version Packages" PR when changesets land on
main. - On merging that PR, publishes to npm and creates GitHub Releases.
- Optionally deploys to Vercel after publish (see
VERCEL_DEPLOYMENTS.md).
pnpm add -D @changesets/cli
pnpm changeset initRoot package.json scripts (recommended):
{
"scripts": {
"changeset": "changeset",
"version": "changeset version && pnpm install -r --no-frozen-lockfile",
"publish-packages": "changeset publish"
}
}.changeset/config.json (sane defaults):
{
"$schema": "https://unpkg.com/@changesets/config/schema.json",
"changelog": "@changesets/changelog-git",
"commit": true,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}For public scoped packages (e.g. @scope/pkg), add to each published package:
{
"publishConfig": { "access": "public" }
}Create .github/workflows/release.yml (adjust the build step for your workspace):
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
id-token: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Git User
run: |
git config --global user.email "ai-registry-bot[bot]@users.noreply.github.com"
git config --global user.name "ai-registry-bot[bot]"
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- name: Install Dependencies
run: pnpm i
# Build all packages. If you prefer a single package:
# run: pnpm build --filter <your-package-name>
- name: Build Packages
run: pnpm -r build
- name: Run Tests
run: pnpm test
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: pnpm changeset version
publish: pnpm changeset publish
createGithubReleases: true
setupGitUser: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Optional: deploy to Vercel after publish
# See VERCEL_DEPLOYMENTS.md for a monorepo-friendly variant
- name: Deploy to Vercel
if: steps.changesets.outputs.published == 'true'
run: npx vercel --prod --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}Notes:
- If you filter the build step, make sure the name matches your package (e.g.
@airegistry/vercel-gateway). - Use Node 20 if required by dependencies (change
node-version: 22).
Repo → Settings → Actions → General
- Workflow permissions: "Read and write permissions"
- Check: "Allow GitHub Actions to create and approve pull requests"
Repo → Settings → Secrets and variables → Actions
NPM_TOKEN: npm Automation token (required)- Optional Vercel:
VERCEL_TOKEN,VERCEL_ORG_ID,VERCEL_PROJECT_ID
Create npm Automation token (bypasses 2FA for CI):
gh secret set NPM_TOKEN --repo <owner>/<repo> --body 'npm_XXXXXXXXXXXXXXXXXXXXXXXX'# on a feature branch
pnpm changeset # select packages + bump types
git add . && git commit -m "chore: changeset" && git push
# merge PR into main → CI opens "Version Packages" PR
# merge that PR → CI publishes to npm & creates GitHub Releases-
Error: GitHub Actions not permitted to create or approve PRs
- Enable the two settings in step 3 (permissions + allow create/approve PRs).
-
E404 on publish to a scoped package
- You must own the npm scope. Either:
- Create/claim the org for the scope and ensure your user (token owner) is a maintainer, or
- Change the package scope to one you own (e.g.
@airegistry/...) or publish unscoped.
- Ensure
publishConfig.access=publicon public scoped packages.
- You must own the npm scope. Either:
-
Verify npm auth in CI
- name: Debug npm auth
run: |
npm config get registry
npm whoami-
Build failures
- Ensure each published package has a
buildscript and is included inpnpm-workspace.yaml. - If filtering a single package, use
pnpm build --filter <pkg>.
- Ensure each published package has a
-
Need CI commits to trigger other workflows
- Use a PAT secret instead of
GITHUB_TOKENand pass it to checkout and the Changesets step.
- Use a PAT secret instead of
Use the built-in step above or see VERCEL_DEPLOYMENTS.md for a monorepo-targeted version with working-directory: apps/website and how to retrieve ORG_ID/PROJECT_ID.