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.2.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.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gitag-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 a47d5fb356060e4c4b7c3c9976c2f0e47d88e32d7caf0cad8136df5f2c36b0e2
MD5 472ab6841b4e4e466c314800f5a2451b
BLAKE2b-256 0d06eda492f3efb4baa968be6b76ffaf796e86e06bede57b227f20adb93311c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gitag-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1ad8b9c5cf7e85e7f4f4ebdf2ce37e7ff634ae223b668cf25309a1d53cb5b89
MD5 ae1f8a620b4508d8c1a4c57a1ba2e708
BLAKE2b-256 05844e90a476b228ea57920b2c545f94420f73c237a7663d969c29fc1f4be3d9

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