Giter Club home page Giter Club logo

git-mkver's Introduction

git-mkver

Automatic Semantic Versioning for git based software development.

For more information head to the project site.

Features

  • Determine next version based on:
  • Next version conforms to Semantic Versioning scheme
  • Patch the next version into source files using a configurable find and replace system
  • Tag the current commit with the next version number

Works out of the box with trunk based development, GitFlow and GithubFlow. Alternatively all of this can be configured based on the branch name so release/main branches get different version numbers to develop or feature branches.

Installation

Install with brew, scoop or simply download the binary for your os from the releases page and copy somewhere on your path.

Usage

Start by using Conventional Commits to indicate whether the commits contain major, minor or patch level changes.

$ git commit -m "feat: added a new feature (this will increment the minor version)"

Then call git mkver next and it will tell you the next version of the software should be if you publish now.

$ git mkver next
v0.4.0

Tagging

If you would like to publish a version, git-mkver can tag the current commit.

$ git mkver tag

This will apply an annotated tag from the next command to the current commit.

Patching versions in files

If you would like to patch version numbers in files prior to building and tagging then you can use the patch command. The files to be patched and the replacements are defined in the mkver.conf config file. A large number of standard patches come pre-defined.

$ git mkver patch

git-mkver's People

Contributors

balaji-dutt avatar cperezabo avatar dependabot[bot] avatar idc101 avatar jbergler avatar nickajacks1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

git-mkver's Issues

Sccop install for 1.3.0 failed (hash doesn't match) [Note: 1.2.2 works]

scoop install https://raw.githubusercontent.com/idc101/git-mkver/v1.3.0/etc/scoop/git-mkver.json

Installing 'git-mkver' (1.3.0) [64bit] from 'https://raw.githubusercontent.com/idc101/git-mkver/v1.3.0/etc/scoop/git-mkver.json'
git-mkver-windows-amd64-1.3.0.zip (7.3 MB) [=======================================================================================================================================================================] 100%
Checking hash of git-mkver-windows-amd64-1.3.0.zip ... ERROR Hash check failed!
App:         git-mkver
URL:         https://github.com/idc101/git-mkver/releases/download/v1.3.0/git-mkver-windows-amd64-1.3.0.zip
First bytes: 50 4B 03 04 14 00 08 00
Expected:    63ad6fd8ebb1e27f2cb81b7c162cb2d0a66809c4c693402d2ec9f1496c9a2636
Actual:      93e15413a025a1b8be939cf4dacd1bc3df75ee55b33a2b936eece3e3813840df

Please try again or create a new issue by using the following link and paste your console output:
https:////

macOS homebrew installation instructions out of date

Hi,

Homebrew does not allow to install with the provided instructions anymore:

brew extract or brew create and brew tap-new to create a formula file in a tap on GitHub instead.: Invalid usage: Non-checksummed download of git-mkver formula file from an arbitrary URL is unsupported! (UsageError)

A real homebrew tap is required.

Java-friendly library

Hi,

Would it be possible to have a Java-friendly library packaging of your nice tool?

I recently discovered maven (and gradle) can have their artifact versions configured at run-time from git history (https://github.com/qoomon/maven-git-versioning-extension or https://github.com/jgitver/jgitver-maven-plugin).

I also discovered conventional-commits and your tool based on conventional-commits to compute the version.

I would like to combine both to benefit from conventional-commits computed version in my maven projects.
But I don't know Scala, only Java, hence the question about a Java-friendly library, which I could try and use in a maven integration.

Access to environment variables

Summary

An environment variable defined is not accessible through the env.XXX interface.

Code to reproduce

$ mkdir foo
$ cd foo
$ printf 'branches: [\n  {\n    pattern: "master"\n    includeBuildMetaData: false\n    tag: true\n    formats: [\n      { name: Docker, format: "{Version}" }\n      { name: Test, format: "{Version}-{env.BUILD_NUMBER}" }\n    ]\n  }\n]' > mkver.conf
$ touch test
$ git add test
$ git commit -m "chore: Initial commit"
$ BUILD_NUMBER=1
$ git mkver next --format '{Test}'

Expected output

0.1.0-1

Actual output

0.1.0-{env.BUILD_NUMBER}

Question regarding feature branches

Hi! Thanks for the great tool! When I use it in ci/cd on feature branches, also when checking out the master branch, mkver next would suggest e.g. 0.1.0+feature-880285.170e24c as I start a pipeline from branch feature/880285.
Before executing git-mkver, I switch to master. (git checkout -b master)
Is it possible to have git-mkver suggest a "next" tag based upon the checked out branch?
Thanks! Thomas

Allowing `git-mkver` to keep predicted versions below `1.0.0` for applications in beta

Background

I'm developing an SDK for the wind turbine industry which is currently in beta. I've also created a package facilitating continuous deployment based on conventional commits that uses git-mkver to warn pull request authors if the expected semantic version is out of line with the package version stated in e.g. setup.py.

I'd also like to quickly say I love git-mkver! It's a really useful tool for automating releases and it does almost everything I need ๐Ÿ’š

Problem statement

As we're in beta, we want to keep the version below 1.0.0 until we have a stable API. The only way I can do that currently without the warning (mentioned above) triggering is by not including BREAKING CHANGE in commit messages because the commit message action for breaking changes is hardwired in the mkver.conf file parser. I can add extra actions to the commitMessageActions of a mkver.conf file but I can't override any of the default ones.

Feature request

To be able to specify exactly what triggers a major version (or any other type of version) increase so beta packages can stay under version 1.0.0. Until today, I thought that this mkver.conf did this.

Proposed solution

Allow defaultCommitMessageActions to be disabled with a flag in mkver.conf so only the commitMessageActions a developer specifies in mkver.conf are used.

Latest release has broken everything ๐Ÿ˜ง

Hi Iain, I think you should take more care about the decisions you make, or at least to communicate them with time to the people working with git-mkver.

setup-git-mkver is broken at the moment, as well as every pipeline using it because v1.3.0 changed the name format of the releases.

The workaround is to stick to v1.2.2, but that implies to update all the pipelines that are using latest

I'm working to support the new assets name format, but I am doing reverse engineering to the universal package because there is no documentation about how to making it run in Windows globally through git mkver, the /etc/scoop/git-mkver.json is outdated as well as /etc/shell/install.sh so I'm blind.

As for Linux, the new x86_64 binary is failing with the following error in the same ubuntu-20.04 runner in which git-mkver v1.2.2 used to run ok.

/usr/local/bin/git-mkver: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /usr/local/bin/git-mkver)
/usr/local/bin/git-mkver: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /usr/local/bin/git-mkver)

v1.2.0 no windows binary

There does not seem to be a windows binary for v1.2.0. a failed scoop install brought me here.

Bang does not increment major version

From Conventional Commits v1.0.0:

If included in the type/scope prefix, breaking changes MUST be indicated by a ! immediately before the :.

e.g.: fix(comp)!: Some damned foolish thing

I would guess another entry is needed here:

val defaultCommitMessageActions: List[CommitMessageAction] = List(

...or this should be something like BREAKING CHANGE|.+(\\(.+\\))?!: to prevent multiple increments if both are used:

CommitMessageAction("BREAKING CHANGE", IncrementAction.IncrementMajor),

I don't feel confident making this change myself.

missing Apple Silicon vor build of 1.3.0

The release 1.2.2 contains a build for Apple Silicon (git-mkver-darwin-arm64-1.2.2.tar.gz).
Any technical reasons why 1.3.0 is not build for Apple Silicon and provided in the releases?

Git errors are silently discarded

Hi there, first of all thank you, I found this tool recently and it's really great. Thank you for sharing your work.

I noticed while trying to integrate this with a CI pipeline that git mkver tag wasn't doing anything, but seemed to be succeeding.

After a bunch of debugging I discovered that the git user/email hadn't been set and this line was failing:
https://github.com/idc101/git-mkver/blob/master/src/main/scala/net/cardnell/mkver/Git.scala#L43

I hope to be able to open a PR for this, but in the event I don't find the time I wanted to record the issue and suggest some improved error handling / logging on failures.

"next-version" as a Commit Message Action

The implementation for next-version is currently hard coded, but it would be nice to be able to gain the flexibility provided by the configuration.
Using GitFlow as an example, one may wish to automatically set the version based on the merge of a branch to master.

commit 8b0d111883980b033aaae7158552712ebf15746f (origin/main, main)
Merge: 476e967 8775451
Author: Susan Programmer <[email protected]>
Date:   Mon Oct 17 23:38:49 2022 +0000

    Merged in release/v1.4.5 (pull request #7)

A potential configuration to allow automatically setting the version:

commitMessageActions: [
  {
    pattern: "Merged in release/v(\\d+\\.\\d+\\.\\d+)"
    action: SetVersion
  }
]

It would be possible to use a regex capture to extract the version from the commit.

Releases not working inside alpine image

Hi,

today I tried to use git-mkver inside an alpine container (exactly with docker:24.0.5) and got this error message:

bash: /usr/local/bin/git-mkver: cannot execute: required file not found

The error is caused by alpines dependency on musl instead of libc. On alpine you need to add the apk add gcompat package for git-mkver to run. Maybe you can add this in the docs.

Installation

docker run -it --rm alpine sh

apk add --no-cache bash git wget
wget -O git-mkver.tar.gz https://github.com/idc101/git-mkver/releases/download/v1.3.0/git-mkver-linux-x86_64-1.3.0.tar.gz
tar -xvf git-mkver.tar.gz
mv git-mkver /usr/local/bin/

Flag --pre-release don't work with "patch" argument

Hi.

If i run git-mkver next --pre-release or git-mkver tag --pre-release it's work correctly.
But if i run git-mkver patch --pre-release nothing happens and the version in the configuration files does not change.

PS
Maybe I'm doing something wrong?

Automated Releases

This project could benefit from automated releases to ensure consistency in released artifacts.

To be completely transparent, I'm asking because I would like to add git-mkver to Hermit which has a soft requirement for providing static Linux amd64 and Darwin amd64/arm64 builds. I'm hoping #39 makes this a just little less difficult.

PreReleaseNumber not set

Summary

The variable PreReleaseNumber seems to be not set. However, git mkver tag -p creates a correctly formatted tag.

Code to reproduce

$ mkdir foo
$ cd foo
$ touch test
$ git add test
$ git commit -m "chore: Initial commit"
$ git mkver info

Expected output

Branch=master
BuildMetaData=master.c88993e
CommitsSinceTag=1
FullHash=c88993ee096d34c5c9f49c6197747df343888539
Major=0
Minor=1
Next=0.1.0
Patch=0
PreRelease=RC
PreReleaseNumber=1
ShortHash=c88993e
Tag=v0.1.0
Tag?=true
TagMessage=release v0.1.0
TagPrefix=v
Tagged?=false
Version=0.1.0
VersionBuildMetaData=0.1.0+master.c88993e
VersionPreRelease=0.1.0-RC1
VersionPreReleaseBuildMetaData=0.1.0-RC1+master.c88993e
dd=02
mm=02
yyyy=2021

Actual output

Branch=master
BuildMetaData=master.c88993e
CommitsSinceTag=1
FullHash=c88993ee096d34c5c9f49c6197747df343888539
Major=0
Minor=1
Next=0.1.0
Patch=0
PreRelease=RC
PreReleaseNumber=
ShortHash=c88993e
Tag=v0.1.0
Tag?=true
TagMessage=release v0.1.0
TagPrefix=v
Tagged?=false
Version=0.1.0
VersionBuildMetaData=0.1.0+master.c88993e
VersionPreRelease=0.1.0-RC
VersionPreReleaseBuildMetaData=0.1.0-RC+master.c88993e
dd=02
mm=02
yyyy=2021

Running mkver in puppet-dev-tools along with pdk

git mkver next is not incrementing the version. We are using the base image to run the jenkins pipeline job.

  1. First we need to increment the puppet module version using git-mkver next
  2. Using that version we need to build the module using pdk build so we ahve used pdk based image.

I believe image got some problem with git-mkver.

git mkver tag silently fails if the commit is already tagged with a prerelease

I made a clean git repo, added a file and a commit with "feat:" in the message.
Running git mkver tag --prerelease yields v0.1.0-pre1 as expected.

However, running git mkver tag immediately afterward silently fails. It simply does not create the tag v0.1.0, which is what I would expect. And no error message either.

If I create a new commit, it works fine again. Is this a scenario that git-mkver supports?

GitHub Action

Hi! I've tried to contact you but haven't found a way, so I write here to tell you that I've built this GitHub Action based on this project. git-mkver is amazing!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.