From 7eb44a97802470225ed5637bae2ac84678bc928c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Wed, 30 May 2018 10:34:45 -0500 Subject: [PATCH] Configure Linux & macOS multi-arch releases using Travis CI (#3) * Test multi arch Travis CI build configuration * Enable Docker as required for cross compilation * Use even more arhitecture targets when building * Disable BSD builds, install ARM cross compiler dependencies * Fix invalid ARM target tuple * Use regular cargo commands for x86_64 Linux * Fix invalid ARM target tuples * Configure multi-platform releases using Travis CI, move from test builds * Enable caching for all Linux x86_64 stable builds on Travis CI * Merge Linux x86_64, macOS and other build arch logic with an if-statement * Add missing arch architecture release configuration * Enable cache on all CI jobs, with platform/arch/version cache separation * Don't explicitly set cache name, it's automatically inferred --- .travis.yml | 109 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 322b9b8..90330f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ # Configuration for Travis CI language: rust -sudo: false +sudo: required +services: + - docker addons: apt: packages: @@ -14,40 +16,127 @@ stages: jobs: include: + ################################ + # Build stage # + ################################ + + # Linux with Rust stable/beta/nightly - stage: build rust: stable + env: TARGET=x86_64-unknown-linux-gnu + cache: cargo script: &build-script - cargo build --verbose --all - cargo build --no-default-features --verbose --all - cargo build --features no-color --verbose --all - cache: cargo - stage: build rust: beta + env: TARGET=x86_64-unknown-linux-gnu + cache: cargo script: *build-script - stage: build rust: nightly + env: TARGET=x86_64-unknown-linux-gnu + cache: cargo script: *build-script + + # macOS with Rust stable - stage: build rust: stable os: osx - script: *build-script - - stage: test - script: cargo test --verbose --all + env: TARGET=x86_64-apple-darwin cache: cargo + script: *build-script + + ################################ + # Test stage # + ################################ + + - stage: test + env: TARGET=x86_64-unknown-linux-gnu + cache: cargo + script: cargo test --verbose --all + + ################################ + # Release stage # + ################################ + + # Cargo crate release - stage: release - script: skip - deploy: + env: TARGET=x86_64-unknown-linux-gnu + cache: cargo + script: + - echo $CARGO_TOKEN | cargo login + - cargo publish --verbose + + # GitHub binary release for Linux on x86/x86_64 + - stage: release + rust: stable + env: TARGET=x86_64-unknown-linux-gnu + cache: cargo + script: &script-github-release + - | + if [ $TARGET == "x86_64-unknown-linux-gnu" ] || [ $TARGET == "x86_64-apple-darwin" ]; then + cargo build --release --verbose --all + else + echo 'Starting build using cross for cross compilation...' + cross build --target $TARGET --release --verbose --all + fi + - cd target/release + - tar -czvf $TRAVIS_BUILD_DIR/ffsend-$TARGET.tar.gz ffsend + - cd $TRAVIS_BUILD_DIR + deploy: &deploy-github-release provider: releases api_key: $GITHUB_OAUTH_TOKEN skip_cleanup: true + overwrite: false + file: ffsend-$TARGET.tar.gz on: tags: true branch: master - stage: release - script: - - echo $CARGO_TOKEN | cargo login - - cargo publish --verbose + rust: stable + env: TARGET=i686-unknown-linux-gnu cache: cargo + install: &install-github-release-cross + - cargo install cross + script: *script-github-release + deploy: *deploy-github-release + # GitHub binary release for Linux on arch + - stage: release + rust: stable + env: TARGET=aarch64-unknown-linux-gnu + cache: cargo + install: *install-github-release-cross + script: *script-github-release + deploy: *deploy-github-release + - stage: release + rust: stable + env: TARGET=arm-unknown-linux-gnueabi + cache: cargo + install: *install-github-release-cross + script: *script-github-release + deploy: *deploy-github-release + - stage: release + rust: stable + env: TARGET=armv7-unknown-linux-gnueabihf + cache: cargo + install: *install-github-release-cross + script: *script-github-release + deploy: *deploy-github-release + + # GitHub binary release for macOX + - stage: release + rust: stable + os: osx + env: TARGET=x86_64-apple-darwin + cache: cargo + script: *script-github-release + deploy: *deploy-github-release + +# TODO: add (Free)BSD architecture +# TODO: use regular cargo commands for x86_64 linux +# TODO: release a build for each architecture # TODO: enfore the git tag/crate version equality for releases # TODO: disable addons/rust installation for GitHub release job