Skip to content

Commit

Permalink
👷 Add Travis CI (#14)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuning Zhang <codeworm96@outlook.com>
  • Loading branch information
codeworm96 authored and gaocegege committed Nov 29, 2018
1 parent ae137a9 commit 8be359f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Based on the "trust" template v0.1.2
# https://github.com/japaric/trust/tree/v0.1.2

dist: trusty
language: rust
services: docker
sudo: required

env:
global:
- CRATE_NAME=dy-weekly-generator

matrix:
include:
# Linux
- env: TARGET=x86_64-unknown-linux-gnu

# OSX
- env: TARGET=x86_64-apple-darwin
os: osx

before_install:
- set -e
- rustup self update

install:
- source ~/.cargo/env || true

script:
- bash ci/script.sh

after_script: set +e

before_deploy:
- sh ci/before_deploy.sh

deploy:
api_key:
secure: "okvpZgsc9tHlHiLsfhGaDxpllq0tYm3wdGSgBWfqKoSJ7E3qddF5fl0D2NgsmeYUJ1w6G6+Q9cWGtfXTzDb62XykQEZJyuXBkB9AGks/szzO1cdWhMF+tegzZJo2OtR666mXJ/0mP9nqUpjrShHNu3MTVTKy1tdty83OWpLGYRCpLyhRi5BPXXvowoqevN1Q3K4hANO/ZdPgHmVzL1gtQCzF3n3M1wcjtpj+LADjnuMjJYGlOkyMRn7DmsseAt+Zi2H05iXDM4mJKeQO3r2akRNqjD6OIfXX8ONF355cMc4EB4a0J8SUgIm0D2mzlt9Ebyb7kuyrm+5BGBr9/dv2d0G+07tvp5uddFLPMNOwdpNen5bjbpSz6duXCq+8ECBZlyfG0ENL5i3laGxTcPYGBLIdAtwzDbmo8phOtM/IyHm66SlgsGH3oWDBhNvMOiO+HObrXi6cILQJhx8QcBHY4O4/aL+IZGjvyNV30LyBkvyYxHoAw9P1aJMxS0QHqH7F40EJOLd4GDn8cyb0yGEtFDC8fOkEAvXUJXUw/Doar0CDMH2DLlAX0LtwJh5hgpq0TKcDFcnvhAkM7eeu5JAvW5+la6HflFMTVFxHBkDZoJS0gfXtoTu88DJBY8l0RTZZWnIrN+M2ZqzJn3adFRSUD+NyfWtHNJNWPyA2nnsk+Hs="
file_glob: true
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
on:
condition: $TRAVIS_RUST_VERSION = stable
tags: true
provider: releases
skip_cleanup: true

cache: cargo
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo

branches:
only:
# release tags
- /^v\d+\.\d+\.\d+.*$/
- master
31 changes: 31 additions & 0 deletions ci/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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

cargo build --target $TARGET --release

cp target/$TARGET/release/weekly-gen $stage/

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

rm -rf $stage
}

main
18 changes: 18 additions & 0 deletions ci/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This script takes care of testing your crate

set -ex

main() {
cargo build --target $TARGET
cargo build --target $TARGET --release

if [ ! -z $DISABLE_TESTS ]; then
return
fi

}

# we don't run the "test phase" when doing deploys
if [ -z $TRAVIS_TAG ]; then
main
fi

0 comments on commit 8be359f

Please sign in to comment.