Skip to content

Commit 280bcec

Browse files
committed
feat: add config command and multiple replacements in patch
- 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
1 parent 04e543e commit 280bcec

File tree

17 files changed

+262
-191
lines changed

17 files changed

+262
-191
lines changed

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ For more information head to the [project site](https://idc101.github.io/git-mkv
1212
- Branch names
1313
- Manual tagging
1414
- Next version conforms to [Semantic Versioning](https://semver.org/) scheme
15-
- Patch the next version into the build:
16-
- Java
17-
- C#
18-
- Many others, fully configurable
19-
- Tag the current commit with the next version
15+
- Patch the next version into source files using a configurable find and replace system
16+
- Tag the current commit with the next version number
2017

21-
All of this can be configured based on the branch name so release/master branches get different
22-
version numbers to develop or feature branches.
18+
Works out of the box with trunk based development, GitFlow and GithubFlow. Alternatively all of this can be configured
19+
based on the branch name so release/master branches get different version numbers to develop or feature branches.
2320

2421
## Installation
2522

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

2926
## Usage
3027

build.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"
2-
FOR /F %i IN ('git mkver next') DO set VERSION=%i
2+
FOR /F %%i IN ('git mkver next') DO set VERSION=%%i
33
call sbt assembly
44
cd target\scala-2.12
55
call native-image -jar git-mkver-assembly-%VERSION%.jar --no-fallback
66
del git-mkver.exe
77
move git-mkver-assembly-%VERSION%.exe git-mkver.exe
88
PowerShell -Command "Compress-Archive -Path 'git-mkver.exe' -DestinationPath 'git-mkver-windows-amd64-%VERSION%.zip'"
9+
PowerShell -Command "Get-FileHash git-mkver-windows-amd64-%VERSION%.zip | %% Hash"
910
cd ..\..\

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Dependencies._
22

33
ThisBuild / scalaVersion := "2.12.11"
4-
ThisBuild / version := "1.0.0"
4+
ThisBuild / version := "1.1.0"
55
ThisBuild / organization := "net.cardnell"
66

77
lazy val root = (project in file("."))

docs/config_reference.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,27 @@ patches: [
8989
"**/Chart.yaml" # Chart.yaml in any subdirectory of the current working directory
9090
"Chart.yaml" # Chart.yaml the current working directory only
9191
]
92-
# search string, using java regular expression syntax (https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html)
93-
find: "appVersion: .*"
94-
# replacement string using substitutions from formats
95-
replace: "appVersion: \"{Version}\""
92+
# list of replacements to apply to files
93+
replacements: [
94+
{
95+
# search string, using java regular expression syntax (https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html)
96+
# find strings can include the special marker `{VersionRegex}` which will be replaced with the regular expression
97+
# for a Semantic Version.
98+
find: "appVersion: {VersionRegex}"
99+
# replacement string using substitutions from formats
100+
replace: "appVersion: \"{Version}\""
101+
}
102+
]
96103
}
97104
{
98105
name: Csproj
99106
filePatterns: ["**/*.csproj"]
100-
find: "<Version>.*</Version>"
101-
replace: "<Version>{Version}</Version>"
107+
replacements: [
108+
{
109+
find: "<Version>.*</Version>"
110+
replace: "<Version>{Version}</Version>"
111+
}
112+
]
102113
}
103114
]
104115
# commitMessageActions configure how different commit messages will increment

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Linux
44

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

docs/usage.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ $ git mkver tag
6868

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

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

85+
Other conventional commits such as `build`, `chore`, `docs` will not increment
86+
the version number.
87+
8388
All commit messages since the last tagged message are analyzed and the greatest
8489
version increment is used. For example if one commit is a minor change and one is
8590
a major change then the major version will be incremented.
@@ -119,7 +124,7 @@ you can use the `patch` command. The files to be patched and the replacements ar
119124
defined in the `mkver.conf` [config](config) file.
120125

121126
For example, suppose you have the version number in a code file:
122-
```
127+
```scala
123128
object VersionInfo {
124129
val version = "1.0.0"
125130
}
@@ -130,8 +135,12 @@ and you define a patch as follows in your config file:
130135
{
131136
name: Readme
132137
filePatterns: ["version.scala"]
133-
find: "val version = \".*\""
134-
replace: "val version = \"{Next}\""
138+
replacements: [
139+
{
140+
find: "val version = \"{VersionRegex}\""
141+
replace: "val version = \"{Next}\""
142+
}
143+
]
135144
}
136145
```
137146

etc/Formula/git-mkver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class GitMkver < Formula
2-
MKVER_VERSION = "1.0.0".freeze
3-
MKVER_SHA256 = "d1546df319e236d038f7c6b3b88ca155fb882b237011c2cbd7e56e9a16b6ba56".freeze
2+
MKVER_VERSION = "1.1.0".freeze
3+
MKVER_SHA256 = "f69fb9b97f510b05455138fc202b53aa5d3f55af471d995bbe74888aeaea28db".freeze
44

55
desc "Installs git-mkver from pre-built binaries"
66
homepage "https://idc101.github.io/git-mkver/"

etc/scoop/git-mkver.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"version": "1.0.0",
2+
"version": "1.1.0",
33
"description": "Automatic Semantic Versioning for git based software development",
4-
"url": "https://github.com/idc101/git-mkver/releases/download/v1.0.0/git-mkver-windows-amd64-1.0.0.zip",
5-
"hash": "913cd814cf8dd2c5f933f484834c43b0ab62539b4791ce731327e0bb2fb567ac",
4+
"url": "https://github.com/idc101/git-mkver/releases/download/v1.1.0/git-mkver-windows-amd64-1.1.0.zip",
5+
"hash": "3F0E0E2C982A3B7C4C74B5D7CCCF4340FA6DB796337E4613C67EAF01D8B1CF60",
66
"extract_to": "",
77
"bin": "git-mkver.exe"
88
}

etc/shell/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#/bin/bash
2-
MKVER_VERSION=1.0.0
2+
MKVER_VERSION=1.1.0
33
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
44
tar xvzf git-mkver.tar.gz
55
sudo mv git-mkver /usr/local/bin

git-mkver.conf

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ defaults {
33
patches: [
44
Sbt
55
Installers
6+
ScalaVersion
67
]
78
}
89
patches: [
910
{
1011
name: Sbt
1112
filePatterns: ["build.sbt"]
12-
find: "version\\s+:=\\s+\".*\""
13-
replace: "version := \"{Next}\""
13+
replacements: [
14+
{
15+
find: "version\\s+:=\\s+\"{VersionRegex}\""
16+
replace: "version := \"{Next}\""
17+
}
18+
]
1419
}
1520
{
1621
name: Installers
@@ -20,7 +25,23 @@ patches: [
2025
"etc/scoop/git-mkver.json"
2126
"etc/shell/install.sh"
2227
]
23-
find: "\\d+\\.\\d+\\.\\d+"
24-
replace: "{Version}"
28+
replacements: [
29+
{
30+
find: "{VersionRegex}"
31+
replace: "{Version}"
32+
}
33+
]
34+
}
35+
{
36+
name: ScalaVersion
37+
filePatterns: [
38+
"src/main/scala/net/cardnell/mkver/package.scala"
39+
]
40+
replacements: [
41+
{
42+
find: "val GitMkverVersion = \"{VersionRegex}\""
43+
replace: "val GitMkverVersion = \"{Version}\""
44+
}
45+
]
2546
}
2647
]

0 commit comments

Comments
 (0)