Skip to content

Commit 76ac5bd

Browse files
committed
docs: add installers and instructions
1 parent 9879740 commit 76ac5bd

File tree

14 files changed

+129
-14
lines changed

14 files changed

+129
-14
lines changed

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 := "0.6.0"
4+
ThisBuild / version := "0.5.1"
55
ThisBuild / organization := "net.cardnell"
66

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

build.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,43 @@ version=`git mkver next`
88
sbt assembly
99

1010
# Mac
11-
if [[ "$(uname)" == "Darwin "]]
11+
if [[ "$(uname)" == "Darwin" ]]
1212
then
1313
pushd target
1414
native-image -H:IncludeResources='.*conf$' --no-fallback -jar scala-2.12/git-mkver-assembly-$version.jar
1515
mv git-mkver-assembly-$version git-mkver-darwin-amd64-$version
16+
cp git-mkver-darwin-amd64-$version git-mkver
17+
chmod +x git-mkver
18+
tar -cvzf git-mkver-darwin-amd64-$version.tar.gz git-mkver
19+
rm git-mkver
1620
popd
1721

1822
# Linux
1923
docker run -v $(pwd):/workspace -it git-mkver \
2024
/bin/bash -c "cd /workspace/target; native-image -H:IncludeResources='.*conf$' --no-fallback -jar scala-2.12/git-mkver-assembly-$version.jar; mv git-mkver-assembly-$version git-mkver-linux-amd64-$version"
25+
26+
pushd target
27+
cp git-mkver-linux-amd64-$version git-mkver
28+
chmod +x git-mkver
29+
tar -cvzf git-mkver-linux-amd64-$version.tar.gz git-mkver
30+
rm git-mkver
31+
popd
32+
33+
DARWIN_SHA256=$(openssl dgst -sha256 target/git-mkver-darwin-amd64-$version.tar.gz | cut -f2 -d' ')
34+
LINUX_SHA256=$(openssl dgst -sha256 target/git-mkver-linux-amd64-$version.tar.gz | cut -f2 -d' ')
35+
36+
sed -i '' -e "s/MKVER_SHA256 = \".*\".freeze/MKVER_SHA256 = \"$DARWIN_SHA256\".freeze/g" etc/Formula/git-mkver.rb
2137
fi
2238

2339
# Linux
24-
if [[ "$(uname)" == "Linux "]]
40+
if [[ "$(uname)" == "Linux" ]]
2541
then
2642
pushd target
2743
native-image -H:IncludeResources='.*conf$' --no-fallback -jar scala-2.12/git-mkver-assembly-$version.jar
2844
mv git-mkver-assembly-$version git-mkver-linux-amd64-$version
45+
cp git-mkver-linux-amd64-$version git-mkver
46+
chmod +x git-mkver
47+
tar -cvzf git-mkver-linux-amd64-$version.tar.gz git-mkver
48+
rm git-mkver
2949
popd
3050
fi

docs/_includes/navbar.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<h2><a href="/">Home</a></h2>
44
<h2><a href="installation">Installation</a></h2>
55
<h2><a href="usage">Usage</a></h2>
6-
<h2><a href="common_patterns">Common Patterns</a></h2>
76
<h2><a href="config_reference">Config Reference</a></h2>
7+
<h2><a href="config_examples">Config Examples</a></h2>
8+
<h2><a href="branching_models">Branching Models</a></h2>
89
<h2><a href="formats">Version Formatting</a></h2>
910
</nav>
1011
</div>

docs/common_patterns.md renamed to docs/branching_models.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Usage Patterns
1+
# Branching Models
22

33
Below are some popular git branching development models and how to configure them with git-mkver:
44
- master (aka trunk) based development
@@ -29,6 +29,8 @@ The build script run by the build server would look something like:
2929

3030
```bash
3131
nextVer=$(git mkver next)
32+
# patch the version number into files as needed
33+
git mkver patch
3234
# build software ...
3335
# If successful:
3436
git mkver tag

docs/config_examples.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Config Examples
2+
3+
Below are some examples of common configuration.
4+
5+
## Patching README.md
6+
7+
I would like to update my README.md and others docs with the latest version number.
8+
9+
```hocon
10+
defaults {
11+
patches: [
12+
Docs
13+
]
14+
}
15+
patches: [
16+
{
17+
name: Docs
18+
filePatterns: [
19+
"README.md"
20+
"docs/installation.md"
21+
]
22+
find: "\\d+\\.\\d+\\.\\d+"
23+
replace: "{Next}"
24+
}
25+
]
26+
```
27+
28+
# I would like a different version format for docker tags
29+
30+
Docker does not support `+` symbols from semantics versions. Create a
31+
format for Docker tags. Additionally `master` branch should be a Version
32+
only while other branches should include build metadata.

docs/formats.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ For example git is happy with the SemVer standard for tagging but docker does no
77

88
All replacements in format strings start with `{` and end with `}`. They are recursively replaced so that one may refer to another.
99

10-
## Examples
11-
12-
13-
1410
## SemVer Formats
1511

1612
The following built in formats conform to the SemVer spec. They cannot be overriden.
@@ -22,7 +18,6 @@ The following built in formats conform to the SemVer spec. They cannot be overri
2218
| `VersionBuildMetaData` | `{Version}+{BuildMetaData}` |
2319
| `VersionPreReleaseBuildMetaData` | `{Version}-{PreRelease}+{BuildMetaData}` |
2420

25-
2621
## Built-in Formats
2722

2823
| Format Token | Substitution |
@@ -49,4 +44,4 @@ The following built in formats conform to the SemVer spec. They cannot be overri
4944

5045
All environment variables are available under a set of formats prefixed with `env.`.
5146
For example `{env.BUILD_NUMBER}` would get the `BUILD_NUMBER` environment variable.
52-
This is most useful for getting information from build systems.
47+
This is most useful for getting information from build systems.

docs/installation.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Installation
22

3+
## Linux
4+
5+
```bash
6+
curl -L https://github.com/idc101/git-mkver/releases/download/v0.5.1/git-mkver-darwin-amd64-0.5.1.tar.gz | tar xvz
7+
sudo mv git-mkver /usr/local/bin
8+
```
9+
10+
## Mac OS
11+
12+
Install with [Homebrew](https://brew.sh):
13+
14+
```bash
15+
brew install https://raw.githubusercontent.com/idc101/git-mkver/master/etc/Formula/git-mkver.rb
16+
```
17+
18+
## Windows
19+
20+
Install with [scoop](https://scoop.sh):
21+
22+
```cmd
23+
scoop install https://raw.githubusercontent.com/idc101/git-mkver/master/etc/Formula/git-mkver.rb
24+
```
25+
26+
## Manual
27+
328
1. Download the binary for your os from the [releases](https://github.com/idc101/git-mkver/releases) page.
429
2. Move it to a directory on your path
530

docs/usage.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ This will apply an annotated tag from the `next` command to the current commit.
4747

4848
If you would like to patch version numbers in files prior to building and tagging then
4949
you can use the `patch` command. The files to be patched and the replacements are
50-
defined in the `mkver.yaml` config file. A large number of standard patches come
51-
pre-defined.
50+
defined in the `mkver.conf` [config](config) file.
5251

5352
```bash
5453
$ git mkver patch

etc/Formula/git-mkver.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class GitMkver < Formula
2+
MKVER_VERSION = "0.5.1".freeze
3+
MKVER_SHA256 = "60b12160b0754e5e9d0b631ae0b8537d6aca33a77e6aff240b049c0dac17dbaf".freeze
4+
5+
desc "Installs git-mkver from pre-built binaries"
6+
homepage "https://idc101.github.io/git-mkver/"
7+
url "https://github.com/idc101/git-mkver/releases/download/v#{MKVER_VERSION}/git-mkver-darwin-amd64-#{MKVER_VERSION}.tar.gz"
8+
version MKVER_VERSION
9+
sha256 MKVER_SHA256
10+
11+
def install
12+
bin.install 'git-mkver'
13+
end
14+
end

etc/scoop/git-mkver.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": "0.5.1",
3+
"description": "Automatic Semantic Versioning for git based software development",
4+
"url": "https://github.com/idc101/git-mkver/releases/download/v0.5.1/git-mkver-windows-amd64-0.5.1.zip",
5+
"extract_dir": "git-mkver",
6+
"bin": "git-mkver.exe"
7+
}

etc/shell/install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#/bin/bash
2+
MKVER_VERSION=0.5.1
3+
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
4+
tar xvzf git-mkver.tar.gz
5+
sudo mv git-mkver /usr/local/bin
6+
rm git-mkver.tar.gz

mkver.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
defaults {
33
patches: [
44
Sbt
5+
Installers
56
]
67
}
78
patches: [
@@ -11,4 +12,15 @@ patches: [
1112
find: "version\\s+:=\\s+\".*\""
1213
replace: "version := \"{Next}\""
1314
}
15+
{
16+
name: Installers
17+
filePatterns: [
18+
"docs/installation.md"
19+
"etc/Formula/git-mkver.rb"
20+
"etc/scoop/git-mkver.json"
21+
"etc/shell/install.sh"
22+
]
23+
find: "\\d+\\.\\d+\\.\\d+"
24+
replace: "{Next}"
25+
}
1426
]

src/main/scala/net/cardnell/mkver/CommandLineArgs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object CommandLineArgs {
4141
val commandLineOpts: Opts[CommandLineOpts] = (configFile, commands).mapN(CommandLineOpts.apply)
4242

4343
val mkverCommand: Command[CommandLineOpts] = Command(
44-
name = "git-mkver",
44+
name = s"git-mkver - v${GitMkverVersion}",
4545
header = "Uses git tags, branch names and commit messages to determine the next version of the software to release"
4646
) {
4747
commandLineOpts

src/main/scala/net/cardnell/mkver/package.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ import zio.Has
44

55
package object mkver {
66
type Git = Has[Git.Service]
7+
8+
val GitMkverVersion = "0.5.1"
79
}

0 commit comments

Comments
 (0)