Skip to content
jshacks.dev
Tooling

Add a release workflow with tags

Publish an npm package from a GitHub Actions workflow that runs when you push a version tag, with provenance and a scoped token permission.

1 min read
Summarize in AI

A tag push is a clear signal for "release this". The workflow builds, tests and publishes from a clean runner.

.github/workflows/release.ymlYAML
name: Release
on:
  push:
    tags: ['v*.*.*']

permissions:
  contents: read
  id-token: write

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org
      - run: npm ci
      - run: npm test
      - run: npm publish --provenance --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Shell
npm version minor
git push --follow-tags

npm version bumps package.json, commits and creates the v1.3.0 tag. Pushing the tag starts the workflow. id-token: write lets npm sign a provenance statement that links the package to this run. setup-node with registry-url writes an .npmrc that reads NODE_AUTH_TOKEN. See npm's provenance docs.

Check that the tag matches the version in package.json before publishing, or a wrong tag will publish the wrong number. Store the token as a repository secret, never in the file.

Share

More snippets

Tooling

Create a Vite project from a template

Create a Vite project from a template with npm create vite, choose the vanilla-ts or react-ts template and see which files it generates.

1 min read
Tooling

Configure VS Code settings for a team

Share VS Code settings and recommended extensions with a team by committing a .vscode folder with settings.json and extensions.json.

1 min read
Tooling

Share an ESLint config across packages

Share one ESLint 9 flat config across workspace packages by exporting an array from a package and spreading it into each package's eslint.config.js.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.