Skip to content

Commit 96e75fd

Browse files
authored
Merge pull request #10 from mrksu/multiplatform-ci
Configure CI for multiplatform deployments
2 parents 13d22a6 + ea59fe7 commit 96e75fd

File tree

6 files changed

+342
-0
lines changed

6 files changed

+342
-0
lines changed

.travis.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Based on the "trust" template v0.1.2
2+
# https://github.com/japaric/trust/tree/v0.1.2
3+
4+
dist: bionic
5+
language: rust
6+
services: docker
7+
sudo: required
8+
9+
# TODO Rust builds on stable by default, this can be
10+
# overridden on a case by case basis down below.
11+
12+
env:
13+
global:
14+
- CRATE_NAME=newdoc
15+
16+
matrix:
17+
# TODO These are all the build jobs. Adjust as necessary. Comment out what you
18+
# don't need
19+
include:
20+
# # Android
21+
# - env: TARGET=aarch64-linux-android DISABLE_TESTS=1
22+
# - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1
23+
# - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1
24+
# - env: TARGET=i686-linux-android DISABLE_TESTS=1
25+
# - env: TARGET=x86_64-linux-android DISABLE_TESTS=1
26+
27+
# # iOS
28+
# - env: TARGET=aarch64-apple-ios DISABLE_TESTS=1
29+
# os: osx
30+
# - env: TARGET=armv7-apple-ios DISABLE_TESTS=1
31+
# os: osx
32+
# - env: TARGET=armv7s-apple-ios DISABLE_TESTS=1
33+
# os: osx
34+
# - env: TARGET=i386-apple-ios DISABLE_TESTS=1
35+
# os: osx
36+
# - env: TARGET=x86_64-apple-ios DISABLE_TESTS=1
37+
# os: osx
38+
39+
# Linux
40+
- env: TARGET=aarch64-unknown-linux-gnu
41+
- env: TARGET=arm-unknown-linux-gnueabi
42+
- env: TARGET=armv7-unknown-linux-gnueabihf
43+
- env: TARGET=i686-unknown-linux-gnu
44+
- env: TARGET=i686-unknown-linux-musl
45+
- env: TARGET=mips-unknown-linux-gnu
46+
- env: TARGET=mips64-unknown-linux-gnuabi64
47+
- env: TARGET=mips64el-unknown-linux-gnuabi64
48+
- env: TARGET=mipsel-unknown-linux-gnu
49+
- env: TARGET=powerpc-unknown-linux-gnu
50+
- env: TARGET=powerpc64-unknown-linux-gnu
51+
- env: TARGET=powerpc64le-unknown-linux-gnu
52+
- env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1
53+
- env: TARGET=x86_64-unknown-linux-gnu
54+
- env: TARGET=x86_64-unknown-linux-musl
55+
56+
# OSX
57+
# - env: TARGET=i686-apple-darwin
58+
# os: osx
59+
- env: TARGET=x86_64-apple-darwin
60+
os: osx
61+
62+
# *BSD
63+
- env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
64+
- env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
65+
- env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1
66+
67+
# Windows
68+
- env: TARGET=x86_64-pc-windows-gnu
69+
70+
# Bare metal
71+
# These targets don't support std and as such are likely not suitable for
72+
# most crates.
73+
# - env: TARGET=thumbv6m-none-eabi
74+
# - env: TARGET=thumbv7em-none-eabi
75+
# - env: TARGET=thumbv7em-none-eabihf
76+
# - env: TARGET=thumbv7m-none-eabi
77+
78+
# # Testing other channels
79+
# - env: TARGET=x86_64-unknown-linux-gnu
80+
# rust: nightly
81+
# - env: TARGET=x86_64-apple-darwin
82+
# os: osx
83+
# rust: nightly
84+
85+
before_install:
86+
- set -e
87+
- rustup self update
88+
89+
install:
90+
- sh ci/install.sh
91+
- source ~/.cargo/env || true
92+
93+
script:
94+
- bash ci/script.sh
95+
96+
after_script: set +e
97+
98+
before_deploy:
99+
- sh ci/before_deploy.sh
100+
101+
deploy:
102+
api_key:
103+
secure: mtCvNJGAukCq1lm2hTTurvV0ockz7OZC61OY9mcx3vpIsAPIefebSq81J8T0hTbyqF7olbKp3ohqmNXmRlzHJfVSFaocnQuxVK7KSvdobjh+wJlp4GlReuXI6gsvlTCdb8IR6VHy1l20v/ONhuzRYFg+pfH53dAeTbXWVXgnDctsoBDwd1uJrI2LYDWwzk1amRSdfIZwHA0iQqqjDbWzpTnpaVyaN2PInYssobVPyWOyMRsnxn0biouKGWF5Y8rd5Q5PhD8uFVSMhBFQWwcviVBsoSgzQimox0crYdCnP/HR5ROElyVNpwnW8M9nFDXuOyXvSAFLWuxQ7dB0QE8chHLKT7m3KJk2YxqxaqrB0VbgzXvJHU8o3Gg2/Qpo5ww1d42AlAbSZurAFMt2IUZQQPvwVmnDjG3pTAlFPb0mCv/vmhfRYgx8n+CbFK9kxsMOgY857X2KwgDfygq7YAp9IYwcOi8zFiNyQnBVhhFiKHcD2ZpBLwJJ/vqLHzh2ZM32xma/oEnpixBgUr8is1JCk2GXHEo4eEOYAYTFx4zNZTaPoyn4yZD6i8BL7zBm3bKS55JfF/LtVMspFLLUJAhoJHzymSCQP1BuBEWjtOmPL00MdSbrFxlFH42xrgaZCWVaK624Or4GocGB3t0DENdQisq6W07p4OBoo8QIAwm49Cs=
104+
file_glob: true
105+
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
106+
on:
107+
# TODO Here you can pick which targets will generate binary releases
108+
# In this example, there are some targets that are tested using the stable
109+
# and nightly channels. This condition makes sure there is only one release
110+
# for such targets and that's generated using the stable channel
111+
condition: $TRAVIS_RUST_VERSION = stable
112+
tags: true
113+
provider: releases
114+
skip_cleanup: true
115+
116+
cache: cargo
117+
before_cache:
118+
# Travis can't cache files that are not readable by "others"
119+
- chmod -R a+r $HOME/.cargo
120+
121+
branches:
122+
only:
123+
# release tags
124+
- /^v\d+\.\d+\.\d+.*$/
125+
- main
126+
127+
notifications:
128+
email:
129+
on_success: never

appveyor.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Based on the "trust" template v0.1.2
2+
# https://github.com/japaric/trust/tree/v0.1.2
3+
4+
environment:
5+
global:
6+
# TODO This is the Rust channel that build jobs will use by default but can be
7+
# overridden on a case by case basis down below
8+
RUST_VERSION: stable
9+
10+
CRATE_NAME: newdoc
11+
12+
matrix:
13+
# MinGW
14+
- TARGET: i686-pc-windows-gnu
15+
- TARGET: x86_64-pc-windows-gnu
16+
17+
# MSVC
18+
- TARGET: i686-pc-windows-msvc
19+
- TARGET: x86_64-pc-windows-msvc
20+
21+
# # Testing other channels
22+
# - TARGET: x86_64-pc-windows-gnu
23+
# RUST_VERSION: nightly
24+
# - TARGET: x86_64-pc-windows-msvc
25+
# RUST_VERSION: nightly
26+
27+
install:
28+
- ps: >-
29+
If ($env:TARGET -eq 'x86_64-pc-windows-gnu') {
30+
$env:PATH += ';C:\msys64\mingw64\bin'
31+
} ElseIf ($env:TARGET -eq 'i686-pc-windows-gnu') {
32+
$env:PATH += ';C:\msys64\mingw32\bin'
33+
}
34+
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
35+
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%
36+
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
37+
- rustc -Vv
38+
- cargo -V
39+
40+
# TODO This is the "test phase", tweak it as you see fit
41+
test_script:
42+
# we don't run the "test phase" when doing deploys
43+
- if [%APPVEYOR_REPO_TAG%]==[false] (
44+
cargo build --target %TARGET% &&
45+
cargo build --target %TARGET% --release &&
46+
cargo test --target %TARGET% &&
47+
cargo test --target %TARGET% --release &&
48+
cargo run --target %TARGET% &&
49+
cargo run --target %TARGET% --release
50+
)
51+
52+
before_deploy:
53+
# TODO Update this to build the artifacts that matter to you
54+
- cargo rustc --target %TARGET% --release --bin %CRATE_NAME% -- -C lto
55+
- ps: ci\before_deploy.ps1
56+
57+
deploy:
58+
artifact: /.*\.zip/
59+
auth_token:
60+
secure: 3meIOd9mQoTEZDO84dDbRZR4X8803pqY0xp+1qQhqHl7LbA9EGzeVSbsYk869DZ4
61+
description: ''
62+
on:
63+
# TODO Here you can pick which targets will generate binary releases
64+
# In this example, there are some targets that are tested using the stable
65+
# and nightly channels. This condition makes sure there is only one release
66+
# for such targets and that's generated using the stable channel
67+
RUST_VERSION: stable
68+
appveyor_repo_tag: true
69+
provider: GitHub
70+
71+
cache:
72+
- C:\Users\appveyor\.cargo\registry
73+
- target
74+
75+
branches:
76+
only:
77+
# Release tags
78+
- /^v\d+\.\d+\.\d+.*$/
79+
- master
80+
81+
notifications:
82+
- provider: Email
83+
on_build_success: false
84+
85+
# Building is done in the test phase, so we disable Appveyor's build phase.
86+
build: false

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

ci/install.sh

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

ci/script.sh

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

0 commit comments

Comments
 (0)