Release Pipelines
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
A release pipeline turns a version decision into published artifacts that users can install and verify. The version decision lives in Git (a tag, see Tags and Releases); the pipeline builds that exact commit, tests it, publishes to one or more registries, and records the result as a GitHub release. This page gives the shared shape, the trigger options and one complete workflow per ecosystem. Action versions are those verified on 2026-11-10; the official documentation wins on any discrepancy. For secrets and OIDC fundamentals see Secrets, Variables and OIDC, and for the protection gates around publishing see Environments and Deployment Protection.
The shape of a release
Keep the stages as separate jobs linked by needs, so a failed test never reaches the publish job, and give the publish
job its own permissions and, ideally, a protected environment.
Triggers
| Trigger | When it runs | Use when |
|---|---|---|
|
Whenever a tag matching the pattern is pushed. |
The tag is the release. Simple and the most common. |
|
When a release is published in the UI or by |
A person drafts notes first and publishing triggers the build. Drafts do not trigger it. |
|
Manually from the UI, |
Dry runs, republishing, or when the version is chosen at release time. |
on:
push:
tags: ['v*.*.*']
workflow_dispatch:
inputs:
version:
description: 'Version to release (for example 1.4.0)'
required: true
type: string
dry-run:
description: 'Build and test without publishing'
type: boolean
default: true
Inputs of type: boolean are real booleans in the inputs context but strings in github.event.inputs; prefer the
inputs context. A tag pushed with GITHUB_TOKEN (for example by another workflow) does not trigger further workflows, so push
release tags with a person’s credentials or a GitHub App token.
Versioning from the tag
- name: Derive version from the tag
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}" # v1.4.0 -> 1.4.0
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- run: mvn -B versions:set -DnewVersion="${{ steps.version.outputs.version }}" -DgenerateBackupPoms=false
For workflow_dispatch, use ${{ inputs.version }} and check out the corresponding tag with ref: v followed by the
input. Validate the format before passing it to a build tool:
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.]+)?$ ]] || { echo "bad version: $VERSION"; exit 1; }
Creating GitHub releases
gh release create v1.4.0 --generate-notes --verify-tag
gh release create v1.5.0-rc.1 dist/*.tar.gz --prerelease --generate-notes
gh release upload v1.4.0 dist/app-1.4.0.zip --clobber
gh release list
--generate-notes builds the notes from merged pull requests since the previous tag. Configure the grouping with
.github/release.yml:
# .github/release.yml
changelog:
exclude:
labels: [skip-changelog]
authors: [dependabot]
categories:
- title: Features
labels: [enhancement]
- title: Bug fixes
labels: [bug]
- title: Everything else
labels: ['*']
Inside a workflow, gh needs the token and contents: write:
release:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- run: gh release create "$GITHUB_REF_NAME" --generate-notes --verify-tag dist/*
env:
GH_TOKEN: ${{ github.token }}
softprops/action-gh-release@v3 does the same declaratively (files:, generate_release_notes: true,
prerelease:). When immutable releases are enabled for the repository, a published release’s tag and assets can no
longer be changed or deleted, so create the release as a draft, attach every asset, then publish it as the last step.
Publishing recipes
Maven Central (Central Portal)
name: release-maven
on:
push:
tags: ['v*.*.*']
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
environment: maven-central
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: 21
cache: maven
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- run: mvn -B deploy -Prelease
env:
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
The pom.xml declares org.sonatype.central:central-publishing-maven-plugin (0.12.0) with
<publishingServerId>central</publishingServerId> and <extensions>true</extensions>, plus the source, Javadoc and GPG
signing plugins in the release profile. server-username and server-password name environment variables, not
values; setup-java writes settings.xml referring to them, and the env: block supplies the values. Gradle builds and
Android libraries are covered in Gradle publishing and
Android libraries and Maven Central.
npm
name: release-npm
on:
push:
tags: ['v*.*.*']
jobs:
publish:
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write # OIDC: trusted publishing and provenance
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm test
- run: npm publish --provenance --access public
# trusted publishing needs no token; fallback for classic automation tokens:
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
With trusted publishing configured on npmjs.com (repository, workflow file name and optional environment), npm
exchanges the OIDC token for a short-lived publish credential, so no long-lived token is stored. --provenance attaches
a signed attestation linking the package to this workflow run. See
Node.js workspaces and publishing.
PyPI
name: release-pypi
on:
push:
tags: ['v*.*.*']
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with: { python-version: '3.13' }
- run: python -m pip install build && python -m build
- uses: actions/upload-artifact@v7
with: { name: dist, path: dist/ }
publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/my-package
permissions:
id-token: write # trusted publishing
steps:
- uses: actions/download-artifact@v8
with: { name: dist, path: dist/ }
- uses: pypa/gh-action-pypi-publish@release/v1
Register a trusted publisher on PyPI naming the repository, workflow file and the pypi environment; no API token is
needed. Attestations are generated by default. See
Python virtual environments and packaging.
NuGet
name: release-nuget
on:
push:
tags: ['v*.*.*']
jobs:
publish:
runs-on: ubuntu-latest
environment: nuget
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v7
- uses: actions/setup-dotnet@v6
with: { dotnet-version: 9.0.x }
- run: dotnet pack -c Release -p:Version="${GITHUB_REF_NAME#v}" -o out
- uses: NuGet/login@v1
id: login
with:
user: ${{ vars.NUGET_USER }} # nuget.org profile name
- run: dotnet nuget push "out/*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
env:
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
NuGet/login exchanges the OIDC token for a short-lived API key tied to a trusted-publishing policy configured on
nuget.org. A long-lived NUGET_API_KEY secret remains the fallback. See
NuGet CI release workflows.
GHCR container images
name: release-image
on:
push:
tags: ['v*.*.*']
jobs:
image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v7
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
The full treatment (caches, multi-platform builds, scanning, attestations) is on Docker CI/CD with GitHub Actions.
GitHub Pages, Go and Rust
-
GitHub Pages: documentation sites are deployed with
configure-pages,upload-pages-artifactanddeploy-pagesinto thegithub-pagesenvironment; the full workflow is on Environments and Deployment Protection. This site’s own publish workflow is scheduled rather than tag-driven, because it aggregates content from other repositories. -
Go: the tag is the release. Pushing
v1.4.0is enough;proxy.golang.orgfetches the module on first request and pkg.go.dev lists it. The workflow only needs to test and create the GitHub release (gh release create). Modules at v2 or later need the/v2suffix in the module path. -
Rust:
cargo publishuploads the crate; it needs a registry token, stored as an environment secret.
- uses: dtolnay/rust-toolchain@stable
- run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Ecosystem summary
| Ecosystem | Registry | Auth method | Action or command |
|---|---|---|---|
Java and Kotlin |
Maven Central (Central Portal) |
Portal user token and GPG key |
|
npm |
registry.npmjs.org |
Trusted publishing (OIDC) or |
|
Python |
PyPI |
Trusted publishing (OIDC) |
|
.NET |
nuget.org |
Trusted publishing via |
|
Containers |
ghcr.io |
|
|
Go |
Go module proxy |
None (public tag) |
Push the tag, |
Rust |
crates.io |
Registry token |
|
Static sites |
GitHub Pages |
OIDC ( |
|
Attachments, provenance, changelog and rollback
-
Attach artifacts with
gh release uploadorfiles:inaction-gh-release; also attach checksums (sha256sum dist/* > SHA256SUMS). -
Provenance: add
actions/attest-build-provenance@v4withid-token: writeandattestations: writebefore publishing, so consumers can rungh attestation verify. See Security Hardening. -
Changelog: generated release notes cover the GitHub side; keep a
CHANGELOG.mdfor users who read the repository, updated before tagging (not after, since the tag must contain it). -
Rollback: published versions on Maven Central, npm, PyPI and NuGet cannot be overwritten. Roll back by publishing a fixed higher version and, where supported, deprecating or yanking the bad one (
npm deprecate, PyPI yank, NuGet unlist). Container tags other than the digest can be re-pointed, which is why immutable tags are recommended.
Release branches
A repository with long-lived maintenance branches releases from them: the tag is created on the branch (for example
release_1.4), and the workflow is the same. This documentation site uses the same convention in reverse: its
playbook pulls the release_* branches of every documented repository, so cutting a release branch in one of them makes
its docs appear in the next nightly build without any change here. To release only from release branches, add a branch
filter:
on:
push:
branches: ['release_*']
tags: ['v*.*.*']
Common mistakes
-
Publishing from a job that also runs untrusted pull request code, or without a protected environment.
-
Storing long-lived registry tokens when the registry supports OIDC trusted publishing.
-
Rebuilding for each registry instead of building once and publishing the same artifacts.
-
Tagging before the changelog and version files are committed.
-
Using
softprops/action-gh-releaseorghwithoutcontents: write, which fails with "Resource not accessible by integration". -
Re-pushing a moved tag: registries and immutable releases refuse it, and consumers who cached the old build diverge.
-
Passing
server-usernamethe secret value instead of the environment variable name.