From 9179bc353e91cb119188b336b11a67d3b43ee1a5 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Tue, 7 Jan 2020 11:09:31 +0100 Subject: [PATCH] feat: add binary support for macos x86_64-apple-darwin (resolves #8) --- .drone.yml | 34 +++++++++++++++------------------- .gitignore | 1 + Makefile | 43 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6ab73da..1546aac 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,7 +12,7 @@ pipeline: # DEVELOPMENT test: - image: ekidd/rust-musl-builder:stable + image: joseluisq/rust-linux-darwin-builder:1.40.0 group: development commands: - make test @@ -22,7 +22,7 @@ pipeline: # PRODUCTION build-release: - image: ekidd/rust-musl-builder:stable + image: joseluisq/rust-linux-darwin-builder:1.40.0 group: production commands: - make prod.release @@ -71,27 +71,23 @@ pipeline: files: - ./bin/*.tar.gz - ./bin/*.zip + - ./bin/*-SHA256SUM prerelease: true - checksum: - - md5 - - sha1 when: event: tag - # publish-github-release: - # image: plugins/github-release - # group: production - # api_key: - # from_secret: github_token - # files: - # - ./bin/*.tar.gz - # - ./bin/*.zip - # prerelease: true - # checksum: - # - md5 - # - sha1 - # when: - # event: tag + publish-github-release: + image: plugins/github-release + group: production + api_key: + from_secret: github_token + files: + - ./bin/*.tar.gz + - ./bin/*.zip + - ./bin/*-SHA256SUM + prerelease: true + when: + event: tag publish-image-scratch-docker-hub: image: plugins/docker diff --git a/.gitignore b/.gitignore index 67d7a6b..8ed95aa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ **/*.bin **/*.iml **/.idea +**/.DS_Store diff --git a/Makefile b/Makefile index c09fff7..cb4ec1b 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,17 @@ PKG_TARGET=x86_64-unknown-linux-musl +PKG_TARGET_DARWIN=x86_64-apple-darwin + PKG_BIN_PATH=./bin +PKG_TMP_PATH=/tmp PKG_NAME=$(shell cat Cargo.toml | sed -n 's/name = "\([^}]*\)"/\1/p' | head -n1) PKG_TAG=$(shell cat Cargo.toml | sed -n 's/version = "\([^}]*\)"/\1/p' | head -n1) +PKG_RELEASE_NAME=$(PKG_NAME)-v$(PKG_TAG)-$(PKG_TARGET) +PKG_RELEASE_NAME_DARWIN=$(PKG_NAME)-v$(PKG_TAG)-$(PKG_TARGET_DARWIN) + +PKG_TMP_BIN_PATH=$(PKG_TMP_PATH)/$(PKG_RELEASE_NAME) +PKG_TMP_BIN_PATH_DARWIN=$(PKG_TMP_PATH)/$(PKG_RELEASE_NAME_DARWIN) ####################################### ############# Development ############# @@ -64,7 +72,8 @@ define build_release = echo "Compiling application..." rustc --version cargo build --release --target $(PKG_TARGET) - echo "Release build completed!" + cargo build --release --target $(PKG_TARGET_DARWIN) + echo "Release builds completed!" endef # Shrink a release binary size @@ -72,13 +81,23 @@ define build_release_shrink = set -e set -u - mkdir -p $(PKG_BIN_PATH) - cp -rf ./target/$(PKG_TARGET)/release/$(PKG_NAME) $(PKG_BIN_PATH) + echo "Copying release binaries..." + + # Linux + mkdir -p $(PKG_TMP_BIN_PATH) + cp -rf ./target/$(PKG_TARGET)/release/$(PKG_NAME) $(PKG_TMP_BIN_PATH) + + # Darwin + mkdir -p $(PKG_TMP_BIN_PATH_DARWIN) + cp -rf ./target/$(PKG_TARGET_DARWIN)/release/$(PKG_NAME) $(PKG_TMP_BIN_PATH_DARWIN) + + # Linux only + echo "Performing binary shrinking for $(PKG_TARGET) release..." echo "Size before:" - du -sh $(PKG_BIN_PATH)/$(PKG_NAME) - strip $(PKG_BIN_PATH)/$(PKG_NAME) + du -sh $(PKG_TMP_BIN_PATH)/$(PKG_NAME) + strip $(PKG_TMP_BIN_PATH)/$(PKG_NAME) echo "Size after:" - du -sh $(PKG_BIN_PATH)/$(PKG_NAME) + du -sh $(PKG_TMP_BIN_PATH)/$(PKG_NAME) echo "Release size shrinking completed!" endef @@ -87,9 +106,15 @@ define build_release_files = set -e set -u - cd $(PKG_BIN_PATH) && \ - tar czvf $(PKG_NAME)-v$(PKG_TAG)-x86_64-$(PKG_TARGET).tar.gz $(PKG_NAME) - du -sh ./* + # Linux + tar -C $(PKG_TMP_BIN_PATH) -czvf $(PKG_BIN_PATH)/$(PKG_RELEASE_NAME).tar.gz $(PKG_NAME) + sha256sum $(PKG_BIN_PATH)/$(PKG_RELEASE_NAME).tar.gz > $(PKG_BIN_PATH)/$(PKG_RELEASE_NAME)-SHA256SUM + + # Darwin + tar -C $(PKG_TMP_BIN_PATH_DARWIN) -czvf $(PKG_BIN_PATH)/$(PKG_RELEASE_NAME_DARWIN).tar.gz $(PKG_NAME) + sha256sum $(PKG_BIN_PATH)/$(PKG_RELEASE_NAME_DARWIN).tar.gz > $(PKG_BIN_PATH)/$(PKG_RELEASE_NAME_DARWIN)-SHA256SUM + + du -sh $(PKG_BIN_PATH)/* echo "Release tarball/zipball files created!" endef -- libgit2 1.7.2