$ run as a normal user# run as root (or with sudo)
The quick answer
Step by step
- Choose the version — Semantic Versioning
MAJOR.MINOR.PATCH:
| Change | Bump | Example |
|---|---|---|
| Bug fix, no new behaviour | PATCH | 1.4.1 → 1.4.2 |
| New feature, still compatible | MINOR | 1.4.2 → 1.5.0 |
| Breaking change | MAJOR | 1.5.0 → 2.0.0 |
- Tag the right commit — usually the current
mainafter CI is green. Annotated tags (-a) store who, when and a message; use them for releases. Sign them if you sign commits:
- Push the tag —
git pushalone does not push tags:
git push origin v1.4.2- Release pipeline — a workflow that runs on version tags:
on:
push:
tags: ["v*"]It builds the image tagged 1.4.2, signs it, and attaches artifacts.
- Release notes — GitHub writes them from the merged pull requests:
- Useful commands:
git tag --list 'v1.4.*'
git describe --tags
git log --oneline v1.4.1..v1.4.2
git switch --detach v1.4.2git describe shows the nearest tag (good for version strings in builds); log A..B lists what changed between two releases.
- A wrong tag? If it was not used yet, delete and recreate it. If it was already published and used, do not move it — make a new version (
v1.4.3).
Check that it worked
git ls-remote --tags origin | grep v1.4.2 shows the tag on the server, the release page lists it with notes, and the release pipeline produced the 1.4.2 image.
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Tag not on GitHub | Tags are not pushed with git push. | git push origin TAG (or --follow-tags for annotated tags). |
| Release workflow did not start | Pattern does not match (1.4.2 vs v*). | Use one naming style; match it in on.push.tags. |
| Tagged the wrong commit | Local main was old. | git pull first; if unused, delete and re-tag. |
tag 'v1.4.2' already exists | Same name used before. | Pick the next version; never reuse released tags. |
| Release notes are empty | Direct commits without PRs. | Work with PRs, or write notes by hand. |
| A moved tag confuses deployments | Someone force-pushed a tag. | Protect tags (Rulesets → tag protection). |
Go further
- Command pages: git, gh.
- Next how-tos: Work with branches and pull requests, Build and push an image in CI, Sign Git commits.
- Learn it: Git — Tags. Full guide: Git.
- Practise: Lab: find the bad commit with bisect, park work with stash, release with a tag.
1Why use an annotated tag for a release?
It stores the author, date and message (and can be signed) — a lightweight tag is only a name.
2A wrong tag was already published and used. What do you do?
Do not move it; release a new version with a new tag.