Merge pull request #561 from stevvooe/correct-versioning
version: finish version setup
This commit is contained in:
commit
a463ba33fc
5 changed files with 28 additions and 21 deletions
10
Makefile
10
Makefile
|
@ -7,11 +7,11 @@ DESTDIR=/usr/local
|
||||||
# Used to populate version variable in main package.
|
# Used to populate version variable in main package.
|
||||||
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
|
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
|
||||||
|
|
||||||
PROJECT_ROOT=github.com/docker/containerd
|
PKG=github.com/docker/containerd
|
||||||
|
|
||||||
# Project packages.
|
# Project packages.
|
||||||
PACKAGES=$(shell go list ./... | grep -v /vendor/)
|
PACKAGES=$(shell go list ./... | grep -v /vendor/)
|
||||||
INTEGRATION_PACKAGE=${PROJECT_ROOT}/integration
|
INTEGRATION_PACKAGE=${PKG}/integration
|
||||||
SNAPSHOT_PACKAGES=$(shell go list ./snapshot/...)
|
SNAPSHOT_PACKAGES=$(shell go list ./snapshot/...)
|
||||||
|
|
||||||
# Project binaries.
|
# Project binaries.
|
||||||
|
@ -21,7 +21,7 @@ BINARIES=$(addprefix bin/,$(COMMANDS))
|
||||||
# TODO(stevvooe): This will set version from git tag, but overrides major,
|
# TODO(stevvooe): This will set version from git tag, but overrides major,
|
||||||
# minor, patch in the actual file. We'll have to resolve this before release
|
# minor, patch in the actual file. We'll have to resolve this before release
|
||||||
# time.
|
# time.
|
||||||
GO_LDFLAGS=-ldflags "-X `go list`.Version=$(VERSION)"
|
GO_LDFLAGS=-ldflags "-X $(PKG).Version=$(VERSION) -X $(PKG).Package=$(PKG)"
|
||||||
|
|
||||||
# Flags passed to `go test`
|
# Flags passed to `go test`
|
||||||
TESTFLAGS ?=-parallel 8 -race
|
TESTFLAGS ?=-parallel 8 -race
|
||||||
|
@ -108,8 +108,8 @@ FORCE:
|
||||||
|
|
||||||
# Build a binary from a cmd.
|
# Build a binary from a cmd.
|
||||||
bin/%: cmd/% FORCE
|
bin/%: cmd/% FORCE
|
||||||
@test $$(go list) = "${PROJECT_ROOT}" || \
|
@test $$(go list) = "${PKG}" || \
|
||||||
(echo "👹 Please correctly set up your Go build environment. This project must be located at <GOPATH>/src/${PROJECT_ROOT}" && false)
|
(echo "👹 Please correctly set up your Go build environment. This project must be located at <GOPATH>/src/${PKG}" && false)
|
||||||
@echo "🐳 $@"
|
@echo "🐳 $@"
|
||||||
@go build -i -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./$<
|
@go build -i -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./$<
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,12 @@ var (
|
||||||
global = log.WithModule(gocontext.Background(), "containerd")
|
global = log.WithModule(gocontext.Background(), "containerd")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cli.VersionPrinter = func(c *cli.Context) {
|
||||||
|
fmt.Println(c.App.Name, containerd.Package, c.App.Version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "containerd"
|
app.Name = "containerd"
|
||||||
|
|
|
@ -9,6 +9,12 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cli.VersionPrinter = func(c *cli.Context) {
|
||||||
|
fmt.Println(c.App.Name, containerd.Package, c.App.Version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "ctr"
|
app.Name = "ctr"
|
||||||
|
|
3
cmd/dist/main.go
vendored
3
cmd/dist/main.go
vendored
|
@ -15,6 +15,9 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
cli.VersionPrinter = func(c *cli.Context) {
|
||||||
|
fmt.Println(os.Args[0], containerd.Package, containerd.Version)
|
||||||
|
}
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "dist"
|
app.Name = "dist"
|
||||||
app.Version = containerd.Version
|
app.Version = containerd.Version
|
||||||
|
|
24
version.go
24
version.go
|
@ -1,20 +1,12 @@
|
||||||
package containerd
|
package containerd
|
||||||
|
|
||||||
import "fmt"
|
var (
|
||||||
|
Package = "github.com/docker/containerd"
|
||||||
|
|
||||||
// VersionMajor holds the release major number
|
// Version holds the complete version number.
|
||||||
const VersionMajor = 1
|
Version = "1.0-dev+unknown"
|
||||||
|
|
||||||
// VersionMinor holds the release minor number
|
// GitCommit is filled with the Git revision being used to build the
|
||||||
const VersionMinor = 0
|
// program at linking time
|
||||||
|
GitCommit = ""
|
||||||
// VersionPatch holds the release patch number
|
)
|
||||||
const VersionPatch = 0
|
|
||||||
|
|
||||||
// Version holds the combination of major minor and patch as a string
|
|
||||||
// of format Major.Minor.Patch
|
|
||||||
var Version = fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
|
|
||||||
|
|
||||||
// GitCommit is filled with the Git revision being used to build the
|
|
||||||
// program at linking time
|
|
||||||
var GitCommit = ""
|
|
||||||
|
|
Loading…
Reference in a new issue