diff --git a/.gitignore b/.gitignore index ec5f213..9d7dcc0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /plesk /.plesk /plesk.exe -/build/*/plesk +/build/*/plesk* +/build/*.tgz \ No newline at end of file diff --git a/Makefile b/Makefile index 9d9d62a..659a709 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..8a9ecc2 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file diff --git a/cmd/version/version.go b/cmd/version/version.go index 45de501..37faff0 100644 --- a/cmd/version/version.go +++ b/cmd/version/version.go @@ -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 }, diff --git a/main.go b/main.go index b8bf853..3e82e67 100644 --- a/main.go +++ b/main.go @@ -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() {