DEV Community

Cover image for πŸš€ Automate Your Releases with gitag: The Ultimate CLI for Semantic Versioning
Henry Manke
Henry Manke

Posted on

πŸš€ Automate Your Releases with gitag: The Ultimate CLI for Semantic Versioning

In today’s fast-paced development environments, manually maintaining version numbers and generating changelogs can become a bottleneck. gitag is a modern, lightweight CLI tool designed to integrate seamlessly into your CI/CD pipeline, parsing Conventional Commits and applying Semantic Versioning automatically. Read on to learn how gitag can save you time ⏱️, reduce human error ❌, and improve release consistency πŸ”„.


πŸ€” Why You Need Automatic Versioning

Maintaining consistent version numbers and comprehensive changelogs is challenging:

  • Human Error ❌: Manual bumps can be forgotten or inconsistent, leading to mismatched tags.
  • Inefficient Workflows 🐒: Time spent on versioning and changelog updates diverts focus from actual development.
  • Poor Traceability πŸ”: Without clear semantic tags, it’s hard to understand which commits introduced features, fixes, or breaking changes.

By automating this process, gitag ensures:

  • πŸ”‘ Reliable Tags: Always follow Semantic Versioning (MAJOR.MINOR.PATCH).
  • πŸ“„ Consistent Changelogs: Automatically generate or update your CHANGELOG.md.
  • πŸ€– Seamless CI/CD Integration: No manual stepsβ€”just push and let gitag handle the rest.

✨ Key Features of gitag

Feature Benefit
βœ… Conventional Commits parsing Detects feat:, fix:, BREAKING CHANGE:, and more
πŸ”’ Semantic Versioning support Automatic MAJOR, MINOR, PATCH bumps
🏁 Dry-Run & CI Modes Preview changes before applying; perfect for pipelines
πŸ“ Changelog Generation (BETA) Keeps your CHANGELOG.md in sync with commits
βš™οΈ Configurable via pyproject.toml Customize prefixes, merge strategies, and bump keywords
πŸ”€ Merge Commit Strategies Choose auto, always, or merge-only bump behavior
🀝 GitHub Actions Example Out-of-the-box workflow provided for quick setup
πŸ§ͺ 100% Tested with pytest Confidence in production usage

πŸ“¦ Installation & Quickstart

  1. Install from PyPI
   pip install gitag
Enter fullscreen mode Exit fullscreen mode
  1. πŸ” Preview Next Tag (Dry-Run)
   gitag --dry-run
Enter fullscreen mode Exit fullscreen mode
  1. πŸš€ Tag & Changelog in CI
   gitag --ci --changelog
Enter fullscreen mode Exit fullscreen mode

For development or contributions:

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

πŸ”§ How gitag Works

  1. Analyze Commits πŸ”Ž Reads your Git history since the last tag, matching commit messages against Conventional Commits patterns (e.g., feat:, fix:, perf:).
  2. Determine Bump Level πŸ“ˆ
  • Major πŸ”₯: BREAKING CHANGE:, !:
  • Minor ✨: feat: or feature(...)
  • Patch πŸ›: fix:, perf:, docs:, chore:, etc.
    1. Generate Tag & Changelog 🏷️ Applies the next semantic version tag (e.g., v1.2.3 β†’ v1.3.0), optionally updates CHANGELOG.md, andβ€”if in CI modeβ€”pushes tags to remote.

πŸ€– Integrating with GitHub Actions

Add the following workflow to .github/workflows/auto-tag.yml to automate tagging on every push to main:

name: Auto Tag

on:
  push:
    branches: [main]

jobs:
  tag:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - name: πŸ“₯ Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: 🐍 Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - name: πŸ“¦ Install gitag
        run: pip install gitag
      - name: πŸš€ Run gitag (CI + Changelog)
        run: gitag --ci --debug --changelog
      - name: πŸ“€ Upload CHANGELOG
        uses: actions/upload-artifact@v4
        with:
          name: changelog
          path: CHANGELOG.md
Enter fullscreen mode Exit fullscreen mode

βš™οΈ Configuration Example

Customize gitag behavior via pyproject.toml:

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

[tool.gitag.bump_keywords]
major = ["BREAKING CHANGE", "!:"]
minor = ["feat:"]
patch = ["fix:", "perf:", "docs:", "chore:"]
Enter fullscreen mode Exit fullscreen mode

See the full Config Reference for advanced options.


πŸŽ‰ Conclusion

By adopting gitag, you can:

  • ❌ Eliminate manual errors in version bumps
  • ⚑ Accelerate release cycles with automated tagging
  • πŸ“‘ Maintain clear changelogs aligned with your commit history

Start today by running:

gitag --dry-run
Enter fullscreen mode Exit fullscreen mode

and transform your release process with robust, semantic versioning automation.

Happy tagging! 🏷️

Top comments (1)

Collapse
 
jamey_h_77980273155d088d1 profile image
Jamie H

Hi, Nice posting!