Skip to content

Commit

Permalink
use travis to make releases to github (#83)
Browse files Browse the repository at this point in the history
When a tag is pushed we will following this patch also do a release
build if the debug build and tests passes. We will then being packaging
for each target, along with an archive for the source code. The packages
are named after the targets.

We do a normal debug build and tests first because these are cheaper to
do and will give a shorter turnaround time for developers if any tests
fail. You can also only run tests with debug builds.

Fixes #72.
  • Loading branch information
andreastt authored and jgraham committed Jun 22, 2016
1 parent b89e821 commit 54a9643
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 15 deletions.
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

0 comments on commit 54a9643

Please sign in to comment.