chore: read commit from Go
That way we don't rely on an external tool to pass it and it's always set at build time. Signed-off-by: Yves Brissaud <yves.brissaud@docker.com>
This commit is contained in:
Родитель
7b5c3d98e3
Коммит
c3df0d4631
|
@ -22,7 +22,6 @@ builds:
|
|||
-s
|
||||
-extldflags '-static'
|
||||
-X github.com/docker/index-cli-plugin/internal.version={{.Version}}
|
||||
-X github.com/docker/index-cli-plugin/internal.commit={{.Commit}}
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
|
|
|
@ -22,6 +22,7 @@ package internal
|
|||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
// build-time arguments
|
||||
|
@ -30,6 +31,16 @@ var (
|
|||
commit = "n/a"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
for _, setting := range info.Settings {
|
||||
if setting.Key == "vcs.revision" {
|
||||
commit = setting.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Version information from build time args and environment
|
||||
type Version struct {
|
||||
Version string
|
||||
|
|
Загрузка…
Ссылка в новой задаче