Adding version from version.go

Signed-off-by: Diogo Monica <diogo@docker.com>
This commit is contained in:
Diogo Monica 2015-07-28 14:18:34 -07:00
parent 4cf84b3e46
commit c4e4518d04
4 changed files with 6 additions and 57 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/spf13/viper"
"github.com/docker/notary/pkg/passphrase"
"github.com/docker/notary/version"
)
const configFileName string = "config"
@ -80,7 +81,7 @@ func main() {
Short: "Print the version number of notary",
Long: `print the version number of notary`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("notary v0.1.0-rc1")
fmt.Printf("notary\n Version: %s\n Git commit: %s\n", version.NotaryVersion, version.GitCommit)
},
}

View File

@ -1,26 +0,0 @@
package version
import (
"fmt"
"io"
"os"
)
// FprintVersion outputs the version string to the writer, in the following
// format, followed by a newline:
//
// <cmd> <project> <version>
//
// For example, a binary "registry" built from github.com/docker/distribution
// with version "v2.0" would print the following:
//
// registry github.com/docker/distribution v2.0
//
func FprintVersion(w io.Writer) {
fmt.Fprintln(w, os.Args[0], Package, Version)
}
// PrintVersion outputs the version information, from Fprint, to stdout.
func PrintVersion() {
FprintVersion(os.Stdout)
}

View File

@ -1,11 +1,7 @@
package version
// Package is the overall, canonical project import path under which the
// package was built.
var Package = "github.com/docker/notary"
// Version indicates which version of the binary is running.
var NotaryVersion = "v0.1.0-rc1"
// Version indicates which version of the binary is running. This is set to
// the latest release tag by hand, always suffixed by "+unknown". During
// build, it will be replaced by the actual version. The value here will be
// used if the registry is run after a go get based install.
var Version = "v0.0.1-alpha.1+unknown"
// GitCommit indicates which git hash the binary was built off of
var GitCommit string

View File

@ -1,22 +0,0 @@
#!/bin/sh
# This bash script outputs the current, desired content of version.go, using
# git describe. For best effect, pipe this to the target file. Generally, this
# only needs to updated for releases. The actual value of will be replaced
# during build time if the makefile is used.
set -e
cat <<EOF
package version
// Package is the overall, canonical project import path under which the
// package was built.
var Package = "$(go list)"
// Version indicates which version of the binary is running. This is set to
// the latest release tag by hand, always suffixed by "+unknown". During
// build, it will be replaced by the actual version. The value here will be
// used if the registry is run after a go get based install.
var Version = "$(git describe --match 'v[0-9]*' --dirty='.m' --always)+unknown"
EOF