mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Move version setting to goreleaser
This commit is contained in:
parent
535eada8ab
commit
ea30e28261
@ -8,7 +8,7 @@ builds:
|
|||||||
- main: main.go
|
- main: main.go
|
||||||
binary: psu
|
binary: psu
|
||||||
ldflags:
|
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:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
goos:
|
goos:
|
||||||
|
@ -7,13 +7,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// This is the current version of the client
|
// This is the current version of the client. It is set by goreleaser.
|
||||||
CurrentVersion = Version{
|
version string
|
||||||
Major: 0,
|
|
||||||
Minor: 1,
|
|
||||||
Patch: 1,
|
|
||||||
Suffix: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
// The program name
|
// The program name
|
||||||
programName = "Portainer Stack Utils"
|
programName = "Portainer Stack Utils"
|
||||||
@ -25,32 +20,7 @@ var (
|
|||||||
buildDate string
|
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 {
|
func BuildVersionString() string {
|
||||||
version := "v" + CurrentVersion.String()
|
|
||||||
|
|
||||||
if commitHash != "" {
|
if commitHash != "" {
|
||||||
version += "-" + strings.ToUpper(commitHash)
|
version += "-" + strings.ToUpper(commitHash)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user