cosmos-sdk/version/version.go
Alessio Treglia c0486aa532
R4R: Infrastructure for reproducible builds (#4262)
This change set introduces support for building gaia with gitian
on the following GOOS/GOARCH pairs:

- darwin/386
- darwin/amd64
- linux/386
- linux/amd64
- linux/arm
- linux/arm64
- windows/386
- windows/amd64

cmd/gaia/contrib/gitian-descriptors/ contains gitian descriptor files.

cmd/gaia/contrib/gitian-keys/ contains:
- a keys.txt file that is meant to list core developers and gitian
  builders PGP keys. 
- README.me to provide instructions on how to import the keys
  into one's personal GPG keyring.

The gosum utility is removed, so is the go.sum hashsum bit from
gaiacli/gaiad version string. It was meant to be a provisional
mitigation to the lack of a reproducible build process.

GOBIN is removed from all Makefiles. When GOBIN is set, go
refuses to cross-compiles binaries for foreign architectures.
export GOBIN=$GOPATH/bin is unnecessary anyway as by
default go install places built binaries in $GOPATH/bin.
Developers are required to update their enviornment files and
replace $GOBIN with $GOPATH/bin in PATH.

circleci configuration file is amended accordingly.

Closes: #4027
Closes: #4280
2019-05-14 00:33:34 +02:00

59 lines
1.5 KiB
Go

// This package is a convenience utility that provides SDK
// consumers with a ready-to-use version command that
// produces apps versioning information based on flags
// passed at compile time.
//
// Configure the version command
//
// The version command can be just added to your cobra root command.
// At build time, the variables Name, Version, Commit, and BuildTags
// can be passed as build flags as shown in the following example:
//
// go build -X github.com/cosmos/cosmos-sdk/version.Name=dapp \
// -X github.com/cosmos/cosmos-sdk/version.Version=1.0 \
// -X github.com/cosmos/cosmos-sdk/version.Commit=f0f7b7dab7e36c20b757cebce0e8f4fc5b95de60 \
// -X "github.com/cosmos/cosmos-sdk/version.BuildTags=linux darwin amd64"
package version
import (
"fmt"
"runtime"
)
var (
// Application's name
Name = ""
// Application's version string
Version = ""
// Commit
Commit = ""
// Hash of the go.sum file
GoSumHash = ""
// Build tags
BuildTags = ""
)
type versionInfo struct {
Name string `json:"name"`
Version string `json:"version"`
GitCommit string `json:"commit"`
BuildTags string `json:"build_tags"`
GoVersion string `json:"go"`
}
func (v versionInfo) String() string {
return fmt.Sprintf(`%s: %s
git commit: %s
build tags: %s
%s`, v.Name, v.Version, v.GitCommit, v.BuildTags, v.GoVersion)
}
func newVersionInfo() versionInfo {
return versionInfo{
Name,
Version,
Commit,
BuildTags,
fmt.Sprintf("go version %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)}
}