bump

package module
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 16 Imported by: 0

README

Bump (bump)

Bump is a CLI tool designed to help you manage the versioning of your project using semantic versioning. It allows you to bump the version of your project and tag the repository accordingly. This tool operates directly within your project's Git repository.

Features

  • Bump Patch Version: Increment the patch version for small fixes.
  • Bump Minor Version: Increment the minor version for backward-compatible feature additions.
  • Bump Major Version: Increment the major version for breaking changes.
  • Add Suffix to Version: Add a custom suffix to the version, allowing for pre-release and build metadata.

Installation

Before you can use Bump, you need to ensure that you have a Go environment set up and that your project is using Git for version control.

  1. Clone the repository where bump is hosted.

  2. Navigate into the directory and build the tool using Go:

    go build -o version-bumper
    
  3. You can now use version-bumper from the command line within your project's directory.

Usage

After you have successfully built the version-bumper, you can use it by running the executable followed by the specific version bump you want to apply.

./bump patch              # Bump the patch version (creates tag, does not push)
./bump patch --push       # Bump the patch version and push the tag to remote
./bump minor              # Bump the minor version (creates tag, does not push)
./bump minor --push       # Bump the minor version and push the tag to remote
./bump major --suffix rc1 # Bump the major version with a suffix (creates tag, does not push)
./bump major --suffix rc1 --push # Bump the major version with a suffix and push the tag
./bump push               # Push all tags to remote (can be run separately)

If you do not specify the --push flag, the tool will print the command you should run to push the tag manually (e.g., git push --tags).

Per-Repository Default Push Preference

You can set a default for whether tags are pushed after bumping, on a per-repo basis. This is stored in your repo's .git/config.

To set the default to push after bumping:

./bump config --default-push

To set the default to NOT push after bumping:

./bump config --default-push=false

If you do not specify --push on the command line, the tool will use the repo default. If neither is set, it will not push by default.

How It Works

  1. Opening the Git Repository: The tool automatically detects and opens your project's Git repository.
  2. Fetching Tags: It fetches all the tags from the repository to determine the latest version.
  3. Determining and Creating the Next Version: Based on the command (major, minor, patch, or suffix), it calculates the next version, creates a new tag, and pushes this tag to the remote repository.

Contributing

We welcome contributions to bump, whether it's improving documentation, adding new features, or reporting bugs, your contributions are greatly appreciated.

License

This project is licensed under the MIT License. Feel free to clone, modify, and use it in your own projects.

Disclaimer

The bump is provided "as is", without warranty of any kind. Use at your own risk.

Documentation

Overview

Package bump provides functionality for semantic versioning and git tagging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTag added in v1.6.0

func CreateTag(tag string) error

CreateTag creates a new git tag with the given tag. Uses concurrency protection to prevent concurrent git operations.

func GetDefaultPushPreference added in v1.6.0

func GetDefaultPushPreference(repoPath string) (bool, bool, error)

GetDefaultPushPreference reads the bump defaultPush value from .git/config in the given repo path. Returns (value, isSet, error) where isSet indicates if the preference was explicitly configured.

func GetLatestTag

func GetLatestTag(tagRefs storer.ReferenceIter) (string, error)

GetLatestTag returns the latest semantic version tag in the given git tags.

func GetNextTag

func GetNextTag(currentTag, bumpType, suffix string) (string, error)

GetNextTag returns the next semantic version tag based on the given current tag and bump type.

func NewGitInfo

func NewGitInfo(path string) ([]string, error)

NewGitInfo returns the semantic versions of all git tags in the repository at the given path.

func ParseTagVersion

func ParseTagVersion(tag string) (*tagVersion, bool)

ParseTagVersion parses a git tag into a semantic version.

func PushTag added in v1.6.0

func PushTag() error

PushTag pushes the latest git tag to the remote repository. Uses concurrency protection to prevent concurrent git operations.

func SetDefaultPushPreference added in v1.6.0

func SetDefaultPushPreference(repoPath string, value bool) error

SetDefaultPushPreference writes the bump defaultPush value to .git/config in the given repo path. Uses atomic writes to prevent corruption.

Types

type GitLock added in v1.7.1

type GitLock struct {
	// contains filtered or unexported fields
}

GitLock represents a file-based lock for git operations

func (*GitLock) Release added in v1.7.1

func (lock *GitLock) Release() error

Release releases the git lock, removing the lock file and releasing the mutex.

type MockReferenceIter

type MockReferenceIter struct {
	// contains filtered or unexported fields
}

func NewMockReferenceIter

func NewMockReferenceIter(refs []plumbing.Reference) *MockReferenceIter

func (*MockReferenceIter) Close

func (m *MockReferenceIter) Close()

func (*MockReferenceIter) ForEach

func (m *MockReferenceIter) ForEach(cb func(*plumbing.Reference) error) error

func (*MockReferenceIter) Next

func (m *MockReferenceIter) Next() (*plumbing.Reference, error)

Directories

Path Synopsis
cmd
bump command

Jump to

Keyboard shortcuts

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