gitbump

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

README

git-bump

Easily tag new versions with git using configurable versioning conventions.

Features

  • Multiple Versioning Conventions: Support for semantic versioning (semver) and calendar versioning (calver)
  • Configurable: Use .gitbump.toml configuration files for project-specific settings
  • Flexible Prefixes: Customize version prefixes (v, release, etc.)
  • Auto-increment: Intelligent version incrementing based on convention type
  • Git Integration: Seamless git tag creation and management

Install CLI

Using go:

go install git.sr.ht/~timharek/git-bump/cmd/git-bump@latest
Using Homebrew
brew tap timharek/tap
brew install git-bump

Adding more methods in the future. Help is wanted to achieve the best coverage.

Using pre-compiled binary

Select the version you want to install [available releases] and download it and add it to your bin or something similar.

Example:

wget https://git.sr.ht/~timharek/git-bump/refs/download/<release>/git-bump-<version>-linux-amd64.tar.gz
tar xf git-bump-<version>-linux-amd64.tar.gz
cd git-bump-<version>
cp git-bump /usr/local/bin

Configuration

Initialize a configuration file in your git repository:

git bump init

This creates a .gitbump.toml file with default settings:

[versioning]
convention = 'semver'
prefix = 'v'
format = '{major}.{minor}.{patch}'
timezone = 'UTC'

[git]
remote = 'origin'
auto_push = false

[messages]
use_shortlog = false
custom_messages = []
Versioning Conventions
Semantic Versioning (semver)
  • Convention: semver
  • Format: {major}.{minor}.{patch}
  • Increment types: major, minor, patch
  • Example: v1.2.3
Calendar Versioning (calver)
  • Convention: calver
  • Formats:
    • YYYY.MM.DD (date-based)
    • YY.MM.DD (short year)
    • YYYY.MM.MICRO (with micro increments)
    • YY.MM.MICRO (short year with micro)
  • Increment types: date, micro
  • Examples: release2025.07.11, v25.07.15
Configuration Hierarchy

git-bump searches for configuration files in this order:

  1. .gitbump.toml in git repository root
  2. ~/.config/git-bump/config.toml
  3. ~/.gitbump.toml

Usage

# Get help
git bump -h

# Bump version (uses convention-specific default increment)
git bump
# Output: v0.0.1 (semver) or release2025.07.11 (calver)

# Bump version and include shortlog between current commit and previous tag
git bump --shortlog

# Bump version with message(s)
git bump --message "Feat 1" --message "Fix 2"

# Bump specific component (semver)
git bump --minor   # v0.1.0
git bump --major   # v1.0.0
git bump --patch   # v0.0.1

# Show latest version
git bump latest

# List all version tags
git bump list

# Undo (delete) latest tag
git bump undo

# Undo (delete) tag from remote origin
git bump undo --remote origin

# Push tag to remote
git bump push
Convention-Specific Behavior

Semantic Versioning:

  • Bumping minor resets patch to 0
  • Bumping major resets minor and patch to 0
  • Default increment: patch

Calendar Versioning:

  • Date format: Updates to current date
  • Micro format: Increments micro number for same month, resets to 1 for new month
  • Default increment: date (for YYYY.MM.DD) or micro (for YYYY.MM.MICRO)

Examples

Semver Project
git bump init
# Edit .gitbump.toml: convention = 'semver', prefix = 'v'
git bump          # v0.0.1
git bump --minor  # v0.1.0
git bump --major  # v1.0.0
Calver Project
git bump init
# Edit .gitbump.toml: convention = 'calver', prefix = 'release', format = 'YYYY.MM.DD'
git bump  # release2025.07.11
git bump  # release2025.07.11 (same day, increments to current date)
Calver with Micro Increments
# Edit .gitbump.toml: convention = 'calver', format = 'YYYY.MM.MICRO'
git bump  # v2025.07.1
git bump  # v2025.07.2 (same month, increments micro)

Things to know

  • --help will not work when running in git bump, but will work in git-bump.
  • Configuration settings override command-line defaults
  • Each versioning convention has its own increment logic and options

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoVersions = errors.New("no versions")
)
View Source
var Path string = ""

Where to execute the git/bump commands

Functions

func AddVersion added in v0.2.0

func AddVersion(version convention.Version, msg []string) error

Tag current commit with version.

func AddVersionString added in v0.2.0

func AddVersionString(tagStr string, con convention.Convention) error

Tag current commit with version string using specified con.

func DeleteVersion added in v0.2.0

func DeleteVersion(version convention.Version) error

Delete version tag.

func DeleteVersionRemote added in v0.2.0

func DeleteVersionRemote(version convention.Version, remote string) error

Delete version from remote.

func InitConfig added in v0.2.0

func InitConfig() error

func LatestVersion added in v0.2.0

func LatestVersion(con convention.Convention) (convention.Version, error)

Returns latest version.

func ListVersions added in v0.2.0

func ListVersions(con convention.Convention) ([]convention.Version, error)

func PushVersion added in v0.2.0

func PushVersion(version convention.Version, remote string) error

Push version to remote.

func Shortlog

func Shortlog(rev1, rev2 string) (string, error)

Shortlog between rev1 and rev2.

Example: git shortlog abc1234..HEAD If rev1 is empty, shows all commits up to rev2

Types

type Config added in v0.2.0

type Config struct {
	Versioning VersioningConfig `toml:"versioning"`
	Git        GitConfig        `toml:"git"`
	Messages   MessagesConfig   `toml:"messages"`
}

func DefaultConfig added in v0.2.0

func DefaultConfig() *Config

func LoadConfig added in v0.2.0

func LoadConfig() (*Config, error)

type GitConfig added in v0.2.0

type GitConfig struct {
	Remote   string `toml:"remote"`
	AutoPush bool   `toml:"auto_push"`
}

type MessagesConfig added in v0.2.0

type MessagesConfig struct {
	UseShortlog    bool     `toml:"use_shortlog"`
	CustomMessages []string `toml:"custom_messages"`
}

type VersionListing added in v0.2.0

type VersionListing struct {
	ValidVersions []convention.Version `json:"valid_versions"`
	BrokenTags    []string             `json:"broken_tags,omitempty"`
}

Lists all versions.

func ListVersionsWithBroken added in v0.2.0

func ListVersionsWithBroken(con convention.Convention) (*VersionListing, error)

type VersioningConfig added in v0.2.0

type VersioningConfig struct {
	Convention string `toml:"convention"`
	Prefix     string `toml:"prefix"`
	Format     string `toml:"format"`
	Timezone   string `toml:"timezone"`
}

Directories

Path Synopsis
cmd
git-bump command
internal
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL