Skip to content

Commit

Permalink
Executable MVP
Browse files Browse the repository at this point in the history
  • Loading branch information
René Galle committed Apr 2, 2020
1 parent 13654b4 commit 08ef9cd
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func Build() error {
return sh.RunV("go", "build", "-o", "build/verit", "cmd/verit.go")
return sh.RunV("go", "build", "-o", "build/verit", "main.go")
}

func Test() error {
Expand Down
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@


# VerIt

**work in progress**

## Usage
```
verit <current-version> <pattern>
<current-version>: SemVer denoting the current version of your artifact
<pattern>: SemVer denoting the next version of your artifact. One of <major>.<minor>.<patch> may be set to "x" to increment from current-version.
```

## Examples
```
verit 1.0.0 1.x.0 # prints 1.1.0
```
```
verit 0.9.0 1.x.0 # prints 1.0.0
```

## CI/CD Example

If your artifact should have major version `0`, but you also want to bump the minor version with each build:
```
$ git init && echo "hello" > README.md && git add . && git commit -m "initial commit"
$ verit 0.x.0
0.1.0
# end of (successful) build
$ git push --tags
$ verit 0.x.0
0.2.0
# manually bump major version 0 -> 1, don't move the x for doing just that!
$ verit 1.x.0
1.0.0
$ verit 1.x.0
1.1.0
currentVersion=$(git describe --abbrev=0)
nextVersion=$(verit "$currentVersion" 0.x.0)
git tag "$nextVersion"
git push --tags
# ... use $version, e.g. to tag a docker image.
```
5 changes: 0 additions & 5 deletions cmd/verit.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/verit_test.go

This file was deleted.

32 changes: 32 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"
"os"
"verit/pkg/version"
)

const usage = `Usage: verit <current-version> <pattern>
Example: verit 1.0.0 1.x.0 # prints 1.1.0
<current-version>: SemVer denoting the current version of your artifact
<pattern>: SemVer denoting the next version of your artifact. One of <major>.<minor>.<patch> may be set to "x" to increment from current-version.
`

func main() {
args := os.Args[1:]
if len(args) != 2 {
exitWithMessage(usage)
}
next, err := version.Next(args[0], args[1])
if err != nil {
exitWithMessage(usage)
}
fmt.Println(next)
}

func exitWithMessage(message string) {
_, _ = os.Stderr.WriteString(message)
os.Exit(1)
}

0 comments on commit 08ef9cd

Please sign in to comment.