Reusable GitHub Actions workflows that release each commit a project's CI passes on trunk, from the files that run built and tested, and revert the commit that turns its trunk red.
Cutter is for maintainers who practice trunk-based development on GitHub: everyone commits straight to one branch, trunk, and any commit CI has passed can become a release. You add two jobs to your CI workflow and one short workflow file to your repository, each calling a workflow in Cutter, pinned at a commit you choose. With them:
- Every passing CI run on trunk releases its commit. When your changelog lists something new, an early job asks Cutter for the version, your build writes it into your project, and your tests run. The
releasejob, which needs every other job, calls Cutter, which tags the commit, publishes the files that run built, writes the release notes from your changelog, and then dates your changelog on trunk. Nobody pushes a tag, nobody makes a release commit, and nobody waits for a quiet trunk. - Only a person releases 1.0.0. Cutter never picks 1.0.0. You push the tag
v1.0.0, and with a tag ruleset on your repository, GitHub lets only its admins push it, so the step to a stable version is a person's. Every release before it and after it comes from a passing run. - A red trunk gets put right. When a CI run on trunk fails, Cutter runs the failed jobs once more. If they fail again, it finds the commit that broke trunk, reverts it, and starts CI on the revert.
- Libraries get patch releases after 1.0. From 1.0.0 on, each fix that releases from trunk reaches the older minor versions too. When 1.1.0 releases, Cutter cuts a
release/1.0branch from the newest 1.0 tag; it cherry-picks each fix trunk releases onto that branch, and the branch's passing run releasesv1.0.1the same way. The build cop reverts a fix whose CI fails there, so a fix that doesn't work on 1.0 stays off it. stableis your newest stable release. From 1.0.0 on, Cutter moves astablebranch to each newest stable release, and you make it your repository's default branch. Once it is, a run on trunk releases its commit only with a GitHub App, as Release 1.0.0 says.- Work Cutter can't finish reaches a person. When a run leaves work that no later run does by itself, such as a red trunk Cutter can't revert or a release it can't record, Cutter files an issue in your repository that says what happened and what to do, updates it while the problem lasts, and closes it once a later run finds the problem gone. A red run reaches nobody who doesn't open it.
Neither workflow needs a stored credential: every job uses the token GitHub gives each run, with only the permissions you grant it.
The build cop can take a GitHub App to also revert changes to your workflow files. The release workflow can take the same App to tag, and move stable to, a commit whose workflow files differ from your default branch's, and to carry fixes onto a release branch whose workflow files differ from it: Tokens and permissions.
If you know these tools, here is how Cutter differs:
- release-please keeps a release pull request that bumps the version and the changelog as work lands, and merging it tags the release. Cutter makes no release commit: it releases a commit that is already on trunk, from the run that tested it.
- semantic-release works out the version from commit messages, and publishes from CI whenever a push to a release branch carries a change that calls for a release. Cutter works out the version from your changelog, and releases the commit that the passing run built and tested, from that run.
- With Changesets, you commit a changeset file with each change, and its GitHub Action opens a pull request that versions your packages from them. Cutter reads the entries you already keep under
## [Unreleased]inCHANGELOG.md. - GitHub's merge queue tests each queued pull request against the latest target branch before it merges it. Cutter is for commits pushed straight to trunk, and it repairs trunk after a push instead.
In a project's .github/workflows/ci.yml, CI runs for pushes to trunk and for version tags. Its version job asks Cutter which version the run would release, its package job builds with it, and its release job calls Cutter's release workflow once every job it needs has passed.
name: CI
on:
push:
branches: [trunk, "release/**"]
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
# A push waits behind the run in progress for its branch or tag, and a newer
# push may replace a push that is still waiting, so one run tests every
# commit pushed meanwhile. A run is never canceled while it runs. A rerun of
# a run's failed jobs and a run started by workflow_dispatch each get a group
# of their own, so that no push replaces them while they wait.
concurrency:
group: ci-${{ github.ref }}${{ (github.event_name == 'workflow_dispatch' || github.run_attempt != '1') && format('-{0}-{1}', github.run_id, github.run_attempt) || '' }}
cancel-in-progress: false
jobs:
version:
uses: setdef/Cutter/.github/workflows/version.yml@722bc85807fa248115a93fe5329187a0811bab37 # v0.9.3
permissions:
contents: read
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
with:
bundler-cache: true
- run: bundle exec rake test
package:
needs: version
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
# Build the gem with the version this run would release, if any.
- if: needs.version.outputs.version != ''
env:
VERSION: ${{ needs.version.outputs.version }}
run: sed -i "s/VERSION = \".*\"/VERSION = \"$VERSION\"/" lib/invoice/version.rb
- run: gem build invoice.gemspec
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release
path: "*.gem"
release:
needs: [version, test, package]
if: ${{ !cancelled() }}
uses: setdef/Cutter/.github/workflows/release.yml@722bc85807fa248115a93fe5329187a0811bab37 # v0.9.3
permissions:
contents: write
actions: write
issues: write
with:
artifact: releaseThis project is a Ruby gem, invoice; the test and package jobs are yours to write for your project, and Getting started walks through them. The version and release jobs pin Cutter by the full commit SHA of its newest release's tag, both at the same commit, with the tag in a comment; a tag can be moved, and a SHA can't: Pinning Cutter.
When a run on trunk passes, and the changelog lists something new, its release job tags the commit v0.4.0, publishes the GitHub release v0.4.0 with the files that run built, pushes one commit to trunk that dates the release in CHANGELOG.md, and writes in its summary:
4f2a9c1 would release as v0.4.0: CHANGELOG.md lists 3 new entries under Unreleased, one of them under Added, one under Changed, and one under Fixed.
Published the release v0.4.0 of 4f2a9c1e0b7d3a5c8f6e2d1b9a0c7e5f3d2b1a09.
A tag you push, such as v1.0.0, starts a CI run for the tag, which releases it the same way. The release job has if: ${{ !cancelled() }}, so that it starts even when test or package failed, and Cutter stops that release, and for a tag files an issue, in place of GitHub skipping the job: Calling it.
| What | Needs |
|---|---|
| Where it runs | GitHub Actions on github.com. The jobs in Cutter's workflows run on GitHub-hosted Linux runners (ubuntu-24.04). The jobs of your CI workflow that build your release files may run on any runner, GitHub-hosted or self-hosted, on any operating system, since Cutter reads only the artifact they upload and whether each job passed. The build cop needs git 2.40 or later on the runner, as the ubuntu-24.04 runners have: Git on the runner |
| Your branches | trunk, and from 1.0.0 on, release/X.Y branches |
| Your versions | Semantic Versioning: 0.X.Y before 1.0.0, then X.Y.Z; tags are v plus the version, or, in a repository of several packages, a package's tag prefix, v, and the version, such as invoice/v0.4.0 |
| Your changelog | CHANGELOG.md, or one for each package, in Keep a Changelog form, with an ## [Unreleased] section |
| Your CI | A workflow that runs on every push to trunk, to release/**, and of a v* tag or each package's tag, can be started with workflow_dispatch, never cancels a run in progress (a newer push may replace a run still waiting), and builds your project with the version its version job names. |
| The command line | Optional. cutter runs on Linux on x86-64 or ARM64, macOS on Apple silicon, and Windows on x64, from the archive a release of Cutter publishes for each, with no Ruby to install: Get the command line |
| Your repository | A branch rule or ruleset on trunk or a release/X.Y branch that stops a direct push lets github-actions[bot] push, and a tag ruleset that restricts the tags of your releases lets it create them: Let Cutter push to trunk. From 1.0.0 on, stable is the repository's default branch, and the release workflow has a GitHub App. Issues are turned on. Before your 1.0.0 release, a tag ruleset that lets only admins create the tag v1.0.0. |
Cutter doesn't build your project or run your tests: your CI workflow does both. Cutter reads its results.
Cutter's versions follow Semantic Versioning, and Cutter releases itself with its release workflow. Before 1.0.0, any release may change anything. From 1.0.0 on, each workflow's inputs, outputs, and required permissions, as the reference gives them, work in every minor and patch release as they did before it.
Cutter's workflows need nothing installed. Add two jobs to your CI workflow and a workflow file for the build cop, each calling Cutter's workflows pinned at a commit, as Getting started shows step by step.
Cutter's command line, cutter, is optional. Download the archive for your computer from the release you pin, check it against the release's SHA256SUMS, unpack it, and run cutter from the folder it makes: Get the command line.
- Keep a changelog. Each change your users would notice gets an entry under
## [Unreleased], under### Added,### Changed,### Deprecated,### Removed,### Fixed, or### Security. Start an entry with**Breaking:**when it breaks what a user relies on. Cutter works out each version from these entries: How Cutter picks a version. - Build with the version Cutter names. A
versionjob early in your CI asks Cutter for the version the run would release, and your build writes it into your project before it builds, and uploads the files a release publishes as an artifact: Publish what your CI builds. - Add the release job to your CI workflow, as in A first example. Its inputs and permissions are in the release workflow's reference.
- Check your files before you push, with Cutter's command line, which is optional.
cutter lintchecks your changelog and.config/cutter.ymlby the rules Cutter's workflows apply to them, on your computer or in your CI, andcutter initmoves your workflows' inputs into.config/cutter.yml: The command line. - Release. Land your changes with their entries on trunk. Each run that passes releases what its changelog lists as new: Release a version.
- Add the build cop, which watches your CI on trunk and reverts the commit that turns it red: Put a red trunk right.
- Before 1.0.0, protect the tag
v1.0.0, so only a person can release 1.0.0: Release 1.0.0. - From 1.0.0 on, older versions get your fixes on
release/X.Ybranches, which Cutter cuts and carries each fix onto: Release a fix for an older version.
- The documentation's map: every page, by what it's for, and where to start.
- Getting started: a project's first release with Cutter, from an empty workflow folder to a published release.
- How-to guides, each for one task: release a version, publish what your CI builds, put a red trunk right, release 1.0.0, release a fix for an older version, keep the version files of a project installed from its tag in step, release one package of several, get the command line, and set up a project with
cutter init. - Reference: every workflow's inputs, outputs, permissions, and the reasons a run stops, and the command line's commands, options, and exit statuses.
- Explanations: how Cutter picks a version, why a release is a tag on a proven commit, why the build cop reverts, and tokens and permissions.
- CHANGELOG.md: what changed in each of Cutter's releases.
Ask questions and report problems on the Cutter forum. Include the workflow that went wrong, the tag or commit you ran it on, and its run's log. GitHub Issues are open to the project's collaborators only.
To send a patch, post it on the forum, or email it with git send-email to replies+cutter@forum.setdef.com. git-send-email.io shows how to set that up.
Report a vulnerability privately, never on the forum: SECURITY.md.
CONTRIBUTING.md says how a change lands, how files are licensed, and which changes to ask the maintainer about first.
Cutter's code is released under the MIT License, and its documentation under CC BY 4.0. Cutter places no conditions on the projects that call its workflows. An example between SPDX snippet comments, in this README or the pages under docs/, is under MIT-0, so you may copy it into your workflows without a notice.
I use four words for how code and prose comes to exist. Code or prose I wrote, I typed by hand, with nothing generated. Code or prose I wrought, an AI agent generated while I iterated with it, and I reviewed every change before committing it, so I own every diff. Code or prose I requested, an agent built with little or no review from me, but I take ownership of the outcome or product because I tested and iterated. Code or prose I rushed, an agent built with little or no feedback from me, and may or may not be useful (or safe).
Cutter's documentation, this README included, is rushed: an agent wrote it from my goals and decisions, as the specification that Cutter's code is to be built to. declare-ai.org