Add windows travis builds

This commit is contained in:
Félix Saparelli 2019-10-28 13:01:55 +13:00
parent f7e1639ed1
commit 24204e7b71
No known key found for this signature in database
GPG Key ID: 25940898BB90EA51
6 changed files with 143 additions and 62 deletions

View File

@ -1,20 +1,38 @@
dist: xenial
language: rust
cache: cargo
dist: trusty
sudo: false
cache:
- directories:
- $HOME/.cargo
- target/debug/deps
- target/$TARGET/debug/deps
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo
addons:
apt:
packages:
- fakeroot
- musl-dev
- musl-tools
env:
global:
- PROJECT_NAME=watchexec
matrix:
fast_finish: true
allow_failures:
- env: CARGO_CLIPPY=1
- env: TARGET=i686-unknown-linux-musl
- env: TARGET=x86_64-unknown-linux-musl
- env: TARGET=x86_64-pc-windows-gnu
include:
# Default test+release version
# Default test+release versions
- os: windows
rust: stable
env: TARGET=x86_64-pc-windows-msvc
- os: osx
rust: stable
env: TARGET=x86_64-apple-darwin
@ -22,27 +40,32 @@ matrix:
rust: stable
env: TARGET=x86_64-unknown-linux-gnu
# Extra targets for linux only
# Extra targets, released on best-effort
- os: linux
rust: stable
env: TARGET=i686-unknown-linux-musl
- os: linux
rust: stable
env: TARGET=x86_64-unknown-linux-musl
- os: windows
rust: stable
env: TARGET=x86_64-pc-windows-gnu
# Minimum version advertised in readme
- os: windows
rust: 1.38.0
env: TARGET=x86_64-apple-darwin
- os: linux
rust: 1.38.0
env: TARGET=x86_64-unknown-linux-gnu
- os: osx
rust: 1.38.0
env: TARGET=x86_64-apple-darwin
fast_finish: true
before_script: ci/before_script.sh
# Clippy only
- env: CARGO_CLIPPY=1
before_install: ci/before.sh
script: ci/script.sh
before_deploy: ci/before_deploy.sh
before_deploy: ci/deploy.sh
deploy:
provider: releases
api_key:

18
ci/before.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
rustup target add $TARGET
cargo clean --target $TARGET --verbose
if [ $TRAVIS_OS_NAME = windows ]; then
choco install windows-sdk-10.1
fi
if [[ ! -z "$CARGO_AUDIT" ]]; then
which cargo-audit || cargo install --debug cargo-audit
# --debug for faster build at the minimal expense of runtime speed
elif [[ ! -z "$CARGO_CLIPPY" ]]; then
rustup component add clippy
fi

View File

@ -1,45 +0,0 @@
#!/usr/bin/env bash
# Build script shamelessly stolen from ripgrep :)
cargo build --target $TARGET --release --locked
build_dir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
out_dir=$(pwd)
name="${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}"
mkdir "$build_dir/$name"
cp target/$TARGET/release/watchexec "$build_dir/$name/"
cp {doc/watchexec.1,LICENSE,completions/zsh} "$build_dir/$name/"
pushd $build_dir
tar cvf "$out_dir/$name.tar" *
popd
gzip -f9 "$name.tar"
if [[ "$TARGET" == "x86_64-unknown-linux-gnu" ]]; then
mkdir -p "$build_dir/deb/$name"
pushd "$build_dir/deb/$name"
mkdir -p DEBIAN usr/bin usr/share/man/man1 usr/share/zsh/site-functions
cp "../../$name/watchexec" usr/bin/
cp "../../$name/watchexec.1" usr/share/man/man1/
cp "../../$name/zsh" usr/share/zsh/site-functions/_watchexec
cat <<CONTROL > DEBIAN/control
Package: watchexec
Version: ${TRAVIS_TAG}
Architecture: amd64
Maintainer: Félix Saparelli <aur@passcod.name>
Installed-Size: $(du -d1 usr | tail -n1 | cut -d\t -f1)
Homepage: https://github.com/watchexec/watchexec
Description: Executes commands in response to file modifications.
Software development often involves running the same commands over and over. Boring!
Watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications.
CONTROL
cd ..
fakeroot dpkg -b "$name"
mv "$name.deb" "$out_dir/"
popd
fi

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
rustup target add $TARGET
cargo clean --target $TARGET --verbose

83
ci/deploy.sh Executable file
View File

@ -0,0 +1,83 @@
#!/usr/bin/env bash
### Vars
project="$PROJECT_NAME"
tag="$TRAVIS_TAG"
target="$TARGET"
[[ -z "$project" ]] && exit 21
[[ -z "$tag" ]] && exit 22
[[ -z "$target" ]] && exit 23
ext=""
windows=""
if [[ "$target" == *"windows"* ]]; then
choco install 7zip
ext=".exe"
windows="1"
fi
project="cargo-watch"
build_dir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
out_dir=$(pwd)
name="$project-$tag-$target"
### Build
cargo build --target $target --release --locked
### Decorate
mkdir "$build_dir/$name"
cp -v "target/$target/release/$project$ext" "$build_dir/$name/"
cp -v LICENSE "$build_dir/$name/"
cp -v README.md "$build_dir/$name/"
cp -v completions/zsh "$build_dir/$name/"
cp -v doc/watchexec.1 "$build_dir/$name/"
ls -shal "$build_dir/$name/"
### Strip
cd "$build_dir"
strip "$name/$project$ext"
ls -shal "$name/"
### Pack
if [[ -z "$windows" ]]; then
tar cvf "$out_dir/$name.tar" "$name"
cd "$out_dir"
xz -f9 "$name.tar"
else
7z a "$out_dir/$name.zip" "$name"
fi
### Debify
if [[ "$target" == "x86_64-unknown-linux-gnu" ]]; then
mkdir -p "$build_dir/deb/$name"
cd "$build_dir/deb/$name"
mkdir -p DEBIAN usr/bin usr/share/man/man1 usr/share/zsh/site-functions
cp "../../$name/watchexec" usr/bin/
cp "../../$name/watchexec.1" usr/share/man/man1/
cp "../../$name/zsh" usr/share/zsh/site-functions/_watchexec
cat <<CONTROL > DEBIAN/control
Package: watchexec
Version: ${TRAVIS_TAG}
Architecture: amd64
Maintainer: Félix Saparelli <aur@passcod.name>
Installed-Size: $(du -d1 usr | tail -n1 | cut -d\t -f1)
Homepage: https://github.com/watchexec/watchexec
Description: Executes commands in response to file modifications.
Software development often involves running the same commands over and over. Boring!
Watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications.
CONTROL
cd ..
fakeroot dpkg -b "$name"
mv "$name.deb" "$out_dir/"
popd
fi
ls -shal "$out_dir/"

View File

@ -1,4 +1,10 @@
#!/usr/bin/env bash
cargo build --target $TARGET --verbose
cargo test --target $TARGET --verbose
if [[ ! -z "$CARGO_AUDIT" ]]; then
cargo check --target $TARGET
cargo audit
elif [[ ! -z "$CARGO_CLIPPY" ]]; then
cargo clippy --target $TARGET
else
cargo test --target $TARGET
fi