Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compute Version GitHub Action

"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.

Trunk-Based Development and SemVer

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)
  • develop
  • main

While other branch names can be used, develop and main are designated for development builds and production builds, respectively.

Features

  • 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.

Inputs

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 ''

Outputs

Output Description
version The SemVer-compatible version string.

Usage in Trunk-Based Development

Pre-requisites

  • Ensure your project follows a trunk-based development workflow.
  • Check out the repository using actions/checkout@v3 before executing this action.

Example Workflow

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 }}"

Contributing

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.

Support and Issues

Encountered an issue or need assistance? Please open an issue in the GitHub repository's issue tracker.

License

"Compute Version" is released under the MIT License. For more details, see the LICENSE file in the repository.

Support This Project

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors