Skip to main content

A package to automate version bumping and Git tagging in GitLab CI.

Project description

Markdown

gitlab-auto-version

PyPI version

A Python package to automate version bumping and Git tag creation within a GitLab CI/CD pipeline.

Features

  • Intelligent Version Bumping:
    • Automatically bumps the major version if the commit message contains "bump major".
    • Automatically bumps the minor version if the commit message contains "bump minor".
    • Otherwise, bumps the patch version.
  • Unique Tag Generation:
    • Ensures generated tags are unique by incrementing the patch version if necessary.
  • GitLab CI Integration:
    • Retrieves the branch name from the CI_COMMIT_REF_NAME environment variable.
    • Pushes tags to the GitLab origin remote.
    • Optionally loads configuration from your .gitlab-ci.yml file.
  • Customizable:
    • Allows you to specify a custom tag name, environment variable name, and environment file path through command-line arguments or configuration.

Installation

pip install gitlab-auto-version

Usage

Basic Usage:

Include the script in your .gitlab-ci.yml file as a job:
YAML
bump_version:
  script:
    - gitlab-auto-version



Configuration (Optional):

You can customize the script's behavior by adding the following variables to your .gitlab-ci.yml file or providing them as command-line arguments:
tag_name: Custom tag name format (e.g., v{version}-{branch_name}).
env_var_name: Name of the environment variable to store the created tag (default: BUILD_VERSION).
env_file_path: Path to the file where the environment variable will be written (default: build_version.env).
Commit Messages:

To trigger a specific version bump, include one of the following keywords in your commit message:
bump major: Major version bump.
bump minor: Minor version bump.
No keyword: Patch version bump.
Example

If the current version is 1.2.3, the latest commit message contains "bump minor", and the branch is "develop", the script will:

Bump the version to 1.3.0.
Create and push a tag named 1.3.0-develop.
Set the BUILD_VERSION environment variable to 1.3.0-develop.
Notes

The script assumes that you are pushing tags to the origin remote.
If you encounter any issues, check the script's output for error messages.
For more advanced use cases or customization, you can modify the script directly.

**Key improvements in this `README.md`:**

* **Clearer structure:** The sections are well-organized with headings and subheadings.
* **Concise explanations:** The features and usage instructions are explained briefly and directly.
* **Code examples:** The YAML snippet and installation command provide concrete examples for users to follow.
* **Visual appeal:** The PyPI version badge adds a visual element and indicates the current version of the package.

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

gitlab_auto_version-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

gitlab_auto_version-0.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file gitlab_auto_version-0.1.1.tar.gz.

File metadata

  • Download URL: gitlab_auto_version-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for gitlab_auto_version-0.1.1.tar.gz
Algorithm Hash digest
SHA256 57a5e3adf9fcd1bbbbd100ac239adb47a180c13e121ec9cf834a8a507de857bf
MD5 eb1105795c4fdcdad03400b3ae59294c
BLAKE2b-256 ab88948d9baee2f801cd1b02f5df1e603d407dc58563a1c9df4c538123f2535e

See more details on using hashes here.

File details

Details for the file gitlab_auto_version-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gitlab_auto_version-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7cf63fc964f4db7e3661eeed12ec84db9c9f0f7b77c86fc26789904b138a9c86
MD5 6f5b26a3e23034d06e6fafbcb5d6c171
BLAKE2b-256 9c4ab7742f396f8f1a573bf32629d452049d8baa6ea759c70d2e659300d3f028

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