Advanced
Searching inHow-to guides
How to search
  • Type the task in your own words (find port, open firewall, disk full) or paste an error message in quotes.
  • Choose "Quick answer" to see only the commands, or an area to stay in one field.
  • "two words" finds the exact phrase.
  • Plain words find names, texts and examples.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search
Try:

How-to 153Git · CI/CD

How to make a release with a Git tag

"Which code is version 1.4.2?" — a Git tag answers that forever: a fixed name for one commit. With a version tag, CI can build the release image, GitHub can publish release notes, and you can always go back to exactly what shipped. This how-to uses semantic versions, creates annotated (and signed) tags, publishes a GitHub release, and triggers the release pipeline.

  • 5 Lessons
  • 3 Commands

$ run as a normal user# run as root (or with sudo)

153.1

The quick answer

git switch main && git pull
git tag -a v1.4.2 -m "Release 1.4.2"
git push origin v1.4.2
gh release create v1.4.2 --generate-notes

Commands in this lesson

153.2

Step by step

  1. Choose the version — Semantic Versioning MAJOR.MINOR.PATCH:
ChangeBumpExample
Bug fix, no new behaviourPATCH1.4.1 → 1.4.2
New feature, still compatibleMINOR1.4.2 → 1.5.0
Breaking changeMAJOR1.5.0 → 2.0.0
  1. Tag the right commit — usually the current main after CI is green. Annotated tags (-a) store who, when and a message; use them for releases. Sign them if you sign commits:
git tag -s v1.4.2 -m "Release 1.4.2"
git show v1.4.2 --stat | head
  1. Push the tag — git push alone does not push tags:
git push origin v1.4.2
  1. Release pipeline — a workflow that runs on version tags:
.github/workflows/release.yml (part)
on:
  push:
    tags: ["v*"]

It builds the image tagged 1.4.2, signs it, and attaches artifacts.

  1. Release notes — GitHub writes them from the merged pull requests:
gh release create v1.4.2 --generate-notes --title "1.4.2"
gh release list | head -3
  1. Useful commands:
git tag --list 'v1.4.*'
git describe --tags
git log --oneline v1.4.1..v1.4.2
git switch --detach v1.4.2

git describe shows the nearest tag (good for version strings in builds); log A..B lists what changed between two releases.

  1. 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).
git tag -d v1.4.2
git push origin --delete v1.4.2

153.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.

Commands in this lesson

153.4

Common problems

ProblemCauseFix
Tag not on GitHubTags are not pushed with git push.git push origin TAG (or --follow-tags for annotated tags).
Release workflow did not startPattern does not match (1.4.2 vs v*).Use one naming style; match it in on.push.tags.
Tagged the wrong commitLocal main was old.git pull first; if unused, delete and re-tag.
tag 'v1.4.2' already existsSame name used before.Pick the next version; never reuse released tags.
Release notes are emptyDirect commits without PRs.Work with PRs, or write notes by hand.
A moved tag confuses deploymentsSomeone force-pushed a tag.Protect tags (Rulesets → tag protection).

Commands in this lesson

153.5

Go further

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.

Commands in this lesson

All commands in this chapter