From 9f7649049dd1b171d9197de9360f7cca952ea95b Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sat, 7 May 2022 00:49:53 -0500 Subject: [PATCH] added versioning --- Makefile | 18 ++++++++++++++++++ go.mod | 4 ++++ go.sum | 12 ++++++++++++ main.go | 14 ++++++++++++++ tools.go | 5 +++++ 5 files changed, 53 insertions(+) create mode 100644 Makefile create mode 100644 go.sum create mode 100644 main.go create mode 100644 tools.go diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..35a20e7 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +BIN_NAME=hasshelper +PACKAGE_NAME=git.bloy.org/mike/hasshelper +GIT_DESCRIBE=$(shell git describe --always --long --dirty) +GIT_SEMVER=$(shell go run github.com/mdomke/git-semver) +LDFLAGS="-X main.gitDescribe=${GIT_DESCRIBE} -X main.gitVersion=${GIT_SEMVER}" + +default: all + +all: test build + +build: + go build -ldflags ${LDFLAGS} -o bin/${BIN_NAME} + +test: + go test ./... -ldflags ${LDFLAGS} + +clean: + rm -rf bin/${BIN_NAME} diff --git a/go.mod b/go.mod index 512ed80..bd5d3a6 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,7 @@ module git.bloy.org/mike/hasshelper go 1.18 + +require github.com/mdomke/git-semver v1.0.0 + +require github.com/stretchr/testify v1.7.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..8a839c9 --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/mdomke/git-semver v1.0.0 h1:cg/a+bI/D2EtPWlx4pKSUKz9G9bTOHEBdF2EjbV0b4s= +github.com/mdomke/git-semver v1.0.0/go.mod h1:fNw8giSaJDzhF/Gvxe7JSZJVDlkRR+/a8y1b3g6SGZ8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..0b0f568 --- /dev/null +++ b/main.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" +) + +var gitDescribe = "" +var gitVersion = "" + +func main() { + fmt.Println("vim-go") + fmt.Println("getDescribe", gitDescribe) + fmt.Println("getVersion", gitVersion) +} diff --git a/tools.go b/tools.go new file mode 100644 index 0000000..9931998 --- /dev/null +++ b/tools.go @@ -0,0 +1,5 @@ +//go:build tools + +package tools + +import _ "github.com/mdomke/git-semver"