Skip to content

Commit

Permalink
feat: add config command and multiple replacements in patch
Browse files Browse the repository at this point in the history
- New config command to display config
- Info command now excludes environment variables by default
- Each patch can have multiple replacements
- Add all conventional commits to default CommitMessageActions
  • Loading branch information
idc101 committed Jun 8, 2020
1 parent 04e543e commit 280bcec
Show file tree
Hide file tree
Showing 17 changed files with 262 additions and 191 deletions.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@ For more information head to the [project site](https://idc101.github.io/git-mkv
- Branch names
- Manual tagging
- Next version conforms to [Semantic Versioning](https://semver.org/) scheme
- Patch the next version into the build:
- Java
- C#
- Many others, fully configurable
- Tag the current commit with the next version
- Patch the next version into source files using a configurable find and replace system
- Tag the current commit with the next version number

All of this can be configured based on the branch name so release/master branches get different
version numbers to develop or feature branches.
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/master branches get different version numbers to develop or feature branches.

## Installation

Download the binary for your os from the [releases](https://github.com/idc101/git-mkver/releases) page and copy to somewhere on your path.

[Install](https://idc101.github.io/git-mkver/installation) with brew, scoop or simply download the binary for your os
from the [releases](https://github.com/idc101/git-mkver/releases) page and copy somewhere on your path.

## Usage

Expand Down
3 changes: 2 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"
FOR /F %i IN ('git mkver next') DO set VERSION=%i
FOR /F %%i IN ('git mkver next') DO set VERSION=%%i
call sbt assembly
cd target\scala-2.12
call native-image -jar git-mkver-assembly-%VERSION%.jar --no-fallback
del git-mkver.exe
move git-mkver-assembly-%VERSION%.exe git-mkver.exe
PowerShell -Command "Compress-Archive -Path 'git-mkver.exe' -DestinationPath 'git-mkver-windows-amd64-%VERSION%.zip'"
PowerShell -Command "Get-FileHash git-mkver-windows-amd64-%VERSION%.zip | %% Hash"
cd ..\..\
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Dependencies._

ThisBuild / scalaVersion := "2.12.11"
ThisBuild / version := "1.0.0"
ThisBuild / version := "1.1.0"
ThisBuild / organization := "net.cardnell"

lazy val root = (project in file("."))
Expand Down
23 changes: 17 additions & 6 deletions docs/config_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,27 @@ patches: [
"**/Chart.yaml" # Chart.yaml in any subdirectory of the current working directory
"Chart.yaml" # Chart.yaml the current working directory only
]
# search string, using java regular expression syntax (https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html)
find: "appVersion: .*"
# replacement string using substitutions from formats
replace: "appVersion: \"{Version}\""
# list of replacements to apply to files
replacements: [
{
# search string, using java regular expression syntax (https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html)
# find strings can include the special marker `{VersionRegex}` which will be replaced with the regular expression
# for a Semantic Version.
find: "appVersion: {VersionRegex}"
# replacement string using substitutions from formats
replace: "appVersion: \"{Version}\""
}
]
}
{
name: Csproj
filePatterns: ["**/*.csproj"]
find: "<Version>.*</Version>"
replace: "<Version>{Version}</Version>"
replacements: [
{
find: "<Version>.*</Version>"
replace: "<Version>{Version}</Version>"
}
]
}
]
# commitMessageActions configure how different commit messages will increment
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Linux

```bash
curl -L https://github.com/idc101/git-mkver/releases/download/v1.0.0/git-mkver-darwin-amd64-1.0.0.tar.gz | tar xvz
curl -L https://github.com/idc101/git-mkver/releases/download/v1.1.0/git-mkver-darwin-amd64-1.1.0.tar.gz | tar xvz
sudo mv git-mkver /usr/local/bin
```

Expand Down
17 changes: 13 additions & 4 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ $ git mkver tag

The next version number will be determined based on the commit messages since
the last version was tagged. The commit messages that trigger different version
increments are [configurable](config_reference) but by default they are as follows:
increments are [configurable](config_reference) but by default they are based on
the [Conventional Commit](https://www.conventionalcommits.org/) specification
as follows:

- Commits containing the following will increment the _major_ version:
- `major:` or `major(...):`
Expand All @@ -80,6 +82,9 @@ increments are [configurable](config_reference) but by default they are as follo
- `patch:` or `patch(...):`
- `fix:` or `fix(...):`

Other conventional commits such as `build`, `chore`, `docs` will not increment
the version number.

All commit messages since the last tagged message are analyzed and the greatest
version increment is used. For example if one commit is a minor change and one is
a major change then the major version will be incremented.
Expand Down Expand Up @@ -119,7 +124,7 @@ you can use the `patch` command. The files to be patched and the replacements ar
defined in the `mkver.conf` [config](config) file.

For example, suppose you have the version number in a code file:
```
```scala
object VersionInfo {
val version = "1.0.0"
}
Expand All @@ -130,8 +135,12 @@ and you define a patch as follows in your config file:
{
name: Readme
filePatterns: ["version.scala"]
find: "val version = \".*\""
replace: "val version = \"{Next}\""
replacements: [
{
find: "val version = \"{VersionRegex}\""
replace: "val version = \"{Next}\""
}
]
}
```

Expand Down
4 changes: 2 additions & 2 deletions etc/Formula/git-mkver.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class GitMkver < Formula
MKVER_VERSION = "1.0.0".freeze
MKVER_SHA256 = "d1546df319e236d038f7c6b3b88ca155fb882b237011c2cbd7e56e9a16b6ba56".freeze
MKVER_VERSION = "1.1.0".freeze
MKVER_SHA256 = "f69fb9b97f510b05455138fc202b53aa5d3f55af471d995bbe74888aeaea28db".freeze

desc "Installs git-mkver from pre-built binaries"
homepage "https://idc101.github.io/git-mkver/"
Expand Down
6 changes: 3 additions & 3 deletions etc/scoop/git-mkver.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "1.0.0",
"version": "1.1.0",
"description": "Automatic Semantic Versioning for git based software development",
"url": "https://github.com/idc101/git-mkver/releases/download/v1.0.0/git-mkver-windows-amd64-1.0.0.zip",
"hash": "913cd814cf8dd2c5f933f484834c43b0ab62539b4791ce731327e0bb2fb567ac",
"url": "https://github.com/idc101/git-mkver/releases/download/v1.1.0/git-mkver-windows-amd64-1.1.0.zip",
"hash": "3F0E0E2C982A3B7C4C74B5D7CCCF4340FA6DB796337E4613C67EAF01D8B1CF60",
"extract_to": "",
"bin": "git-mkver.exe"
}
2 changes: 1 addition & 1 deletion etc/shell/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
MKVER_VERSION=1.0.0
MKVER_VERSION=1.1.0
curl -L https://github.com/idc101/git-mkver/releases/download/v${MKVER_VERSION}/git-mkver-darwin-amd64-${MKVER_VERSION}.tar.gz -o git-mkver.tar.gz
tar xvzf git-mkver.tar.gz
sudo mv git-mkver /usr/local/bin
Expand Down
29 changes: 25 additions & 4 deletions git-mkver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ defaults {
patches: [
Sbt
Installers
ScalaVersion
]
}
patches: [
{
name: Sbt
filePatterns: ["build.sbt"]
find: "version\\s+:=\\s+\".*\""
replace: "version := \"{Next}\""
replacements: [
{
find: "version\\s+:=\\s+\"{VersionRegex}\""
replace: "version := \"{Next}\""
}
]
}
{
name: Installers
Expand All @@ -20,7 +25,23 @@ patches: [
"etc/scoop/git-mkver.json"
"etc/shell/install.sh"
]
find: "\\d+\\.\\d+\\.\\d+"
replace: "{Version}"
replacements: [
{
find: "{VersionRegex}"
replace: "{Version}"
}
]
}
{
name: ScalaVersion
filePatterns: [
"src/main/scala/net/cardnell/mkver/package.scala"
]
replacements: [
{
find: "val GitMkverVersion = \"{VersionRegex}\""
replace: "val GitMkverVersion = \"{Version}\""
}
]
}
]
Loading

0 comments on commit 280bcec

Please sign in to comment.