summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-06-25 02:10:48 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-06-25 02:23:23 -0700
commit1c90502a3c4f735a7546a1147b100946f1a5af01 (patch)
treec932a54055229911f120fcc15e54d266bfae849f /ci
parent3216d47824f3f15e11a60132b2c559fc4796d59c (diff)
Add CI courtesy of trust & cross
Diffstat (limited to 'ci')
-rw-r--r--ci/before_deploy.ps122
-rw-r--r--ci/before_deploy.sh31
-rw-r--r--ci/install.sh47
-rw-r--r--ci/script.sh24
4 files changed, 124 insertions, 0 deletions
diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1
new file mode 100644
index 0000000..5bc9388
--- /dev/null
+++ b/ci/before_deploy.ps1
@@ -0,0 +1,22 @@
+# This script takes care of packaging the build artifacts that will go in the
+# release zipfile
+
+$SRC_DIR = $pwd.Path
+$STAGE = [System.Guid]::NewGuid().ToString()
+
+Set-Location $env:TEMP
+New-Item -Type Directory -Name $STAGE
+Set-Location $STAGE
+
+$ZIP = "$SRC_DIR\$($env:CRATE_NAME)-$($env:APPVEYOR_REPO_TAG_NAME)-$($env:TARGET).zip"
+
+Copy-Item "$SRC_DIR\target\$($env:TARGET)\release\$($env:CRATE_NAME).exe" '.\'
+
+7z a "$ZIP" *
+
+Push-AppveyorArtifact "$ZIP"
+
+Remove-Item *.* -Force
+Set-Location ..
+Remove-Item $STAGE
+Set-Location $SRC_DIR
diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh
new file mode 100644
index 0000000..7525d8c
--- /dev/null
+++ b/ci/before_deploy.sh
@@ -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
+
+ cross rustc --bin so --target $TARGET --release -- -C lto
+
+ cp target/$TARGET/release/so $stage/
+
+ cd $stage
+ tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
+ cd $src
+
+ rm -rf $stage
+}
+
+main
diff --git a/ci/install.sh b/ci/install.sh
new file mode 100644
index 0000000..3e96e97
--- /dev/null
+++ b/ci/install.sh
@@ -0,0 +1,47 @@
+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
+
+ # Builds for iOS are done on OSX, but require the specific target to be
+ # installed.
+ case $TARGET in
+ aarch64-apple-ios)
+ rustup target install aarch64-apple-ios
+ ;;
+ armv7-apple-ios)
+ rustup target install armv7-apple-ios
+ ;;
+ armv7s-apple-ios)
+ rustup target install armv7s-apple-ios
+ ;;
+ i386-apple-ios)
+ rustup target install i386-apple-ios
+ ;;
+ x86_64-apple-ios)
+ rustup target install x86_64-apple-ios
+ ;;
+ esac
+
+ # This fetches latest stable release
+ local tag=$(git ls-remote --tags --refs --exit-code https://github.com/rust-embedded/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 rust-embedded/cross \
+ --tag $tag \
+ --target $target
+}
+
+main
diff --git a/ci/script.sh b/ci/script.sh
new file mode 100644
index 0000000..6c3703f
--- /dev/null
+++ b/ci/script.sh
@@ -0,0 +1,24 @@
+# This script takes care of testing your crate
+
+set -ex
+
+main() {
+ local features="--features reqwest/native-tls-vendored"
+ if [[ $TARGET =~ .*-freebsd ]]; then
+ features="--features reqwest/rustls-tls"
+ fi
+
+ cross build $features --target $TARGET
+ cross build $features --target $TARGET --release
+
+ if [ ! -z $DISABLE_TESTS ]; then
+ return
+ fi
+
+ cross test $features --target $TARGET
+}
+
+# we don't run the "test phase" when doing deploys
+if [ -z $TRAVIS_TAG ]; then
+ main
+fi