diff --git a/Makefile b/Makefile index f17d308d..c7e12a67 100644 --- a/Makefile +++ b/Makefile @@ -249,36 +249,43 @@ distclean: clean ################################################# BINARY_OUTPUT=$(OUTPUT_ROOT)binary/ -BUNDLE_MAKE=v=$v GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2)' PREFIX=$(3) make $(3)bin/$(BINNAME) $(3)bin/$(CLOUDKMS_BINNAME) RELEASE=./.travis-releases -binary-linux: - $(call BUNDLE_MAKE,linux,amd64,$(BINARY_OUTPUT)linux/) - -binary-darwin: - $(call BUNDLE_MAKE,darwin,amd64,$(BINARY_OUTPUT)darwin/) - -define BUNDLE - $(q)BUNDLE_DIR=$(BINARY_OUTPUT)$(1)/bundle; \ - stepName=step-certificates_$(2); \ - mkdir -p $$BUNDLE_DIR $(RELEASE); \ - TMP=$$(mktemp -d $$BUNDLE_DIR/tmp.XXXX); \ - trap "rm -rf $$TMP" EXIT INT QUIT TERM; \ - newdir=$$TMP/$$stepName; \ - mkdir -p $$newdir/bin; \ - cp $(BINARY_OUTPUT)$(1)/bin/$(BINNAME) $$newdir/bin/; \ - cp $(BINARY_OUTPUT)$(1)/bin/$(CLOUDKMS_BINNAME) $$newdir/bin/; \ - cp README.md $$newdir/; \ - NEW_BUNDLE=$(RELEASE)/step-certificates_$(2)_$(1)_$(3).tar.gz; \ - rm -f $$NEW_BUNDLE; \ - tar -zcvf $$NEW_BUNDLE -C $$TMP $$stepName; +define BUNDLE_MAKE + # $(1) -- Go Operating System (e.g. linux, darwin, windows, etc.) + # $(2) -- Go Architecture (e.g. amd64, arm, arm64, etc.) + # $(3) -- Go ARM architectural family (e.g. 7, 8, etc.) + # $(4) -- Parent directory for executables generated by 'make'. + $(q) GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2) GOARM=$(3)' PREFIX=$(4) make $(4)bin/$(BINNAME) $(4)bin/$(CLOUDKMS_BINNAME) endef -bundle-linux: binary-linux - $(call BUNDLE,linux,$(VERSION),amd64) +binary-linux: + $(call BUNDLE_MAKE,linux,amd64,,$(BINARY_OUTPUT)linux/) + +binary-linux-arm64: + $(call BUNDLE_MAKE,linux,arm64,,$(BINARY_OUTPUT)linux.arm64/) + +binary-linux-armv7: + $(call BUNDLE_MAKE,linux,arm,7,$(BINARY_OUTPUT)linux.armv7/) + +binary-darwin: + $(call BUNDLE_MAKE,darwin,amd64,,$(BINARY_OUTPUT)darwin/) + +define BUNDLE + # $(1) -- Binary Output Dir Name + # $(2) -- Step Platform Name + # $(3) -- Step Binary Architecture + # $(4) -- Step Binary Name (For Windows Comaptibility) + $(q) ./make/bundle.sh "$(BINARY_OUTPUT)$(1)" "$(RELEASE)" "$(VERSION)" "$(2)" "$(3)" "$(4)" "$(5)" +endef + +bundle-linux: binary-linux binary-linux-arm64 binary-linux-armv7 + $(call BUNDLE,linux,linux,amd64,$(BINNAME),$(CLOUDKMS_BINNAME)) + $(call BUNDLE,linux.arm64,linux,arm64,$(BINNAME),$(CLOUDKMS_BINNAME)) + $(call BUNDLE,linux.armv7,linux,armv7,$(BINNAME),$(CLOUDKMS_BINNAME)) bundle-darwin: binary-darwin - $(call BUNDLE,darwin,$(VERSION),amd64) + $(call BUNDLE,darwin,darwin,amd64,$(BINNAME),$(CLOUDKMS_BINNAME)) .PHONY: binary-linux binary-darwin bundle-linux bundle-darwin diff --git a/make/bundle.sh b/make/bundle.sh new file mode 100755 index 00000000..437a7f92 --- /dev/null +++ b/make/bundle.sh @@ -0,0 +1,30 @@ +#/bin/sh +set -ex; + +OUTPUT_DIR=$1 +RELEASE_DIR=$2 + +STEP_VERSION=$3 +STEP_PLATFORM=$4 +STEP_ARCH=$5 +STEP_EXEC_NAME=$6 +STEP_CLOUDKMS_EXEC_NAME=$7 + +BUNDLE_DIR=${OUTPUT_DIR}/bundle + +mkdir -p "$BUNDLE_DIR" "$RELEASE_DIR" +TMP=$(mktemp -d "$BUNDLE_DIR/tmp.XXXX") +trap "rm -rf $TMP" EXIT INT QUIT TERM + +stepName=step-certificates_${STEP_VERSION} +newdir="$TMP/${stepName}" +mkdir -p "$newdir/bin" + +cp "$OUTPUT_DIR/bin/${STEP_EXEC_NAME}" "$newdir/bin/${STEP_EXEC_NAME}" +cp "$OUTPUT_DIR/bin/${STEP_CLOUDKMS_EXEC_NAME}" "$newdir/bin/${STEP_CLOUDKMS_EXEC_NAME}" + +cp README.md "$newdir" +NEW_BUNDLE="${RELEASE_DIR}/step-certificates_${STEP_PLATFORM}_${STEP_VERSION}_${STEP_ARCH}.tar.gz" + +rm -f "$NEW_BUNDLE" +tar -zcvf "$NEW_BUNDLE" -C "$TMP" "${stepName}"