Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Travis to make releases to Github #83

Merged
merged 1 commit into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ matrix:
- gcc-arm-linux-gnueabihf
- libc6-armhf-cross
- libc6-dev-armhf-cross
- env: TARGET=i686-unknown-linux-gnu
addons:
apt:
packages:
- gcc-multilib
- env: TARGET=x86_64-unknown-linux-gnu
- env: TARGET=x86_64-unknown-linux-musl
dist: trusty
sudo: required
Expand All @@ -29,10 +23,8 @@ matrix:
apt:
packages:
- gcc-mingw-w64
- gcc-mingw-w64-i686
- gcc-mingw-w64-x86-64
- binutils-mingw-w64-x86-64
- binutils-mingw-w64-i686
- libbz2-dev

install:
Expand All @@ -47,3 +39,18 @@ script:
branches:
only:
- master

deploy:
provider: releases
api_key:
secure:
OY6y0xRhlGSBH+3+7+7K6s4pp0Tf3BA61NAubEK4gpO23AKfyJUK+vqqCbdo06Z0E4QO4O1ke6fot7Gq9EdxJmsl/Kk5LDd9Rv3BXSYdjPupzs7coYuD8wv10NfAX6ETd9ITyPim2Zq6bq8nx1S2ESTpos/js1HCtVW3nrlCV58=
skip_cleanup: true
file:
- "geckodriver-$TRAVIS_TAG.tar.gz"
- "geckodriver-$TRAVIS_TAG-arm7hf.zip"
- "geckodriver-$TRAVIS_TAG-win64.zip"
- "geckodriver-$TRAVIS_TAG-linux64.tar.gz"
on:
tags: true
repo: mozilla/geckodriver
80 changes: 73 additions & 7 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,99 @@ linker = "$prefix-gcc"
EOF
}

# Build current crate and print file type information.
# Build current crate for given target and print file type information.
# If the second argument is set, a release build will be made.
cargo_build() {
cargo build --target $1

if [[ "$1" =~ "windows" ]]
local mode
if [ -z "$2" ]
then
file target/$1/debug/geckodriver.exe
mode=debug
else
file target/$1/debug/geckodriver
mode=release
fi

local modeflag
if [ "$mode" == "release" ]
then
modeflag=--release
fi

cargo build --target $1 $modeflag

file $(get_binary $1 $mode)
}

# Run current crate's tests if the current system supports it.
cargo_test() {
if echo "$1" | grep -E "(i686|x86_64)-unknown-linux-(gnu|musl)"
then
cargo test --target $1
fi
}

# Returns relative path to binary
# based on build target and type ("release"/"debug").
get_binary() {
local ext
if [[ "$1" =~ "windows" ]]
then
ext=".exe"
fi
echo "target/$1/$2/geckodriver$ext"
}

# Create a compressed archive of the binary
# for the given given git tag, build target, and build type.
package_binary() {
local target
case "$2" in
armv7-unknown-linux-gnueabihf)
target=arm7hf
;;
x86_64-pc-windows-gnu)
target=win64
;;
x86_64-unknown-linux-musl)
target=linux64
;;
esac

local bin
bin=$(get_binary $2 $3)
cp $bin .

if [[ "$2" =~ "windows" ]]
then
zip geckodriver-$1-$target.zip geckodriver.exe
file geckodriver-$1-$target.zip
else
>&2 echo "not running tests on $1"
tar zcvf geckodriver-$1-$target.tar.gz geckodriver
file geckodriver-$1-$target.tar.gz
fi
}

# Create a compressed archive of the source code
# for the given git tag.
package_source() {
git archive --format=tar --prefix="geckodriver-$1/" $1 | \
gzip >geckodriver-$1.tar.gz
}

main() {
rustup_target_add $TARGET

cargo_config $TARGET
cargo_build $TARGET
cargo_test $TARGET

# when something is tagged,
# also create a release build and package it
if [ ! -z "$TRAVIS_TAG" ]
then
cargo_build $TARGET 1
package_binary $TRAVIS_TAG $TARGET "release"
package_source $TRAVIS_TAG
fi
}

main