This repository was archived by the owner on Oct 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1+ dist /
2+
13# For testing:
24config.hcl
Original file line number Diff line number Diff line change 1+ VERSION := 0.1.0
2+
13# Note that I'd love to use goreleaser for this but they don't quite
24# have the hooks yet to be able to merge in gon support. Ideally they'd
35# just integrate natively in some way.
46build : clean
57 mkdir -p dist
6- GOOS=darwin GOARCH=amd64 go build -o ./dist/gon ./cmd/gon
8+ GOOS=darwin GOARCH=amd64 go build -ldflags " -X main.version= $( VERSION ) " - o ./dist/gon ./cmd/gon
79.PHONY : build
810
911# release will package the distribution packages, sign, and notarize
Original file line number Diff line number Diff line change @@ -19,11 +19,29 @@ import (
1919 "github.com/mitchellh/gon/sign"
2020)
2121
22+ // Set by build process
23+ var (
24+ version string
25+ )
26+
2227func main () {
2328 os .Exit (realMain ())
2429}
2530
2631func realMain () int {
32+ // Look for version
33+ for _ , v := range os .Args [1 :] {
34+ v = strings .TrimLeft (v , "-" )
35+ if v == "v" || v == "version" {
36+ if version == "" {
37+ version = "dev"
38+ }
39+
40+ fmt .Printf ("version %s\n " , version )
41+ return 0
42+ }
43+ }
44+
2745 var logLevel string
2846 var logJSON bool
2947 flags := flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
You can’t perform that action at this time.
0 commit comments