Skip to content

Commit

Permalink
version: Use variables for goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyfrosch committed Nov 17, 2020
1 parent a0dbea2 commit b79eb87
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
GIT_COMMIT := $(shell git rev-list -1 HEAD)
GO_BUILD := go build -v -ldflags "-X main.GitCommit=$(GIT_COMMIT)"
DATE := $(shell date --iso-8601=seconds)
GO_BUILD := go build -v -ldflags "-X main.commit=$(GIT_COMMIT) -X main.date=$(DATE) -X main.builtBy=make"

NAME = check_by_powershell

Expand Down
28 changes: 21 additions & 7 deletions version.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
package main

const Version = "0.2.0"

var GitCommit string
// default vars set by goreleaser
// https://goreleaser.com/customization/build/
var (
version = "0.2.0"
commit string
date string
builtBy string
)

func buildVersion() string {
version := Version
if GitCommit != "" {
version += " - " + GitCommit
s := version

if commit != "" {
s += " - " + commit
}

if date != "" {
s += " (" + date + ")"
}

if builtBy != "" {
s += " (built by " + builtBy + ")"
}

return version
return s
}

0 comments on commit b79eb87

Please sign in to comment.