Skip to content
Latchkey

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: 0 gives semantic-release the full commit history it needs.
  • Needs contents: write for 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

Run this faster and cheaper on Latchkey managed runners. Start free →