Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

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 Lessen
  • 3 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met 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

Commando's in deze les

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.

Commando's in deze les

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

Commando's in deze les

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.

Commando's in deze les

Alle commando's in dit hoofdstuk