Release the newest releasable commit
Describe how your repository releases in one file, then release with one command or one button, without picking a commit.
A release starts your release workflow (for example a deploy workflow with a production input)
with one commit: the newest commit of the release branch that has passed everything you require,
such as a green test workflow and a successful staging deploy. You do not look up a commit id, and
a commit that has not passed is never picked for you.
Replace repo-id with the repository's id.
Prerequisites
ci:ListRunson the repository to see which commit a release would take.ci:StartWorkflowon the repository to start the release. A release is a manual start of the release workflow, recorded in the audit log as one.- A release workflow that accepts a manual start (
on: workflow_dispatch) with an input that names the commit to release.
Describe how the repository releases
Commit .dcloud/release.yml to the default branch:
name: production # the button reads "Release to production"
workflow: deploy.yml # .github/workflows/deploy.yml
branch: main # the release branch; default: the default branch
ref_input: ref # the workflow input that receives the commit id
inputs: # the other inputs of a release
production: true
requires:
workflows: [tests.yml] # the newest completed run on the commit succeeded
statuses: [deploy/staging] # this commit status is successA commit is releasable when, for each workflow under requires.workflows, the newest completed run
of that workflow on the commit succeeded, and each commit status under requires.statuses is
success. A failed run that a re-run turned green counts as green; a green run followed by a red
re-run counts as red.
Commit statuses are set with GitHub's API from a job, for example after your staging deploy:
gh api "repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
-f state=success -f context=deploy/stagingThe job needs permissions: statuses: write (see
Call the GitHub API from a job).
Tag each release
Add tag_prefix to the file to have every release tag the commit it ships:
tag_prefix: prod # a release tags its commit prod-2026-12-03-1The tag is <tag_prefix>-<YYYY-MM-DD>-<n>: the date in UTC, and n counting that day's releases
from 1. The release makes the tag first, then starts the workflow, so:
- You need
git:PushRepositoryon the repository as well, andgit:PushProtectedTagwhen a tag protection rule covers the tag. Without it nothing is tagged and nothing starts. Protect the prefix (for exampleprod-*) to limit who can release. - The tag starts no workflow of its own, so a workflow with
on: push: tagsdoes not run a second release for it. - The tag records that a release of this commit was asked for. Whether the release succeeded is the workflow run's result: a run that fails or refuses leaves the tag in place.
Release
- Open the repository in Git, then Actions.
- Choose Release to production (the name comes from
namein the file). - Check the commit, its age, what it adds to the last release and which newer commits are not releasable yet, and why.
- Choose Release with the commit id.
The run list marks the newest run of the commit a release would take Next release, and the run that made the last release Released to production.
Inside a clone of the repository:
dcloud ci release --dry-run # which commit, and nothing else
dcloud ci release # shows it and asks before it startsOutside a clone, name it with -R org/repo. --ref <commit> releases that
commit instead; --yes does not ask.
GET /ci/api/repositories/repo-id/releasePOST /ci/api/repositories/repo-id/release
{ "dryRun": true }POST without dryRun starts the release. Pass the ref you were shown, so the release takes
that commit even when a newer one became releasable in the meantime.
Result
201 with { sha, subject, releasable, unmet, name, workflowPath, lastRelease, tag, dispatched: true, runId }: the release workflow is queued on the release branch with the commit in
ref_input. tag is the tag the release made, or null without tag_prefix. With dryRun,
200 and dispatched: false; tag is then the tag a release made now would get, and no tag is
made.
409with one line when no commit qualifies, naming the commit closest to releasable and what it still lacks, for example "No releasable commit since the last release (1a2b3c4d5e6f); the nearest, 9f8e7d6c5b4a, has deploy/staging: pending."409when the repository has no.dcloud/release.yml, or it is invalid (the error names the field).409withoutrefwhen the last release already shipped the newest releasable commit.409when the tag could not be made (the error says why); nothing was started.- With
ref, the commit is started even when it is not releasable;unmetlists what it lacks, and your workflow decides.
The commit a release takes is never older than the last release: "what it adds" is the commits
between the two. The last release is the newest successful manual run of the release workflow
started with the same inputs. When that run named no commit in ref_input (it was started by hand
without one), the last release is unknown, and the release looks back up to 200 commits.