version: 2 jobs: # Job used for testing test: docker: - image: circleci/rust:latest steps: - checkout - run: name: Pull submodules command: | # git pull --recurse-submodules git submodule sync --recursive git submodule update --recursive --init - restore_cache: keys: - v4-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }} - run: sudo apt-get install -y cmake - run: make test - save_cache: paths: - /usr/local/cargo/registry - target/debug/.fingerprint - target/debug/build - target/debug/deps key: v4-test-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }} test-and-build: docker: - image: circleci/rust:latest steps: - checkout - run: name: Pull submodules command: | # git pull --recurse-submodules git submodule sync --recursive git submodule update --recursive --init - restore_cache: keys: - v4-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }} - run: sudo apt-get install -y cmake - run: name: Execute tests command: make test - run: name: Make release build command: | make release mkdir -p artifacts VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) GIT_VERSION=$(git describe --exact-match --tags) echo "${VERSION}" >> artifacts/version echo "${GIT_VERSION}" >> artifacts/git_version 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/.fingerprint - target/release/build - target/release/deps key: v4-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }} test-and-build-macos: macos: xcode: "9.0" steps: - checkout - run: name: Pull submodules command: | # git pull --recurse-submodules git submodule sync --recursive git submodule update --recursive --init - restore_cache: keys: - v4-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }} - run: name: Install CMAKE command: | curl -O https://cmake.org/files/v3.4/cmake-3.4.1-Darwin-x86_64.tar.gz tar xf cmake-3.4.1-Darwin-x86_64.tar.gz export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" - run: name: Install Rust command: | curl https://sh.rustup.rs -sSf | sh -s -- -y export PATH="$HOME/.cargo/bin:$PATH" cargo --version - run: name: Execute tests command: | export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" export PATH="$HOME/.cargo/bin:$PATH" make test - run: name: Make release build command: | export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" export PATH="$HOME/.cargo/bin:$PATH" make release mkdir -p artifacts # VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) # echo "${VERSION}" >> artifacts/version 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/.fingerprint - target/release/build - target/release/deps key: v4-cargo-cache-darwin-{{ arch }}-{{ checksum "Cargo.lock" }} 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=$(./artifacts/ --version) VERSION=$(cat ./artifacts/version) rm ./artifacts/version # VERSION_TAG=${CIRCLE_TAG} VERSION_TAG=$(cat ./artifacts/git_version) # VERSION_TAG=$(git describe --exact-match --tags) if [ "$VERSION" == "$VERSION_TAG" ]; then echo "Versions match, publishing to Github" ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/ else echo "Versions don't match. Wasmer output version (wasmer --version) is ${VERSION} while Git tag is ${VERSION_TAG}" exit 1 fi workflows: version: 2 main: jobs: - test: filters: branches: ignore: master - test-and-build: filters: branches: only: master - test-and-build-macos: filters: branches: only: master # : # filters: # tags: # only: /^\d+\.\d+\.\d+$/ - publish-github-release: requires: - test-and-build - test-and-build-macos filters: tags: only: /^\d+\.\d+\.\d+$/