Skip to content

Commit d22fd1b

Browse files
committed
Build binaries!
1 parent e14292a commit d22fd1b

5 files changed

Lines changed: 175 additions & 9 deletions

File tree

.travis.yml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,66 @@
1+
dist: trusty
12
language: rust
2-
rust:
3-
- stable
4-
- beta
5-
- nightly
3+
services: docker
4+
sudo: required
5+
6+
env:
7+
global:
8+
- CRATE_NAME=static-filez
9+
- BIN_NAME=static-filez
10+
11+
before_install:
12+
- set -e
13+
- rustup self update
14+
15+
install:
16+
- sh ci/install.sh
17+
- source ~/.cargo/env || true
18+
19+
script:
20+
- bash ci/script.sh
21+
22+
after_script: set +e
23+
24+
before_deploy:
25+
- sh ci/before_deploy.sh
626

727
matrix:
828
include:
9-
- rust: 1.29.1
29+
- rust: 1.29.2
1030
env: CLIPPY=YESPLEASE
1131
before_script: rustup component add clippy-preview
12-
script: cargo clippy --all-targets -- -D warnings
13-
- rust: 1.29.1
32+
script: cargo clippy --all -- -D warnings
33+
- rust: 1.29.2
1434
env: RUSTFMT=YESPLEASE
1535
before_script: rustup component add rustfmt-preview
1636
script: cargo fmt --all -- --check
1737

38+
# dist targets from https://github.com/japaric/trust
39+
- env: TARGET=x86_64-unknown-linux-gnu
40+
- env: TARGET=x86_64-unknown-linux-musl
41+
- env: TARGET=x86_64-apple-darwin
42+
os: osx
43+
44+
deploy:
45+
api_key:
46+
secure: "u0a8Ld+DjOOjiHGkqLAw1eDFnwMDc4PKNi7kuGRArfK4XM+edFP4d3G3Li7DSrGR/6Vm7d95OVHbQnBOdhN2YAZlvpXG4moU/N5/U28T0LfFukVEjDPlrQZlz7B9c9URu/dgI4s9u5RNaOeqpMTaK7RpDzHQjXK7p2RYTqmJ8TOeYi812q9k0+Y0SClWXT5sx08x/wPQT+QcCSh0nqvFYyssJ203/dr4IgVEzftvpggq7UcFR3A0YGoXpLn1rSm0johrSt/A7QOELbnoxR+bNKbFapQETyfnEuhltfv2jNe+VV0oHeeu7nPJMdG5Kw+rTbJgFHCiJTFsZWRPFrAq/rxnV/dzLQrQrPR1PTd2iEhUtQJPc3AT48xWH8ziQ5clNeN9Gx/CFao94emVBmQE6Ba0hyP77EXdtio0nIgBvd4yNXXtEOtzgEG2zEUAInVlAvxe1JKcMgGLIDuQYw7CTe0/bF/1F7UmG4qfSfDsBDGNjLwCOPlr7Np4DwqNMZRdxvFIwEsPkIy0B/7Xi4RvQoLTbwHllKJW8KCNji8FFFfY+TYzwe14PcwodpYC+LGNZK4PcwzYpPtX2PuXDWJdZHQlvedwAzktzmQ8Pkz+2wrV/EsGs5WENGWEpikaDFceZp1QgP2Nv+zFVCf2ddBv2ETuy+yRoR2A6LGrfwMNz0w="
47+
file_glob: true
48+
file: "$CRATE_NAME-$TRAVIS_TAG-$TARGET.*"
49+
on:
50+
condition: '"$TARGET" != ""'
51+
tags: true
52+
provider: releases
53+
skip_cleanup: true
54+
1855
branches:
1956
except:
2057
- staging.tmp
2158

22-
cache: cargo
23-
2459
notifications:
2560
email:
2661
on_success: never
62+
63+
cache: cargo
64+
before_cache:
65+
# Travis can't cache files that are not readable by "others"
66+
- chmod -R a+r $HOME/.cargo

ci/before_deploy.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This script takes care of packaging the build artifacts that will go in the
2+
# release zipfile
3+
4+
$SRC_DIR = $PWD.Path
5+
$STAGE = [System.Guid]::NewGuid().ToString()
6+
7+
Set-Location $ENV:Temp
8+
New-Item -Type Directory -Name $STAGE
9+
Set-Location $STAGE
10+
11+
$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
12+
13+
# TODO Update this to package the right artifacts
14+
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\$BIN_NAME.exe" '.\'
15+
16+
7z a "$ZIP" *
17+
18+
Push-AppveyorArtifact "$ZIP"
19+
20+
Remove-Item *.* -Force
21+
Set-Location ..
22+
Remove-Item $STAGE
23+
Set-Location $SRC_DIR

ci/before_deploy.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
# This script takes care of building your crate and packaging it for release
3+
4+
set -ex
5+
6+
main() {
7+
local src=$(pwd) \
8+
stage=
9+
10+
case $TRAVIS_OS_NAME in
11+
linux)
12+
stage=$(mktemp -d)
13+
;;
14+
osx)
15+
stage=$(mktemp -d -t tmp)
16+
;;
17+
esac
18+
19+
test -f Cargo.lock || cargo generate-lockfile
20+
21+
# TODO Update this to build the artifacts that matter to you
22+
cross build --bin $BIN_NAME --target $TARGET --release
23+
24+
# TODO Update this to package the right artifacts
25+
cp target/$TARGET/release/$BIN_NAME $stage/
26+
27+
cd $stage
28+
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
29+
cd $src
30+
31+
rm -rf $stage
32+
}
33+
34+
main

ci/install.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
main() {
5+
local target=
6+
if [ $TRAVIS_OS_NAME = linux ]; then
7+
target=x86_64-unknown-linux-musl
8+
sort=sort
9+
else
10+
target=x86_64-apple-darwin
11+
sort=gsort # for `sort --sort-version`, from brew's coreutils.
12+
fi
13+
14+
# Builds for iOS are done on OSX, but require the specific target to be
15+
# installed.
16+
case $TARGET in
17+
aarch64-apple-ios)
18+
rustup target install aarch64-apple-ios
19+
;;
20+
armv7-apple-ios)
21+
rustup target install armv7-apple-ios
22+
;;
23+
armv7s-apple-ios)
24+
rustup target install armv7s-apple-ios
25+
;;
26+
i386-apple-ios)
27+
rustup target install i386-apple-ios
28+
;;
29+
x86_64-apple-ios)
30+
rustup target install x86_64-apple-ios
31+
;;
32+
esac
33+
34+
# This fetches latest stable release
35+
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
36+
| cut -d/ -f3 \
37+
| grep -E '^v[0.1.0-9.]+$' \
38+
| $sort --version-sort \
39+
| tail -n1)
40+
curl -LSfs https://japaric.github.io/trust/install.sh | \
41+
sh -s -- \
42+
--force \
43+
--git japaric/cross \
44+
--tag $tag \
45+
--target $target
46+
}
47+
48+
main

ci/script.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# This script takes care of testing your crate
3+
4+
set -ex
5+
6+
# TODO This is the "test phase", tweak it as you see fit
7+
main() {
8+
cross build --target $TARGET
9+
cross build --target $TARGET --release
10+
11+
if [ ! -z $DISABLE_TESTS ]; then
12+
return
13+
fi
14+
15+
cross test --target $TARGET
16+
}
17+
18+
# we don't run the "test phase" when doing deploys
19+
if [ -z $TRAVIS_TAG ]; then
20+
main
21+
fi

0 commit comments

Comments
 (0)