Skip to content

Commit

Permalink
feat: Deploy builds using trust and cross
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Feb 3, 2018
1 parent a812942 commit 372a278
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 3 deletions.
36 changes: 33 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
language: rust
sudo: required
services: docker
cache: cargo
matrix:
include:
- rust: nightly-2017-12-18
- rust: beta
- rust: stable
env:
- DEPLOY=1
- TARGET=x86_64-unknown-linux-gnu
- rust: nightly-2017-12-18
env: WASM=1

# Only for deployment
- if: tag IS present
env:
- TARGET=x86_64-pc-windows-gnu
- DEPLOY=1
- if: tag IS present
env:
- TARGET=x86_64-apple-darwin
- DEPLOY=1
os: osx
os:
- linux

before_install:
- set -e
- rustup self update
install:
- sh scripts/install_cross.sh
- source ~/.cargo/env || true

env:
- RUST_BACKTRACE=1
global:
- CRATE_NAME=gluon
- RUST_BACKTRACE=1
script:
- >
if [[ -z ${WASM+set} ]]; then
Expand All @@ -20,20 +45,25 @@ script:
rustup target add wasm32-unknown-unknown
cargo check --target wasm32-unknown-unknown -p gluon_c-api
fi
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/78796507a78a48a4b18e
on_success: change
on_failure: always
on_start: never

before_deploy:
- sh scripts/before_deploy.sh
deploy:
provider: releases
api_key:
secure: ImhF+DkxyHyzDQ4SZZlATjgkrzr+yY1xwADxgO2B5Xi+C7AOllkPInSB/RL+C6tebQnxIEop7KU0N4svbIw6zuoDmOvkliP++U1gXDqvpggBT7AXM5ICcLKWUzTdh3XexhL5SUmtH+QvWRwFwcOoq6mic8rc6DSvTojB/NydyJCeHGvx5iSl5o/ZSqrnEjOF/yDMXADVNwQRZebzyXss+wtTfEbD7OZoJ9ihPugDES8EkmScwS/UCJfCfEqBf/AwDSaAxVpPB/2PF7J0bDIB1ORrwA4HUguJ/U5QuV4vea0hNhhIzzwfcsbPhPLARcLENZLirUk3iygbwSPCTNg+8yEz0MPJQVTj/T48cbKkn9rgZfWi3Bs9nyv22ZouKBFQooiQD6b7WhVGY8bA1Q39cTSLfrR9WrkiRS3x11QrNkwWUqvWHb+2u0KtovTnCt9Lxrx0j8WKMO5Onx6hLfGfH00puCNpV8keWqkzriSi7/ce4mBl8HTvFX22bKZ5uZAxX2mPodAtWoh8hgOGMZhjG2ODS1CEQBxWw5nCXkKQE1afaJOEjhzXmmSNzTnfWIFQGk6V9T9LF8u/PrSVmkQCgka/arlUQlKl+Fa8XUEx8DZEHptj2OdP86A2qiUOcsAmYF2z19kYziHYK3Ll1xDPoOSil6Eej5t+n/e37bmvTMY=
file: target/release/gluon
file_glob: true
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
skip_cleanup: true
on:
rust: stable
tags: true
repo: gluon-lang/gluon
condition: $DEPLOY = 1
41 changes: 41 additions & 0 deletions scripts/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This script takes care of building your crate and packaging it for release

set -ex

main() {
local src=$(pwd) \
stage=

case $TRAVIS_OS_NAME in
linux)
stage=$(mktemp -d)
;;
osx)
stage=$(mktemp -d -t tmp)
;;
esac

test -f Cargo.lock || cargo generate-lockfile

cross build -p gluon_repl --target $TARGET --release

# Copy the files that are needed in the distribution
if [ -f target/$TARGET/release/gluon ]; then
cp target/$TARGET/release/gluon $stage/
elif [ -f target/$TARGET/release/gluon.exe ]; then
cp target/$TARGET/release/gluon.exe $stage/
else
echo "Could not find gluon executable"
exit 1
fi
mkdir $stage/std
cp -r std/* $stage/std/

cd $stage
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
cd $src

rm -rf $stage
}

main
27 changes: 27 additions & 0 deletions scripts/install_cross.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set -ex

main() {
local target=
if [ $TRAVIS_OS_NAME = linux ]; then
target=x86_64-unknown-linux-musl
sort=sort
else
target=x86_64-apple-darwin
sort=gsort # for `sort --sort-version`, from brew's coreutils.
fi

# This fetches latest stable release
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
| cut -d/ -f3 \
| grep -E '^v[0.1.0-9.]+$' \
| $sort --version-sort \
| tail -n1)
curl -LSfs https://japaric.github.io/trust/install.sh | \
sh -s -- \
--force \
--git japaric/cross \
--tag $tag \
--target $target
}

main

0 comments on commit 372a278

Please sign in to comment.