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
|
||||
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:
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user