From ea30e282616d3f94969256d40e613fddef0db836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Mej=C3=ADas=20Rodr=C3=ADguez?= Date: Fri, 9 Aug 2019 01:28:31 -0400 Subject: [PATCH] Move version setting to goreleaser --- .goreleaser.yml | 2 +- common/version.go | 34 ++-------------------------------- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 3cd2e55..c42c8fe 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,7 +8,7 @@ builds: - main: main.go binary: psu ldflags: - - -X github.com/greenled/portainer-stack-utils/common.commitHash={{ .ShortCommit }} -X github.com/greenled/portainer-stack-utils/common.buildDate={{ .Date }} + - -X github.com/greenled/portainer-stack-utils/common.version={{ .Version }} -X github.com/greenled/portainer-stack-utils/common.commitHash={{ .ShortCommit }} -X github.com/greenled/portainer-stack-utils/common.buildDate={{ .Date }} env: - CGO_ENABLED=0 goos: diff --git a/common/version.go b/common/version.go index 938aa0f..9aebc77 100644 --- a/common/version.go +++ b/common/version.go @@ -7,13 +7,8 @@ import ( ) var ( - // This is the current version of the client - CurrentVersion = Version{ - Major: 0, - Minor: 1, - Patch: 1, - Suffix: "", - } + // This is the current version of the client. It is set by goreleaser. + version string // The program name programName = "Portainer Stack Utils" @@ -25,32 +20,7 @@ var ( buildDate string ) -type Version struct { - // Major version - Major uint32 - - // Minor version - Minor uint32 - - // Patch version - Patch uint32 - - // Suffix used in version string - // Will be blank for release versions - Suffix string -} - -func (v Version) String() string { - if v.Suffix != "" { - return fmt.Sprintf("%d.%d.%d-%s", v.Major, v.Minor, v.Patch, v.Suffix) - } else { - return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch) - } -} - func BuildVersionString() string { - version := "v" + CurrentVersion.String() - if commitHash != "" { version += "-" + strings.ToUpper(commitHash) }