From 36f46342bcad6782df230f0b69aadac4cf4972ae Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Tue, 13 Nov 2018 10:28:50 -0800 Subject: [PATCH] Trying to autoplublish releases --- .circleci/config.yml | 52 +++++++++++++++++++++++++++++++++++++++++++- Makefile | 14 +++++++++++- binary-name.sh | 44 +++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 2 deletions(-) create mode 100755 binary-name.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 9db1b0aa7..86fe2453b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,11 +12,61 @@ jobs: - run: sudo apt-get install -y cmake - run: rustup default nightly-2018-10-07 - run: make test - + - run: + command: | + make release + mkdir -p artifacts + cp ./target/release/wasmer ./artifacts/$(./binary-name.sh) + - persist_to_workspace: + root: . + paths: + - artifacts - save_cache: paths: - /usr/local/cargo/registry - target/debug/.fingerprint - target/debug/build - target/debug/deps + - target/release/build + - target/release/deps key: v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + + # create-release-artifacts-mac: + # macos: + # xcode: "9.0" + # - checkout + + publish-github-release: + docker: + - image: cibuilds/github + steps: + - attach_workspace: + at: . + - run: + name: "Publish Release on GitHub" + command: | + # go get github.com/tcnksm/ghr + # VERSION=$(git log -1 --pretty=%B) + VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) + # VERSION=${CIRCLE_TAG} + # VERSION=$(./artifacts/ --version) + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/ + +workflows: + version: 2 + main: + jobs: + - build + # : + # filters: + # tags: + # only: /^\d+\.\d+\.\d+$/ + + - publish-github-release: + requires: + - build + # filters: + # branches: + # ignore: /.*/ + # tags: + # only: /^\d+\.\d+\.\d+$/ diff --git a/Makefile b/Makefile index af631c70a..88ed6525d 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ spectests: WASM_GENERATE_SPECTESTS=1 cargo build # clean: -# rm -rf target +# rm -rf artifacts build: cargo build @@ -15,3 +15,15 @@ install: test: cargo test -- --test-threads=1 + +release: + # If you are in OS-X, you will need mingw-w64 for cross compiling to windows + # brew install mingw-w64 + cargo build --release + # mkdir -p artifacts + # BINARY_NAME := $(./binary-name.sh) + # cp ./target/release/wasmer ./artifacts/$(./binary-name.sh) + # cp ./target/release/wasmer ./artifacts/${BINARY_NAME} + +publish-release: + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/ diff --git a/binary-name.sh b/binary-name.sh new file mode 100755 index 000000000..98a3a8497 --- /dev/null +++ b/binary-name.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +initArch() { + ARCH=$(uname -m) + if [ -n "$WASMER_ARCH" ]; then + ARCH="$WASMER_ARCH" + fi + case $ARCH in + amd64) ARCH="amd64";; + x86_64) ARCH="amd64";; + i386) ARCH="386";; + *) echo "Architecture ${ARCH} is not supported by this installation script"; exit 1;; + esac +} + +initOS() { + OS=$(uname | tr '[:upper:]' '[:lower:]') + if [ -n "$WASMER_OS" ]; then + echo "Using WASMER_OS" + OS="$WASMER_OS" + fi + case "$OS" in + darwin) OS='darwin';; + linux) OS='linux';; + freebsd) OS='freebsd';; + mingw*) OS='windows';; + msys*) OS='windows';; + *) echo "OS ${OS} is not supported by this installation script"; exit 1;; + esac +} + +# identify platform based on uname output +initArch +initOS + +# determine install directory if required +BINARY="wasmer-${OS}-${ARCH}" + +# add .exe if on windows +if [ "$OS" = "windows" ]; then + BINARY="$BINARY.exe" +fi + +echo "${BINARY}"