Skip to main content

Bump version numbers across several files

Project description

Version Bumper

A tool to bump version numbers in project files. It can be used locally or as a GitHub Action.

Features

  • Bump minor, or patch versions (semantic versioning)
  • Automatically detects version patterns in files
  • Option to use Git tags as version source
  • Can be used as a GitHub Action or CLI tool

Installation

For now, the tool is only available as a script or Github Actions tool (recommended). I have plans to publish it on pip soon.

Usage

CLI Usage

If you want to bump the version number in setup.py,

# Bump patch version (default)
python main.py setup.py # 1.2.3 -> 1.2.4

# Specific bump types
python main.py setup.py --major # 1.2.3 -> 2.0.0
python main.py setup.py --minor # 1.2.3 -> 1.3.0
python main.py setup.py --patch # 1.2.3 -> 1.2.4

# Use Git tag as version, e.g. v0.9-19-g7e2d
python main.py setup.py --git

# Pass several files to update
python main.py setup.py README.md --patch

GitHub Action Usage

name: Bump Version

on:
  push:
    branches: [main]

# give permission to write and push commits
permissions:
  contents: write

jobs:
  bump-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0  # Required for git versioning

      - name: Bump version
        uses: Ikromov247/bump_version@v0.9
        with:
          file: 'package.json' # file containing your package version number
          bump_type: 'patch'  # Options: major, minor, patch, git

      - name: Commit changes
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git add .
          git commit -m "Bump version"
          git push

Config file

You can also add your configurations in a yaml file instead of passing them as arguments. If you pass both the config file and the arguments, config file takes precedence and cli arguments will be ignored.

Example configuration file:

name: 'Patch bump' # Configuration name
description: 'Bump the patch version in dummy.py' # description

settings:
  bump_type: patch
  files: # list of files to update
    - setup.py
    - README.md

In cli, pass as an argument: python main.py --config config.yml

In Github Actions workflow file:

- name: Bump version
  uses: Ikromov247/bump_version@v0.9
  with:
    config: bump_config.yml

Supported Version Formats

The tool recognizes uses regex to recognize various version patterns:

  • version = "1.2.3"
  • VERSION = "1.2.3"
  • __version__ = "1.2.3"
  • "version": "1.2.3" (for JSON/package.json)

Common errors

  • Invalid version format:

    • Reason: the tool could not find the version number. Your version possibly does not match supported patterns.
  • File or permission errors:

    • Reason: the tool could not open or write to specified files.
    • Solution: check file paths and permissions.
  • Config file is invalid:

    • Reason: your config file does not have required fields.
    • Solution: check the sample config file for reference.
  • Major version bumping is not supported:

    • Reason: Bumping major versions is only possible through cli to prevent accidental major version bumps.
    • Solution: Use cli for major version bumps or set a different bump type
  • Error occured when reading the git tag:

    • Reason: your repo does not have tags.
    • Solution: create a tag.

Contributing

If you want to contribute, start from checking the todo file and the CONTRIBUTING.MD for rules. To suggest new features, create an issue with the tag enhancement.

License

MIT

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

simplebumpversion-2.0.2.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

simplebumpversion-2.0.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file simplebumpversion-2.0.2.tar.gz.

File metadata

  • Download URL: simplebumpversion-2.0.2.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for simplebumpversion-2.0.2.tar.gz
Algorithm Hash digest
SHA256 7781a68e49126521befbbefa5b042e7c95a898a0f44752b8c1a35ff28c185a4b
MD5 638568096686dcf0e651237ac02f3199
BLAKE2b-256 a93d33faf061c481c830d4955b01a0a930f8caade9f1ed53ef0612677ecfd769

See more details on using hashes here.

File details

Details for the file simplebumpversion-2.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for simplebumpversion-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b07088097c3a95e9b29bb7222cff1d93ba9b50fdd1eaa1bf0539b0053df6033e
MD5 a5372d0f988c2bc9dcd5c289e0aafa84
BLAKE2b-256 5b0ba05725b644344f51e31d195ccea86d82d0bed8b230730a54427e05cce8be

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