Why this matters
Whenever Composer installs version 2.1.0 of a package, it finds the code through a Git tag named 2.1.0. A Git tag is just a pointer to a commit, and on most hosts anyone with write access can move it to a different commit at any time.
If that happens, people who install the version afterwards get different code under a version number they already trusted, reviewed, or audited. Nothing warns them. Someone who takes over a maintainer account or a release token can use this to rewrite a version that thousands of projects already depend on, without publishing anything that looks new.
GitHub immutable releases remove this risk for every release published while the setting is on. The tag is locked to its commit and cannot be moved or deleted while the release exists, not even by an administrator. Release files are locked too, and each release gets a signed attestation people can verify.
What good looks like
- Release immutability is turned on for the repository, or for the whole organization.
- Every version is published as a GitHub release, not only as a bare Git tag.
- The latest release shows the Immutable label under its title on the releases page.
How to do it
Turn on immutable releases
- Open the repository's Settings, then General.
- In the Releases section, select Enable release immutability.
- Publish your next version as a GitHub release.
Organization owners can turn this on for every repository at once under the organization's Settings, Repository, General, Releases.
Immutability applies only to releases published after you turn it on. Earlier releases stay as they were.
Publish releases, not just tags
Immutability applies to releases, not to tags. A tag pushed on its own has no release, so it can still be moved even with the setting turned on. Create a release for every version, for example with gh release create v2.1.0 --generate-notes, or with a release workflow that runs when you push a tag. Many projects only push tags today; this is the one change they need.
Attach files before publishing
Release files cannot be added once an immutable release is published. If your workflow uploads files, create the release as a draft, upload the files, then publish it.
Things to watch for
- Tags pushed before the release. If a workflow pushes the tag first and creates the release later, the tag is unprotected in between. Let the release create the tag where you can.
- Release tools that retry by recreating tags. A retry that deletes and recreates the tag will fail once releases are immutable. Make retries publish a new version instead.
- Other hosts. GitHub is the only host that offers a lock like this today. GitLab, Bitbucket, and others have protected tags, which help against mistakes, but an administrator can switch them off. If your host adds an equivalent lock, use it.
- Turning it off. Disabling the setting does not unlock earlier immutable releases, but new releases are no longer protected.