Video in progress

Middle 🌿 Git

How do you manage release versions with Git tags, and how does semantic versioning relate to that?

Every release is marked with an annotated tag, for example v2.4.1. By SemVer, MAJOR is a backward-incompatible change, MINOR is a new feature, and PATCH is only a fix. CI sees the tag and builds the artifact and image with that version.

📖 Answer

The flow is usually like this:

git switch main && git pull
git tag -a v2.4.0 -m "Release 2.4.0: Click orqali to'lov"
git push origin v2.4.0

A job in GitHub Actions that runs only on a tag push:

on:
  push:
    tags: ['v*']
jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./mvnw -B versions:set -DnewVersion=${GITHUB_REF_NAME#v} && ./mvnw -B deploy

This way the version in pom.xml and the tag never drift apart.

SemVer has to be taken seriously for API consumers: if you removed a method from a library or took a field out of a REST response, that is a MAJOR bump. For an internal-only service, many teams also use date-based versions (2026.11.03), which is fine too.

Never move tags (re-pointing a name at a different commit). Someone has already downloaded the old v2.4.0, and now there are two different "2.4.0"s. If there is a mistake, release v2.4.1.