From 80ab1b94dee0a849a6ae556ae202026c672a0d10 Mon Sep 17 00:00:00 2001 From: Sean Jezewski Date: Mon, 27 Jun 2016 17:30:55 -0700 Subject: [PATCH] Update how we consume additional version string Needs to be set at build time. --- .gitignore | 1 + .goxc.json => .goxc.json.template | 5 ++++- Makefile | 20 ++++++++++++++++++-- etc/build/release_manifest | 1 + etc/build/release_pachctl | 27 +++++++++++++++++++++------ src/client/version/version.go | 29 ++++------------------------- 6 files changed, 49 insertions(+), 34 deletions(-) rename .goxc.json => .goxc.json.template (56%) diff --git a/.gitignore b/.gitignore index dce158ce1b9..04aa342c3b2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *#* # Build artifacts +.goxc.json /protofix # Compiled Object files, Static and Dynamic libs (Shared Objects) diff --git a/.goxc.json b/.goxc.json.template similarity index 56% rename from .goxc.json rename to .goxc.json.template index 6419a1bd481..0b2748ec7eb 100644 --- a/.goxc.json +++ b/.goxc.json.template @@ -5,6 +5,9 @@ "publish-github" ], "BuildConstraints": "linux,amd64 darwin,amd64", + "BuildSettings" : { + "LdFlags": "-X github.com/pachyderm/pachyderm/src/server/vendor/github.com/pachyderm/pachyderm/src/client/version.AdditionalVersion=%%VERSION_ADDITIONAL%%" + }, "TaskSettings": { "publish-github": { "owner": "pachyderm", @@ -12,4 +15,4 @@ } }, "ConfigVersion": "0.9" -} \ No newline at end of file +} diff --git a/Makefile b/Makefile index 5a750b03912..89413ccbb31 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ COMPILE_RUN_ARGS = -v /var/run/docker.sock:/var/run/docker.sock --privileged=tru CLUSTER_NAME = pachyderm MANIFEST = etc/kube/pachyderm-versioned.json DEV_MANIFEST = etc/kube/pachyderm.json +VERSION_ADDITIONAL = $(shell git log --pretty=format:%H | head -n 1) LD_FLAGS = -X github.com/pachyderm/pachyderm/src/server/vendor/github.com/pachyderm/pachyderm/src/client/version.AdditionalVersion=$(VERSION_ADDITIONAL) ifndef TRAVIS_BUILD_NUMBER @@ -69,6 +70,9 @@ install-doc: release: release-version release-pachd release-job-shim release-manifest release-pachctl ./etc/build/tag_release rm VERSION + #git commit -a -m "[Automated] Released $(VERSION). Updated manifests to release version $(VERSION)" && \ + git pull origin master && \ + git push origin master release-version: @# Need to blow away pachctl binary if its already there @@ -278,12 +282,24 @@ goxc-generate-local: goxc-release: @if [ -z $$VERSION ]; then \ - echo "Missing version. Please run via: 'make VERSION=v1.2.3-4567 goxc-release'"; \ - exit 1; \ + @echo "Missing version. Please run via: 'make VERSION=v1.2.3-4567 VERSION_ADDITIONAL=4567 goxc-release'"; \ + @exit 1; \ + fi + if [ -z $$VERSION_ADDITIONAL ]; then \ + @echo "Missing version. Please run via: 'make VERSION=v1.2.3-4567 VERSION_ADDITIONAL=4567 goxc-release'"; \ + @exit 1; \ + else \ + sed 's/%%VERSION_ADDITIONAL%%/$(VERSION_ADDITIONAL)/' .goxc.json.template > .goxc.json; \ fi goxc -pv="$(VERSION)" -wd=./src/server/cmd/pachctl goxc-build: + if [ -z $$VERSION_ADDITIONAL ]; then \ + @echo "Missing version. Please run via: 'make VERSION_ADDITIONAL=4567 goxc-build'"; \ + @exit 1; \ + else \ + sed 's/%%VERSION_ADDITIONAL%%/$(VERSION_ADDITIONAL)/' .goxc.json.template > .goxc.json; \ + fi goxc -tasks=xc -wd=./src/server/cmd/pachctl .PHONY: diff --git a/etc/build/release_manifest b/etc/build/release_manifest index 672039d4346..a1e21d9b378 100755 --- a/etc/build/release_manifest +++ b/etc/build/release_manifest @@ -19,6 +19,7 @@ git clone git@github.com:pachyderm/www cp MANIFEST www/manifest.json cd www && \ git commit -a -m "[Automated] Update manifest.json to release version $VERSION" && \ + git pull origin master && \ git push origin master && \ make rm -rf www diff --git a/etc/build/release_pachctl b/etc/build/release_pachctl index 2cfe6d01ebd..ce16005c1db 100755 --- a/etc/build/release_pachctl +++ b/etc/build/release_pachctl @@ -22,15 +22,30 @@ then fi echo "--- Cross compiling pachctl for linux/mac and uploading binaries to github" -make VERSION=$VERSION goxc-release +make VERSION=v$VERSION goxc-release echo "--- Updating homebrew formula to use binaries at version $VERSION" +rm -rf homebrew-tap || true git clone git@github.com:pachyderm/homebrew-tap cd homebrew-tap && \ - make VERSION=$VERSION update-formula && \ - git commit -a -m "[Automated] Update formula to release version $VERSION" && \ - git push origin master -rm -rf homebrew-tap + make VERSION=$VERSION update-formula # && \ +# git commit -a -m "[Automated] Update formula to release version $VERSION" && \ +# git pull origin master && \ +# git push origin master +#rm -rf homebrew-tap + +rm -rf www || true +curl -o /tmp/pachctl.deb -L https://github.com/pachyderm/pachyderm/releases/download/v$(VERSION)/pachctl_$(VERSION)_amd64.deb +git clone git@github.com:pachyderm/www +cp /tmp/pachctl.deb www/pachctl.deb +cd www && \ + git add pachctl.deb +# make && \ +# git commit -a -m "[Automated] Update pachctl.deb to release version $VERSION" &&\ +# git pull origin master && \ +# git push origin master +#rm -rf www + + -# TODO: Add apt-get compilation / registering here diff --git a/src/client/version/version.go b/src/client/version/version.go index 9326f558b2b..287f6ac8b07 100644 --- a/src/client/version/version.go +++ b/src/client/version/version.go @@ -2,8 +2,6 @@ package version import ( "fmt" - "os/exec" - "strings" "go.pedge.io/proto/version" ) @@ -18,15 +16,16 @@ const ( ) var ( + // AdditionalVersion is the string provided at release time + // The value is passed to the linker at build time + AdditionalVersion string // Version is the current version for pachyderm. Version = &protoversion.Version{ Major: MajorVersion, Minor: MinorVersion, Micro: MicroVersion, - Additional: getAdditionalVersion(), + Additional: AdditionalVersion, } - // AdditionalVersion is the string provided at release time - AdditionalVersion string ) func PrettyPrintVersion(version *protoversion.Version) string { @@ -36,23 +35,3 @@ func PrettyPrintVersion(version *protoversion.Version) string { } return result } - -func getAdditionalVersion() string { - value := AdditionalVersion - if value == "" { - _, err := exec.LookPath("git") - if err != nil { - return "dirty" - } - out, err := exec.Command("git", "log", "--pretty=format:%H").Output() - if err != nil { - panic(err) - } - lines := strings.SplitAfterN(string(out), "\n", 2) - if len(lines) < 2 { - panic("Couldn't determine current commit hash") - } - value = strings.TrimSpace(lines[0]) - } - return value -}