- Notifications
You must be signed in to change notification settings - Fork1
Go package that embeds a git tag/version string in your application
License
aletheia7/gogitver
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
gogitver andmage (go make)
A go package that inserts a git tag into your binary. Uses mage to efficientlycompile your go application when the git tag changes. Other source code changeswill still trigger a compile. The git version/tag is created beforehand with:
git tag -a# View the git tag:git describe --tags --long# Instead of "go install" execute:mage
Install andmage
gogitver must be installed as a package under your application maindirectory. E.g. if your application resides under ~/go/src/app,gogitver must be installed under ~/go/src/app/gogitver. ~/go/src/app/vendor/gogitveris preferred.
# Examplemkdir~/go/src/app/vendor/gogitvercd~/go/src/appgit clone --depth 1 https://github.com/aletheia7/gogitver.git vendor/gogitverrm -fr vendor/gogitver/.git# link mage_gogitver.goln -s vendor/gogitver/mage_gogitver.go.Add a mg.Dep(Gogitver) to your main magefile.go that should reside under~/go/src/app.
Create a git tag:
git tag -a 1.0.7
Run mage:
mage
gogitver andGNUMake
A go package that inserts a git tag into your binary. Uses make to efficientlycompile your go application when the git tag changes. Other source code changeswill still trigger a compile. The git version/tag is created beforehand with:
git tag -a# View the git tag:git describe --tags --long# Instead of "go install" execute:make# Run "go install" and strip to remove debug symbols:make strip# Instead of "go clean" execute:make clean
Install andGNUMake
gogitver must be installed as a package under your application maindirectory. E.g. if your application resides under ~/go/src/app,gogitver must be installed under ~/go/src/app/gogitver. ~/go/src/app/vendor/gogitveris preferred.
# Examplemkdir~/go/src/app/vendor/gogitvercd~/go/src/appgit clone --depth 1 https://github.com/aletheia7/gogitver.git vendor/gogitverrm -fr vendor/gogitver/.git# link makefileln -s vendor/gogitver/makefile.
Create a git tag:
git tag -a 1.0.7
Run make:
make
Software Version Guidelines:Semantic Versioning
Compare & parse semver version strings:godoc go-semver,code: go-semver
package mainimport ("fmt"// Do not use "github.com/alethiea7/gogitver"// It will not work"app/gogitver")funcmain() {fmt.Println(gogitver.Git())fmt.Println(gogitver.Tag())}
1.0.7-0-g8e9e07b1.0.7
Use of this source code is governed by a BSD-2-Clause license that can be foundin the LICENSE file.