diff --git a/Makefile b/Makefile index 2f8b07927e5..9b4ea87641d 100755 --- a/Makefile +++ b/Makefile @@ -56,7 +56,6 @@ PROJECT_NAME = $(PROJECT_NAME)/fabric else PROJECT_NAME = hyperledger/fabric endif -IS_RELEASE = false EXPERIMENTAL ?= true BUILD_DIR ?= .build @@ -65,12 +64,8 @@ ifeq ($(EXPERIMENTAL),true) GO_TAGS += experimental endif -ifneq ($(IS_RELEASE),true) -EXTRA_VERSION ?= snapshot-$(shell git rev-parse --short HEAD) -PROJECT_VERSION=$(BASE_VERSION)-$(EXTRA_VERSION) -else -PROJECT_VERSION=$(BASE_VERSION) -endif +EXTRA_VERSION ?= $(shell git rev-parse --short HEAD) +PROJECT_VERSION=$(BASE_VERSION)-snapshot-$(EXTRA_VERSION) PKGNAME = github.com/$(PROJECT_NAME) CGO_FLAGS = CGO_CFLAGS=" " @@ -78,7 +73,8 @@ ARCH=$(shell go env GOARCH) MARCH=$(shell go env GOOS)-$(shell go env GOARCH) # defined in common/metadata/metadata.go -METADATA_VAR = Version=$(PROJECT_VERSION) +METADATA_VAR = Version=$(BASE_VERSION) +METADATA_VAR += CommitSHA=$(EXTRA_VERSION) METADATA_VAR += BaseVersion=$(BASEIMAGE_RELEASE) METADATA_VAR += BaseDockerLabel=$(BASE_DOCKER_LABEL) METADATA_VAR += DockerNamespace=$(DOCKER_NS) @@ -163,16 +159,16 @@ orderer: $(BUILD_DIR)/bin/orderer orderer-docker: $(BUILD_DIR)/image/orderer/$(DUMMY) .PHONY: configtxgen -configtxgen: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.Version=$(PROJECT_VERSION) +configtxgen: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.CommitSHA=$(EXTRA_VERSION) configtxgen: $(BUILD_DIR)/bin/configtxgen -configtxlator: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.Version=$(PROJECT_VERSION) +configtxlator: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.CommitSHA=$(EXTRA_VERSION) configtxlator: $(BUILD_DIR)/bin/configtxlator -cryptogen: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.Version=$(PROJECT_VERSION) +cryptogen: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.CommitSHA=$(EXTRA_VERSION) cryptogen: $(BUILD_DIR)/bin/cryptogen -idemixgen: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.Version=$(PROJECT_VERSION) +idemixgen: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.CommitSHA=$(EXTRA_VERSION) idemixgen: $(BUILD_DIR)/bin/idemixgen discover: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.Version=$(PROJECT_VERSION) @@ -334,7 +330,7 @@ release: $(patsubst %,release/%, $(MARCH)) # builds release packages for all target platforms release-all: $(patsubst %,release/%, $(RELEASE_PLATFORMS)) -release/%: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.Version=$(PROJECT_VERSION) +release/%: GO_LDFLAGS=-X $(pkgmap.$(@F))/metadata.CommitSHA=$(EXTRA_VERSION) release/windows-amd64: GOOS=windows release/windows-amd64: $(patsubst %,release/windows-amd64/bin/%, $(RELEASE_PKGS)) release/windows-amd64/install diff --git a/common/metadata/metadata.go b/common/metadata/metadata.go index 1b283f2b682..44278013556 100644 --- a/common/metadata/metadata.go +++ b/common/metadata/metadata.go @@ -8,6 +8,7 @@ package metadata // Variables defined by the Makefile and passed in with ldflags var Version string = "latest" +var CommitSHA string = "development build" var BaseVersion string = "0.4.8" var BaseDockerLabel string = "org.hyperledger.fabric" var DockerNamespace string = "hyperledger" diff --git a/common/tools/configtxgen/metadata/metadata.go b/common/tools/configtxgen/metadata/metadata.go index 7d42c09389b..94835d828be 100644 --- a/common/tools/configtxgen/metadata/metadata.go +++ b/common/tools/configtxgen/metadata/metadata.go @@ -22,17 +22,19 @@ import ( ) // Package version -var Version string +const Version = "1.2.0" + +var CommitSHA string // Program name const ProgramName = "configtxgen" func GetVersionInfo() string { - if Version == "" { - Version = "development build" + if CommitSHA == "" { + CommitSHA = "development build" } - return fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - ProgramName, Version, runtime.Version(), + return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + ProgramName, Version, CommitSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) } diff --git a/common/tools/configtxgen/metadata/metadata_test.go b/common/tools/configtxgen/metadata/metadata_test.go index 218983100d8..d23cde4aa53 100644 --- a/common/tools/configtxgen/metadata/metadata_test.go +++ b/common/tools/configtxgen/metadata/metadata_test.go @@ -26,16 +26,16 @@ import ( ) func TestGetVersionInfo(t *testing.T) { - testVersions := []string{"", "TestVersion"} + testSHAs := []string{"", "abcdefg"} - for _, version := range testVersions { - metadata.Version = version - if version == "" { - version = "development build" + for _, sha := range testSHAs { + metadata.CommitSHA = sha + if sha == "" { + sha = "development build" } - expected := fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - metadata.ProgramName, version, runtime.Version(), + expected := fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + metadata.ProgramName, metadata.Version, sha, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) assert.Equal(t, expected, metadata.GetVersionInfo()) } diff --git a/common/tools/configtxlator/metadata/metadata.go b/common/tools/configtxlator/metadata/metadata.go index 4586d1ef1f2..8d1f166af43 100644 --- a/common/tools/configtxlator/metadata/metadata.go +++ b/common/tools/configtxlator/metadata/metadata.go @@ -14,7 +14,9 @@ import ( // package-scoped variables // Package version -var Version string +const Version = "1.2.0" + +var CommitSHA string // package-scoped constants @@ -22,11 +24,11 @@ var Version string const ProgramName = "configtxlator" func GetVersionInfo() string { - if Version == "" { - Version = "development build" + if CommitSHA == "" { + CommitSHA = "development build" } - return fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - ProgramName, Version, runtime.Version(), + return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + ProgramName, Version, CommitSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) } diff --git a/common/tools/configtxlator/metadata/metadata_test.go b/common/tools/configtxlator/metadata/metadata_test.go index 20de67a1806..7b8455cb29b 100644 --- a/common/tools/configtxlator/metadata/metadata_test.go +++ b/common/tools/configtxlator/metadata/metadata_test.go @@ -16,11 +16,11 @@ import ( ) func TestGetVersionInfo(t *testing.T) { - testVersion := "TestVersion" - metadata.Version = testVersion + testSHA := "abcdefg" + metadata.CommitSHA = testSHA - expected := fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - metadata.ProgramName, testVersion, runtime.Version(), + expected := fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + metadata.ProgramName, metadata.Version, testSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) assert.Equal(t, expected, metadata.GetVersionInfo()) } diff --git a/common/tools/cryptogen/metadata/metadata.go b/common/tools/cryptogen/metadata/metadata.go index 67a91148bfb..9974f75ea6c 100644 --- a/common/tools/cryptogen/metadata/metadata.go +++ b/common/tools/cryptogen/metadata/metadata.go @@ -14,7 +14,9 @@ import ( // package-scoped variables // Package version -var Version string +const Version = "1.2.0" + +var CommitSHA string // package-scoped constants @@ -22,11 +24,11 @@ var Version string const ProgramName = "cryptogen" func GetVersionInfo() string { - if Version == "" { - Version = "development build" + if CommitSHA == "" { + CommitSHA = "development build" } - return fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - ProgramName, Version, runtime.Version(), + return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + ProgramName, Version, CommitSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) } diff --git a/common/tools/cryptogen/metadata/metadata_test.go b/common/tools/cryptogen/metadata/metadata_test.go index 337a19a8d3d..4788ce5f109 100644 --- a/common/tools/cryptogen/metadata/metadata_test.go +++ b/common/tools/cryptogen/metadata/metadata_test.go @@ -16,11 +16,11 @@ import ( ) func TestGetVersionInfo(t *testing.T) { - testVersion := "TestVersion" - metadata.Version = testVersion + testSHA := "abcdefg" + metadata.CommitSHA = testSHA - expected := fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - metadata.ProgramName, testVersion, runtime.Version(), + expected := fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + metadata.ProgramName, metadata.Version, testSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) assert.Equal(t, expected, metadata.GetVersionInfo()) } diff --git a/common/tools/idemixgen/metadata/metadata.go b/common/tools/idemixgen/metadata/metadata.go index e641ed1e725..b921d3d8636 100644 --- a/common/tools/idemixgen/metadata/metadata.go +++ b/common/tools/idemixgen/metadata/metadata.go @@ -12,17 +12,19 @@ import ( ) // Package version -var Version string +const Version = "1.2.0" + +var CommitSHA string // Program name const ProgramName = "idemixgen" func GetVersionInfo() string { - if Version == "" { - Version = "1.2.0-dev" + if CommitSHA == "" { + CommitSHA = "development build" } - return fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - ProgramName, Version, runtime.Version(), + return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + ProgramName, Version, CommitSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) } diff --git a/common/tools/idemixgen/metadata/metadata_test.go b/common/tools/idemixgen/metadata/metadata_test.go index 78e96b10d0c..e54c7bd8907 100644 --- a/common/tools/idemixgen/metadata/metadata_test.go +++ b/common/tools/idemixgen/metadata/metadata_test.go @@ -16,11 +16,11 @@ import ( ) func TestGetVersionInfo(t *testing.T) { - testVersion := "TestVersion" - metadata.Version = testVersion + testSHA := "abcdefg" + metadata.CommitSHA = testSHA - expected := fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s", - metadata.ProgramName, testVersion, runtime.Version(), + expected := fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s", + metadata.ProgramName, metadata.Version, testSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)) assert.Equal(t, expected, metadata.GetVersionInfo()) } diff --git a/orderer/common/metadata/metadata.go b/orderer/common/metadata/metadata.go index 0420afbb49e..03c2368e99d 100644 --- a/orderer/common/metadata/metadata.go +++ b/orderer/common/metadata/metadata.go @@ -29,7 +29,9 @@ func GetVersionInfo() string { Version = "development build" } - return fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s\n"+ - " Experimental features: %s\n", ProgramName, Version, runtime.Version(), + return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n"+ + " Go version: %s\n OS/Arch: %s\n"+ + " Experimental features: %s\n", ProgramName, Version, common.CommitSHA, + runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), common.Experimental) } diff --git a/orderer/common/metadata/metadata_test.go b/orderer/common/metadata/metadata_test.go index 0715d1c7f46..439221baa63 100644 --- a/orderer/common/metadata/metadata_test.go +++ b/orderer/common/metadata/metadata_test.go @@ -24,8 +24,9 @@ func TestGetVersionInfo(t *testing.T) { common.Version = "testVersion" } - expected := fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s\n"+ + expected := fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n OS/Arch: %s\n"+ " Experimental features: %s\n", metadata.ProgramName, common.Version, + common.CommitSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), common.Experimental) assert.Equal(t, expected, metadata.GetVersionInfo()) diff --git a/peer/version/version.go b/peer/version/version.go index efbf3b95538..f18ef87d3ee 100644 --- a/peer/version/version.go +++ b/peer/version/version.go @@ -44,9 +44,10 @@ func GetInfo() string { metadata.BaseVersion, metadata.BaseDockerNamespace, metadata.BaseDockerLabel, metadata.DockerNamespace) - return fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s\n"+ + return fmt.Sprintf("%s:\n Version: %s\n Commit SHA: %s\n Go version: %s\n"+ + " OS/Arch: %s\n"+ " Experimental features: %s\n Chaincode:\n %s\n", - ProgramName, metadata.Version, runtime.Version(), + ProgramName, metadata.Version, metadata.CommitSHA, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), metadata.Experimental, ccinfo) } diff --git a/sampleconfig/core.yaml b/sampleconfig/core.yaml index a2d6fa36302..78006aaa69d 100644 --- a/sampleconfig/core.yaml +++ b/sampleconfig/core.yaml @@ -510,7 +510,7 @@ chaincode: name: # Generic builder environment, suitable for most chaincode types - builder: $(DOCKER_NS)/fabric-ccenv:$(ARCH)-$(PROJECT_VERSION) + builder: $(DOCKER_NS)/fabric-ccenv:latest # Enables/disables force pulling of the base docker images (listed below) # during user chaincode instantiation.