8000 chore: use ldflags to pass version to build process (#127) · git-chglog/git-chglog@3113e42 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
chore: use ldflags to pass version to build process (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
clok authored Mar 23, 2021
1 parent 9a0d584 commit 3113e42
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
VERSION?=$$(git describe --tags --always)

LDFLAGS="-X main.version=$(VERSION)"

.PHONY: clean
clean:
rm -rf ./dist/
Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion cmd/git-chglog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions cmd/git-chglog/version.go

This file was deleted.

0 comments on commit 3113e42

Please sign in to comment.
0