-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.go
More file actions
32 lines (27 loc) · 1.03 KB
/
Copy pathversion.go
File metadata and controls
32 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
_ "embed"
"strings"
"github.com/modernpath/cli/cmd"
)
// VERSION is the one place the CLI's version lives: the NEXT release, as the
// tag `v$(cat VERSION)` will name it in ModernPath/cli. A release build gets
// exactly that string through -ldflags (release.yml reads the tag); a local
// build gets `<VERSION>-dev+<commit> (<date>)` from install-local.sh; a bare
// `go build` gets `<VERSION>-dev` from here. Semver then orders every local
// build after the last release and before the next one, which is what a
// freshness check compares (BACKLOG-TOOL-71). install-local.sh used to
// hard-code 0.5.0 while the release repo was already at v0.6.0, so a fresh
// local build read as older than a month-old release.
//
//go:embed VERSION
var nextRelease string
// defaultVersion is what the binary reports when no -ldflags stamp was given.
func defaultVersion(embedded string) string {
return strings.TrimSpace(embedded) + "-dev"
}
func init() {
if cmd.Version == "dev" {
cmd.Version = defaultVersion(nextRelease)
}
}