GitHub Actions Workflow for Semantic Release on Push
Version, tag, and release automatically from your commit messages.
This workflow checks out full history and runs semantic-release, which derives the next version from conventional commits and publishes.
The workflow
.github/workflows/release.yml
name: Release
on:
push:
branches: [main]
permissions:
contents: write
issues: write
pull-requests: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}Notes
fetch-depth: 0gives semantic-release the full commit history it needs.- Needs
contents: writefor tags and releases plus a publish token. - Bumps are inferred from feat/fix/BREAKING CHANGE commits.
Run it cheaper
Point runs-on: at a Latchkey label to run this workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.
Related guides
GitHub Actions Workflow for Publish to npm on TagA GitHub Actions workflow that builds, tests, and publishes an npm package automatically whenever you push a…
How to Use Secrets in GitHub Actions SafelyUse GitHub Actions secrets correctly - repo vs environment vs org secrets, why forks can not read them, and h…