Skip to content

Commit

Permalink
Update how we consume additional version string
Browse files Browse the repository at this point in the history
Needs to be set at build time.
  • Loading branch information
sjezewski committed Jun 28, 2016
1 parent bb1ab9d commit 80ab1b9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@
*#*

# Build artifacts
.goxc.json
/protofix

# Compiled Object files, Static and Dynamic libs (Shared Objects)
Expand Down
5 changes: 4 additions & 1 deletion .goxc.json → .goxc.json.template
Expand Up @@ -5,11 +5,14 @@
"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",
"repository": "pachyderm"
}
},
"ConfigVersion": "0.9"
}
}
20 changes: 18 additions & 2 deletions Makefile
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions etc/build/release_manifest
Expand Up @@ -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
Expand Down
27 changes: 21 additions & 6 deletions etc/build/release_pachctl
Expand Up @@ -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
29 changes: 4 additions & 25 deletions src/client/version/version.go
Expand Up @@ -2,8 +2,6 @@ package version

import (
"fmt"
"os/exec"
"strings"

"go.pedge.io/proto/version"
)
Expand All @@ -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 {
Expand All @@ -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
}

0 comments on commit 80ab1b9

Please sign in to comment.