Semantic version generator using git commit keywords and overrides

Semantic version generator

Docker image build. GitHub release (latest by date) codecov

Project created overnight, to prove that management of semantic versioning is NOT painful and do not require arguments and debates within the team. Simple, clean and only thing the project team should need to agree to are the keywords.

How does it work

  • Binary clones the github repository
  • Iterates through the list of commits looking for the keywords specified in config file for additional bumps of versions
  • Returns the semantic version which can be included in the release

Usage

Authentication

If you intend to use this project with remote repositories ( regardless of them being private or public ) you need to authenticate with your repository. To do so you can utilise the following environment variables ( they are NOT github specific, for other providers you can use the password )

export GITHUB_USERNAME=lukaszraczylo
export GITHUB_TOKEN=yourPersonalApiToken

As a binary

You can download latest versions of the binaries from the release page.

Supported OS and architectures: Darwin ARM64/AMD64, Linux ARM64/AMD64, Windows AMD64

bash$ ./semver-gen generate -r https://github.com/nextapps-de/winbox
SEMVER 9.0.10
bash$ ./semver-gen generate -l
SEMVER 5.1.1

Local repository flag -l will always take precedence over remote repository URL

Usage:
  semver-gen generate [flags]
  semver-gen [command]

Available Commands:
  generate    Generates semantic version
  help        Help about any command

Flags:
  -c, --config string       Path to config file (default "semver.yaml")
  -d, --debug               Enable debug mode
  -h, --help                help for semver-gen
  -l, --local               Use local repository
  -r, --repository string   Remote repository URL. (default "https://github.com/lukaszraczylo/simple-gql-client")
  -s, --strict              Strict matching
  -u, --update              Update binary with latest
  -v, --version             Display version

As a github action

jobs:
  prepare:
    name: Preparing build context
    runs-on: ubuntu-latest
    outputs:
      RELEASE_VERSION: ${{ steps.semver.outputs.semantic_version }}
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
        with:
          fetch-depth: '0'
      - name: Semver run
        id: semver
        uses: lukaszraczylo/semver-generator@PLACE_LATEST_TAG_HERE
        # you can also use v1 tag which _should_ automatically upgrade to latest
        # uses: lukaszraczylo/semver-generator@v1
        with:
          config_file: semver.yaml
          # either...
          repository_local: true
          # or...
          repository_url: https://github.com/lukaszraczylo/simple-gql-client
          # when using remote repository, especially with private one:
          github_username: lukaszraczylo
          github_token: MySupeRSecr3tPa$$w0rd
      - name: Semver check
        run: |
          echo "Semantic version detected: ${{ steps.semver.outputs.semantic_version }}"

As a docker container

docker pull ghcr.io/lukaszraczylo/semver-generator:latest

Docker supported architectures: Linux/arm64, Linux/amd64

Calculations example [standard]

  • 0.0.1 - PATCH - starting commit
  • 0.0.2 - PATCH - another commit
  • 0.0.4 - PATCH - another commit with word 'Update' => DOUBLE increment PATCH
  • 0.1.0 - MINOR - after commit with word 'Change' => increment MINOR, reset PATCH
  • 0.1.1 - PATCH - additional commit
  • 1.0.1 - MAJOR - commit with word 'BREAKING' = > INCREMENT MAJOR, reset MINOR
  • 1.0.2 - PATCH - another commit

Calculations example [strict matching]

  • 0.0.1 - PATCH - starting commit
  • 0.0.1 - PATCH - another commit
  • 0.0.1 - PATCH - another commit with word 'Update' => SINGLE increment PATCH
  • 0.1.0 - MINOR - after commit with word 'Change' => increment MINOR, reset PATCH
  • 0.1.0 - PATCH - additional commit
  • 1.0.0 - MAJOR - commit with word 'BREAKING' = > INCREMENT MAJOR, reset MINOR
  • 1.0.0 - PATCH - another commit

Example configuration

version: 1
force:
  major: 1
  minor: 0
  patch: 1
  commit: 69fbe2df696f40281b9104ff073d26186cde1024
wording:
  patch:
    - update
    - initial
  minor:
    - add
    - change
    - improve
  major:
    - breaking
    - the # For testing purposes
  • version: is not respected at the moment, introduced for potential backwards compatibility in future
  • force: sets the "starting" version, you don't need to specify this section as the default is always 0
  • force.commit: allows you to set commit hash from which the calculations should start
  • wording: words the program should look for in the git commits to increment (patch|minor|major)

Good to know

  • Word matching uses fuzzy search AND is case INSENSITIVE
  • I do not recommend using common words ( like "the" from the example configuration )
Comments
  • 'strict' and 'existing' flags not working from config file

    'strict' and 'existing' flags not working from config file

    Hi!

    Let me spend one line making an explicit thank you for sharing your knowledge and time in this project.

    Now, to the issue:

    I was testing your tool to incorporate it into our workflows. I found that the recently added existing: true flag, and also the strict flag don't work from the config file.

    This is my config file:

    version: 1
    force:
      existing: true
      strict: true
    wording:
      patch:
        - update
        - fix
      minor:
        - feature
        - improve
      major:
        - breaking
        - major
      release:
        - release-candidate
        - add-rc
    

    I was originally testing directly from a Github Action:

    name: Testing semver
    
    on:
      push:
        branches:
          - main
    
    jobs:
      prepare:
        name: Preparing build context
        runs-on: ubuntu-latest
        outputs:
          RELEASE_VERSION: ${{ steps.semver.outputs.semantic_version }}
        steps:
          - name: Checkout repo
            uses: actions/checkout@v2
            with:
              fetch-depth: '0'
          - name: Semver run
            id: semver
            uses: lukaszraczylo/semver-generator@v1
            with:
              config_file: semver.yml
              repository_local: true
          - name: Semver check
            run: |
              echo "Semantic version detected: ${{ steps.semver.outputs.semantic_version }}"
    

    The result was that existing tags were not taken into account, and strict mode didn't work either.

    I download the project to test it locally and I realized that from my local computer I'm able to reproduce the same behavior running the binary in this way (semver.yml is the same one I included before):

    ./semver-gen generate -l  -c semver.yml
    SEMVER 0.0.13
    

    But if I run explicitly including the flags the result is the desired one:

    ./semver-gen generate -l -s -e -c semver.yml
    SEMVER 0.1.0
    

    Am I doing something wrong? Otherwise, I hope this requires minimal effort on your side since it's all I need for my workflows right now.

    Thanks again.

  • Patch version being updated instead of minor

    Patch version being updated instead of minor

    During my tests when using the default config.yaml I noticed that minor keywords are acting as they were the patch ones.

    It happened with add and change but NOT with improve.

    config.yaml

    version: 1
    force:
      major: 1
      commit: 4dc131734b6e7504ebd185d70b5777059880ab59
    wording:
      patch:
        - update
        - initial
        - fix
      minor:
        - add
        - change
        - improve
      major:
        - breaking
    

    I got the following

    Initially: 1.0.2
    Breaking commit: 2.0.1
    Change commit: 2.0.2
    Update commit: 2.0.3
    Improve commit: 2.1.1
    Improve commit: 2.2.1
    Add commit: 2.2.2
    
  • Unable to find config file semver.yaml

    Unable to find config file semver.yaml

    Describe the bug If installed using go it doesn't seem to work out of the box.

    Output with debug semver-generator generate -l Unable to find config file semver.yaml

  • More specific name for the default config

    More specific name for the default config

    The default config.yaml is too generic and can be confused with other yaml files in the project. Maybe it would be better to have it more unique default name, like semver.yml, sem.yml or sem-version.yml

  • Using in a github action, but failed with no output

    Using in a github action, but failed with no output

    Describe the bug Tried to use this as part of a github action, but it failed without any output. It is unclear how to get debug output in this format. If it could work as described, this would absolutely fill a need for our project that I otherwise cannot find a plugin working for. If this is an issue with my configuration, please do let me know. I am also unsure if the "build semver-generator@v1" step at the beginning was truly successful or not, as it does have error output despite passing. Any help would be appreciated. image

    Output with debug (could not get debug output, as this is undocumented for github actions)

    Expected behavior Expected action to succeed or show configuration issues.

    Additional context The failed run: https://github.com/HDR-Development/HewDraw-Remix/runs/5252877868?check_suite_focus=true config file at this time: https://github.com/HDR-Development/HewDraw-Remix/blob/8da98b893e92979baebcc26d8e68257cbcfe3a47/.github/workflows/semver_config.yaml the action step: https://github.com/HDR-Development/HewDraw-Remix/blob/8da98b893e92979baebcc26d8e68257cbcfe3a47/.github/workflows/build.yml#L104

  • Add update switch

    Add update switch

    Manually updating the binary, after the "-v" flag was enabled can be troublesome. Add an additional flag which will trigger the update and replace the existing binary with the latest possible version.

  • Add strict matching switch

    Add strict matching switch

    Description:

    Switch should trigger non zero exit if it fails to match any specified keywords for all the levels of version.

    This should help teams operating on strict rules and naming conventions to avoid generation of unfinished work.

  • Force parameter not working

    Force parameter not working

    ❯ semver-gen -v semver-gen 1.0.32

    For

    force:
      major: 0
      minor: 0
      patch: 0
    
    ❯ semver-gen generate -c config.yml -r https://github.com/hipertracker/words_extractor
    SEMVER 1.4.12
    

    which is correct, but for

    force:
      major: 1
      minor: 1
      patch: 1
    
    ❯ semver-gen generate -c config.yml -r https://github.com/hipertracker/words_extractor
    SEMVER 1.4.12
    

    this is confusing. Should not force enforce the given 1.1.1 version incremented by all commits?

  • Major version incremented for no new commit

    Major version incremented for no new commit

    It increments a major number by 1 even when no new code commit was sent.

    E.g for config.yml

    version: 1
    force:
      major: 1
      minor: 4
      patch: 12
      commit: 1c8e2eb628bc7c82f914b14b1163710be24ed510
    wording:
      patch:
        - update
        - initial
      minor:
        - add
        - change
        - improve
      major:
        - breaking
        - the # For testing purposes
    
    ❯ semver-gen generate -c config.yml -r https://github.com/hipertracker/words_extractor
    SEMVER 2.4.12
    

    It should be 1.4.12

  • Access to private repos

    Access to private repos

    If I am not wrong, currently, the application can connect to only public repositories. It needs an option (or ENV variable) for connecting to private repositories.

  • The specific commit as the starting point

    The specific commit as the starting point

    The application should be able to start the calculations from the (optionally) defined commit instead form the first one (default). This should help to calculate the proper SEM numbers for the legacy code.

    Eg.

    force:
      major: 7
      minor: 4
      patch: 5
      commit: 1c8e2eb628bc7c82f914b14b1163710be24ed510
    
  • Allow 'blacklisting' terms / limiting number of hits per commit

    Allow 'blacklisting' terms / limiting number of hits per commit

    Hello,

    I am trying to set up this tool for a project because of its simplicity. However, I could'nt figure out if there was a way to blacklist terms.

    For example, I wanted to have something such as this:

      minor:
        - "feature:"
    

    However, when I want to add features to the project, I name my branch feature/xxxx and then merge it into develop, which will trigger the version bump, in addition to the commits. Even worse, I am using gitlab merge requests feature and the merge commits often contain text from previous commits. This results in even the smallest changes bumping the version by a disproportionate amout every time.

    This is making the tool close to unusable for me and I think this is a quite common workflow.

    What do you think ? What is the expected workflow ?

Git-auto-push - Auto commit and push to github repositories

Auto commit and push to github repositories. How to use git clone https://github

Dec 19, 2022
A distributed append only commit log used for quick writes and reads to any scale
A distributed append only commit log used for quick writes and reads to any scale

Maestro-DB A distributed append only commit log used for quick writes and reads to any scale Part 1 - Scaffolding Part-1 Notes Going to start off with

Nov 28, 2021
github-actions-merger is github actions that merges pull request with commit message including pull request labels.

github-actions-merger github-actions-merger is github actions that merges pull request with commit message including pull request labels. Usage Write

Dec 7, 2022
Git with a cup of tea, painless self-hosted git service
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023
Watchtower for Git: automatically keep local Git repositories up to date with their remotes

CrowsNest Watchtower for Git: automatically keep local Git repositories up to date with their remotes. Configuration Flags --run-once or -r: Normally

Oct 30, 2022
Simple example using Git actions + Argo CD + K8S + Docker and GO lang

CICD-simple_example Simple example using Git actions + Argo CD + K8S + Docker and GO lang Intro Pre reqs Have an ArgoCD account and Installed. Docker

Oct 28, 2021
A simple program to automatically backup a database using git. Err handling by Sentry, Reporting by Betteruptime. Made with 🩸 , 😓 & 😭

backup What is this? A Simple program to automatically backup a database using git. Err handling by Sentry, Uses heartbeats by Betteruptime Made with

Nov 4, 2022
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI

A Simple and Comprehensive Vulnerability Scanner for Containers and other Artifacts, Suitable for CI. Table of Contents Abstract Features Installation

Jan 1, 2023
The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism
The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism

___ werf is an Open Source CLI tool written in Go, designed to simplify and speed up the delivery of applications. To use it, you need to describe the

Jan 4, 2023
Go version manager. Super simple tool to install and manage Go versions. Install go without root. Gobrew doesn't require shell rehash.

gobrew Go version manager Install or update With curl $ curl -sLk https://git.io/gobrew | sh - or with go $ go get -u github.com/kevincobain2000/gobre

Jan 5, 2023
A golang package for comparing and working with k0s version numbers

version A go-language package for managing k0s version numbers. It is based on hashicorp/go-version but adds sorting and comparison capabilities for t

Feb 7, 2022
ArgoCD is widely used for enabling CD GitOps. ArgoCD internally builds manifest from source data in Git repository, and auto-sync it with target clusters.
ArgoCD is widely used for enabling CD GitOps. ArgoCD internally builds manifest from source data in Git repository, and auto-sync it with target clusters.

ArgoCD Interlace ArgoCD is widely used for enabling CD GitOps. ArgoCD internally builds manifest from source data in Git repository, and auto-sync it

Dec 14, 2022
"go build" wrapper to add version info to Golang applications

govvv The simple Go binary versioning tool that wraps the go build command. Stop worrying about -ldflags and go get github.com/ahmetb/govvv now. Build

Dec 16, 2022
Go Version Manager

gvm By Josh Bussdieker (jbuss, jaja, jbussdieker) while working at Moovweb Currently lovingly maintained by Benjamin Knigge Pull requests and other an

Jan 2, 2023
A live-updating version of the UNIX wc command.
A live-updating version of the UNIX wc command.

lwc A live-updating version of the UNIX wc command. Installation You can get a prebuilt binary for every major platform from the Releases page. Just e

Jul 26, 2022
"go build" wrapper to add version info to Golang applications

govvv The simple Go binary versioning tool that wraps the go build command. Stop worrying about -ldflags and go get github.com/ahmetb/govvv now. Build

Dec 16, 2022
A tool to restart a Docker container with a newer version of the image

repull A tool to restart a Docker container with a newer version of an image used by the container Often you may need to pull a newer version of an im

Nov 28, 2022
Mutagen Compose is a modified version of Docker Compose that offers automated integration with Mutagen.

Mutagen Compose Mutagen Compose is a (minimally) modified version of Docker Compose that offers automated integration with Mutagen. This allows you to

Dec 22, 2022