A package to automate version bumping and Git tagging in GitLab CI.
Project description
Markdown
gitlab-auto-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_NAMEenvironment variable. - Pushes tags to the GitLab origin remote.
- Optionally loads configuration from your
.gitlab-ci.ymlfile.
- Retrieves the branch name from the
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitlab_auto_version-0.1.3.tar.gz.
File metadata
- Download URL: gitlab_auto_version-0.1.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95523768c4cf1d912891f417c772d7b84b6dc268855479d45da40be1c6c29492
|
|
| MD5 |
af0f9fcc09084cc61d098dbbd3b1063d
|
|
| BLAKE2b-256 |
284d129c58a8249626fa8a883aef9cd498a4b21fcffaa4fdac47a14c528215e9
|
File details
Details for the file gitlab_auto_version-0.1.3-py3-none-any.whl.
File metadata
- Download URL: gitlab_auto_version-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac626b73c340a2083ad5f1165af1b2df49d9f42dd01bbbd8cac9aa3ccc0a6194
|
|
| MD5 |
50da80cd8b0ee559f506aba0f13406ee
|
|
| BLAKE2b-256 |
1b48c056c9d842f9679da13116b7adef3520e73533a2d8c61d10bc29373b6ac6
|