"Compute Version" is a GitHub Action designed to automate version computation in CI/CD pipelines, utilizing branch names and git tags. Optimized for projects using trunk-based development practices and adhering to Semantic Versioning (SemVer), it dynamically generates version numbers to streamline deployments and releases.
This action excels in environments that favor trunk-based development, where frequent merges are made to a single branch, typically main or master. By integrating with SemVer, it promotes consistent and meaningful version increments, ensuring version management aligns with continuous integration principles.
We support branches prefixed for various stages:
feature/(optional Jira card ID)developmain
While other branch names can be used, develop and main are designated for development builds and production builds, respectively.
- Git Tag Analysis: Identifies the latest version tag to align with SemVer practices.
- Dynamic Version Generation: Creates version numbers based on the commit context, suitable for trunk-based development's linear history.
- Initial Project Versioning: Sets a default version (
0.1.0) for new projects, providing a standardized versioning starting point. - JIRA Card ID Integration: Optionally includes JIRA card IDs from commit messages or branch names in the version, enhancing traceability.
- Version Validation: Ensures the generated version adheres to Semantic Versioning 2.0, Docker tag, and OCI tag standards.
| Input | Description | Required | Default |
|---|---|---|---|
major_version |
Override major version (typically sourced from cicd.yaml config.version.major). Must be set together with minor_version. |
No | '' |
minor_version |
Override minor version (typically sourced from cicd.yaml config.version.minor). Must be set together with major_version. |
No | '' |
release_branch |
Branch name that produces a clean SemVer with no postfix. Set this if your trunk is not main. |
No | main |
test_version_tag |
Test-only override for the latest version lookup. Do not set in production. | No | '' |
test_branch_name |
Test-only override for branch name detection. Do not set in production. | No | '' |
| Output | Description |
|---|---|
version |
The SemVer-compatible version string. |
- Ensure your project follows a trunk-based development workflow.
- Check out the repository using
actions/checkout@v3before executing this action.
name: Compute and Use Version
on: [push, pull_request]
jobs:
versioning:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout repository
- name: Compute Version
id: compute_version
uses: ActionsCI/compute-semver@v1.0.2
with:
test_version_tag: '' # Optional for testing purposes
- name: Use Computed Version
run: echo "Computed version: ${{ steps.compute_version.outputs.version }}"Your contributions and suggestions are highly valued. They help refine and enhance "Compute Version," making it more versatile for trunk-based development and SemVer practices.
Encountered an issue or need assistance? Please open an issue in the GitHub repository's issue tracker.
"Compute Version" is released under the MIT License. For more details, see the LICENSE file in the repository.
If "Compute Version" brings value to your workflow, consider supporting its development:
- PayPal: Donate via PayPal.me
- Cryptocurrency: Ethereum Address -
0xbB767477D28560672BE7b2E2270c70F80F9341eE
Your support is greatly appreciated and contributes to ongoing development.