Skip to content

Commit

Permalink
Track version number for release purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed May 17, 2021
1 parent 3f795d6 commit 03ecf3d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/plesk
/.plesk
/plesk.exe
/build/*/plesk
/build/*/plesk*
/build/*.tgz
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

OUTFILE=plesk
REVISON:=$(shell git rev-parse --short HEAD)
VERSION:=$(shell cat VERSION)
BUILD_TIME=$(shell date +'%Y-%m-%d_%T')
LDFLAGS=-X main.revision=$(REVISON) -X main.buildTime=$(BUILD_TIME)
LDFLAGS=-X main.revision=$(REVISON) -X main.buildTime=$(BUILD_TIME) -X main.version=$(VERSION)
RELEASE_LDFLAGS=$(LDFLAGS) -s -w

.PHONY: all build clean test
Expand All @@ -13,8 +14,11 @@ build: test

release: test
GOOS=linux go build -ldflags "$(RELEASE_LDFLAGS)" -o ./build/linux/$(OUTFILE)
tar czf ./build/$(OUTFILE)-v$(VERSION)-linux.tgz build/linux/$(OUTFILE)
GOOS=darwin go build -ldflags "$(RELEASE_LDFLAGS)" -o ./build/mac/$(OUTFILE)
GOOS=windows go build -ldflags "$(RELEASE_LDFLAGS)" -o ./build/win/$(OUTFILE)
tar czf ./build/$(OUTFILE)-v$(VERSION)-mac.tgz build/mac/$(OUTFILE)
GOOS=windows go build -ldflags "$(RELEASE_LDFLAGS)" -o ./build/win/$(OUTFILE).exe
tar czf ./build/$(OUTFILE)-v$(VERSION)-win.tgz build/win/$(OUTFILE).exe

run:
go run main.go
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
4 changes: 3 additions & 1 deletion cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import (
var (
Revision string
BuildTime string
Version string
)

var VersionCmd = &cobra.Command{
Use: "version",
Short: locales.L.Get("version.description"),
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Printf("Revision:\t%s\nBuild time:\t%s\n", Revision, BuildTime)
fmt.Println("Client information")
fmt.Printf("Version:\t%s\nRevision:\t%s\nBuild time:\t%s\n", Version, Revision, BuildTime)

return nil
},
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import (
var (
revision string
buildTime string
version string
)

func init() {
versionCmd.Revision = revision
versionCmd.BuildTime = buildTime
versionCmd.Version = version
}

func main() {
Expand Down

0 comments on commit 03ecf3d

Please sign in to comment.