From 223245cc45a92af4d41689d7038595dae5206f0c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 23 Feb 2016 14:57:14 -0800 Subject: [PATCH] build: Add release builds, now generated with 'make release' Currently supported platforms are - linux{amd64,arm,386} - winows{amd64,386} - darwin{amd64} --- MAINTAINERS.md | 2 +- Makefile | 11 +++++++-- build-constants.go | 12 ++++++---- buildscripts/build.sh | 48 +++++++++++++++++++++++++++++++++++++ buildscripts/gen-ldflags.go | 2 +- release.cmd | 5 ---- release.sh | 6 ----- update-main.go | 7 +++--- 8 files changed, 71 insertions(+), 22 deletions(-) create mode 100755 buildscripts/build.sh delete mode 100644 release.cmd delete mode 100755 release.sh diff --git a/MAINTAINERS.md b/MAINTAINERS.md index bcc95cb38..059d9c3da 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -34,4 +34,4 @@ $ `minio` doesn't follow semantic versioning style, `minio` instead uses the release date and time as the release versions. -`make release` will install new released binary into your `GOPATH` +`make release` will generate new binary into `release` directory. diff --git a/Makefile b/Makefile index 703e18ce5..d63e2cece 100644 --- a/Makefile +++ b/Makefile @@ -124,6 +124,9 @@ pkg-update: pkg-remove: @GO15VENDOREXPERIMENT=1 ${GOPATH}/bin/govendor remove $(PKG) +pkg-list: + @GO15VENDOREXPERIMENT=1 $(GOPATH)/bin/govendor list + install: gomake-all dockerimage: checkdocker verifiers $(UI_ASSETS) @@ -134,8 +137,11 @@ dockerimage: checkdocker verifiers $(UI_ASSETS) @rmdir export @rm minio.dockerimage -release: - @./release.sh +release: verifiers + @MC_RELEASE=RELEASE GO15VENDOREXPERIMENT=1 ./buildscripts/build.sh + +experimental: verifiers + @MC_RELEASE=EXPERIMENTAL GO15VENDOREXPERIMENT=1 ./buildscripts/build.sh clean: @echo "Cleaning up all the generated files:" @@ -143,3 +149,4 @@ clean: @find . -name '*.test' | xargs rm -fv @rm -rf isa-l @rm -rf build + @rm -rf release diff --git a/build-constants.go b/build-constants.go index 03167e9fb..6703e4f85 100644 --- a/build-constants.go +++ b/build-constants.go @@ -17,8 +17,12 @@ package main var ( - minioVersion = "UNOFFICIAL.GOGET" - minioReleaseTag = "UNOFFICIAL.GOGET" - minioCommitID = "UNOFFICIAL.GOGET" - minioShortCommitID = minioCommitID[:] + // minioVersion - version time.RFC3339. + minioVersion = "DEVELOPMENT.GOGET" + // minioReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ. + minioReleaseTag = "DEVELOPMENT.GOGET" + // minioCommitID - latest commit id. + minioCommitID = "DEVELOPMENT.GOGET" + // minioShortCommitID - first 12 characters from mcCommitID + minioShortCommitID = minioCommitID[:12] ) diff --git a/buildscripts/build.sh b/buildscripts/build.sh new file mode 100755 index 000000000..dce9c7bff --- /dev/null +++ b/buildscripts/build.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +_init() { + # Save release LDFLAGS + LDFLAGS=$(go run buildscripts/gen-ldflags.go) + + # Extract release tag + release_tag=$(echo $LDFLAGS | awk {'print $4'} | cut -f2 -d=) + + # Verify release tag. + if [ -z "$release_tag" ]; then + echo "Release tag cannot be empty. Please check return value of \`go run buildscripts/gen-ldflags.go\`" + exit 1; + fi + + # Extract release string. + release_str=$(echo $MC_RELEASE | tr '[:upper:]' '[:lower:]') + + # Verify release string. + if [ -z "$release_str" ]; then + echo "Release string cannot be empty. Please set \`MC_RELEASE\` env variable." + exit 1; + fi + + # List of supported architectures + SUPPORTED_OSARCH='linux/386 linux/amd64 linux/arm windows/386 windows/amd64 darwin/amd64' +} + +go_build() { + local osarch=$1 + os=$(echo $osarch | cut -f1 -d'/') + arch=$(echo $osarch | cut -f2 -d'/') + package=$(go list -f '{{.ImportPath}}') + echo -n "-->" + printf "%15s:%s\n" "${osarch}" "${package}" + GO15VENDOREXPERIMENT=1 GOOS=$os GOARCH=$arch go build --ldflags "${LDFLAGS}" -o $release_str/$os-$arch/$(basename $package).$release_tag +} + +main() { + # Build releases. + echo "Executing $release_str builds for OS: ${SUPPORTED_OSARCH}" + for osarch in ${SUPPORTED_OSARCH}; do + go_build ${osarch} + done +} + +# Run main. +_init && main diff --git a/buildscripts/gen-ldflags.go b/buildscripts/gen-ldflags.go index 0656fc058..2892988cd 100644 --- a/buildscripts/gen-ldflags.go +++ b/buildscripts/gen-ldflags.go @@ -37,7 +37,7 @@ func genLDFlags(version string) string { // genReleaseTag prints release tag to the console for easy git tagging. func releaseTag(version string) string { - relPrefix := "UNOFFICIAL" + relPrefix := "DEVELOPMENT" if prefix := os.Getenv("MINIO_RELEASE"); prefix != "" { relPrefix = prefix } diff --git a/release.cmd b/release.cmd deleted file mode 100644 index 477d9b7d7..000000000 --- a/release.cmd +++ /dev/null @@ -1,5 +0,0 @@ -SET MINIO_RELEASE=OFFICIAL -SET GO15VENDOREXPERIMENT=1 -go run buildscripts/gen-ldflags.go > temp.txt -SET /p LDFLAGS=/dev/null -echo "Binaries built at ${GOPATH}/bin/minio" diff --git a/update-main.go b/update-main.go index 10f6e8b6b..b468ba5f8 100644 --- a/update-main.go +++ b/update-main.go @@ -121,8 +121,9 @@ func parseReleaseData(data string) (time.Time, *probe.Error) { if releaseDateSplits[0] != "minio" { return time.Time{}, probe.NewError(errors.New("Update data malformed, missing minio tag")) } - if releaseDateSplits[1] != "OFFICIAL" { - return time.Time{}, probe.NewError(errors.New("Update data malformed, missing OFFICIAL tag")) + // "OFFICIAL" tag is still kept for backward compatibility, we should remove this for the next release. + if releaseDateSplits[1] != "RELEASE" && releaseDateSplits[1] != "OFFICIAL" { + return time.Time{}, probe.NewError(errors.New("Update data malformed, missing RELEASE tag")) } dateSplits := strings.SplitN(releaseDateSplits[2], "T", 2) if len(dateSplits) < 2 { @@ -145,7 +146,7 @@ func getReleaseUpdate(updateURL string) { data, e := http.Get(newUpdateURL) fatalIf(probe.NewError(e), "Unable to read from update URL ‘"+newUpdateURL+"’.", nil) - if minioVersion == "UNOFFICIAL.GOGET" { + if minioVersion == "DEVELOPMENT.GOGET" { fatalIf(probe.NewError(errors.New("")), "Update mechanism is not supported for ‘go get’ based binary builds. Please download official releases from https://minio.io/#minio", nil) }