From b0e3e7d8a55f1fd77625880853c156811ff007dc Mon Sep 17 00:00:00 2001 From: Tyler Cipriani Date: Thu, 24 May 2018 11:46:02 -0600 Subject: Cross-compile using gox Reviewers: dduvall, #release-engineering-team Reviewed By: dduvall, #release-engineering-team Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D1059 --- .gitignore | 1 + CONTRIBUTING.md | 9 +++++++++ Makefile | 12 +++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c0899c9..483f344 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /bin /blubber /blubber.git +/_release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e08cc1..d9c2d8f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,6 +25,8 @@ to both users inside and outside of WMF and our communities. 4. An account at [phabricator.wikimedia.org](https://phabricator.wikimedia.org) * See our [help article](https://www.mediawiki.org/wiki/Phabricator/Help) for setup instructions. + 5. (optional) `gox` is used for cross-compiling binary releases. To + install `gox` use `go get github.com/mitchellh/gox`. ## Get the source @@ -92,3 +94,10 @@ Use `arc diff` to submit your changes to Differential. Once your changes have been accepted, run `arc land` on your local branch to merge/push the commit and close the diff. + +## Releases + +The `release` target of the `Makefile` in this repository uses `gox` to +cross-compile binary releases of Blubber. + + make release diff --git a/Makefile b/Makefile index cb06b90..9a73549 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +RELEASE_DIR ?= ./_release +TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64 plan9/amd64 + PACKAGE := phabricator.wikimedia.org/source/blubber GO_LDFLAGS := \ @@ -7,4 +10,11 @@ GO_LDFLAGS := \ install: go install -v -ldflags "$(GO_LDFLAGS)" -.PHONY: install +release: + gox -output="$(RELEASE_DIR)/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' -ldflags '$(GO_LDFLAGS)' $(PACKAGE) + cp LICENSE "$(RELEASE_DIR)" + for f in "$(RELEASE_DIR)"/*/blubber; do \ + shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256"; \ + done + +.PHONY: install release -- cgit v1.2.1