Skip to main content

A CLI tool for automatic git tagging based on commit messages

Project description

🚀 gitag

gitag logo

gitag is a modern CLI tool that parses commit messages following Conventional Commits and applies Semantic Versioning automatically — perfect for CI/CD pipelines.

Commit Pattern Bump Level Version Change
!:, BREAKING CHANGE: major 1.2.32.0.0
feat(...), feature(...) minor 1.2.31.3.0
fix(...), perf(...), refactor(...), docs(...), style(...), chore(...), test(...),
ci(...), build(...)
patch 1.2.31.2.4

📖 Table of Contents


Quickstart

  1. Install 📦

    pip install gitag
    
  2. Preview tag 🔍

    gitag --dry-run
    
  3. Tag & Changelog 🔁

    gitag --ci --changelog
    

For development:

git clone https://github.com/henrymanke/gitag.git
cd gitag
pip install -e .[dev]

Features

  • ✅ Semantic Versioning (major, minor, patch)
  • 🔍 Detect latest Git tag
  • 🧠 Commit-based bump detection via Conventional Commits
  • 📄 (BETA) Optional CHANGELOG.md generation
  • 🔁 Dry-run & CI modes
  • 🚀 Push tags via GITHUB_TOKEN
  • ⚙️ Configurable via pyproject.toml
  • 🔀 Flexible merge commit strategies
  • 🧪 100% tested with pytest and mocks

Commit Mapping & Version Bumps

Commit Type Bump Level Example Spec Reference
BREAKING CHANGE: major BREAKING CHANGE: update API method SemVer
feat: / feature: minor feat: add new export feature Conventional Commits
fix: / chore: patch fix: correct typo in docs Conventional Commits

Installation

Install from PyPI:

pip install gitag

Or install for development:

git clone https://github.com/henrymanke/gitag.git
cd gitag
pip install -e .[dev]

CLI Reference

Command Description
--dry-run Preview the next tag without applying it
--changelog Generate or update CHANGELOG.md
--push Push the new tag to the remote repository
--pre <label> Add a pre-release label (e.g. alpha.1)
--build <meta> Include build metadata (e.g. 123abc)
--config <path> Path to pyproject.toml (default: project root)
--merge-strategy Override bump strategy (auto, always, merge_only)

See Advanced CLI Options for full list.


GitHub Actions Example

Save as .github/workflows/auto-tag.yml:

name: Auto Tag

on:
  push:
    branches: [main]

jobs:
  tag:
    runs-on: ubuntu-latest

    # Allow this workflow to push tags and artifacts
    permissions:
      contents: write

    # GitHub token for pushing tags and uploading artifacts
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # or use a personal token for cross-repo support

    steps:
      # 1. Checkout the full repository (including all tags and history)
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0          # Needed to find the latest tag
          token: ${{ env.GH_TOKEN }}

      # 2. Set up Python 3.11 environment
      - name: Set up Python 3.11
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
          cache: "pip"

      # 3. Install the gitag CLI tool
      - name: Install gitag
        run: pip install gitag

      # 4. Run gitag in CI mode and generate the changelog
      - name: Run gitag (CI mode + changelog)
        run: gitag --ci --debug --changelog

      # 5. Upload the generated CHANGELOG.md as a build artifact
      - name: Upload generated changelog
        uses: actions/upload-artifact@v4
        with:
          name: changelog
          path: CHANGELOG.md

Commit and push — workflow runs on every push to main.


Configuration

Add to pyproject.toml:

[tool.gitag]
prefix = "v"
merge_strategy = "auto"

[tool.gitag.bump_keywords]
major = ["BREAKING CHANGE"]
minor = ["feat:"]
patch = ["fix:"]

See Config Reference for details.


Deep Dive Documentation


Contributing & License

Contributions are welcome! Read CONTRIBUTING.md.

Licensed under the MIT License — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitag-0.0.1.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitag-0.0.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file gitag-0.0.1.tar.gz.

File metadata

  • Download URL: gitag-0.0.1.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for gitag-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fd1f857a82789441d0f6c06466e3293ed172348ecd3aea97743fd768024a94e3
MD5 bfd5718234b29e82ee9935bc94917da2
BLAKE2b-256 8254442123ac772a7c3ee1f253e49419ec0bf2e3eccd08dc04d67584388b9321

See more details on using hashes here.

File details

Details for the file gitag-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: gitag-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for gitag-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8adb8bf4d78b9207501617bbe3aaf453339251a2719a67261b0f8147aad15be
MD5 660525f3adcc67fe5ad86db856c78fec
BLAKE2b-256 dd714b59555f4d253b416dbc419ee889c60a17ea56c2b50192fc54e75211efa5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page