chore: use ldflags to pass version to build process (#127)

This commit is contained in:
Derek Smith 2021-03-23 14:11:35 -05:00 committed by GitHub
parent 9a0d584745
commit 3113e42524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -1,3 +1,7 @@
VERSION?=$$(git describe --tags --always)
LDFLAGS="-X main.version=$(VERSION)"
.PHONY: clean
clean:
rm -rf ./dist/
@ -7,7 +11,7 @@ clean:
.PHONY: build
build:
go build -o git-chglog ./cmd/git-chglog
go build -ldflags=$(LDFLAGS) -o git-chglog ./cmd/git-chglog
.PHONY: test
test:

View file

@ -12,6 +12,9 @@ import (
"github.com/urfave/cli/v2"
)
// version is passed in via LDFLAGS main.version
var version string
// CreateApp creates and initializes CLI application
// with description, flags, version, etc.
func CreateApp(actionFunc cli.ActionFunc) *cli.App {
@ -74,7 +77,7 @@ func CreateApp(actionFunc cli.ActionFunc) *cli.App {
app := cli.NewApp()
app.Name = "git-chglog"
app.Usage = "todo usage for git-chglog"
app.Version = Version
app.Version = version
app.Flags = []cli.Flag{
// init

View file

@ -1,4 +0,0 @@
package main
// Version of git-chglog cli client
const Version = "v0.12.0"