upload.sh 3.42 KB
Newer Older
1 2 3 4
#!/bin/sh

set -x

5 6
. ./travis-common.sh

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# Read out ACCOUNT and REPO from the slug
# Cribbed from http://unix.stackexchange.com/a/53323/118117
ACCOUNT=${TRAVIS_REPO_SLUG%%"/"*}
REPO=${TRAVIS_REPO_SLUG#*"/"}

# TAG will be used to uniquely identify a matrix entry; we
# need to push each matrix entry to a separate branch.
TAG="$TRAVIS_OS_NAME-$GHCVER$TAGSUFFIX"

# This is the commit for which we want a GitHub status update
# ping to go to.  Note that it is NOT TRAVIS_COMMIT unconditionally,
# since if we have a pull request, this commit will be a merge
# commit which no one from GitHub will be able to see.
COMMIT=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}

22 23 24
# This is just to help you correlate the build to what it's for
if [ "x$TRAVIS_PULL_REQUEST" != "xfalse" ]; then
    ORIGIN="${TRAVIS_REPO_SLUG}/pull/$TRAVIS_PULL_REQUEST"
25
    URL="pull/${TRAVIS_PULL_REQUEST}"
26 27
else
    ORIGIN="${TRAVIS_REPO_SLUG}/${TRAVIS_BRANCH}"
28
    URL="commits/${TRAVIS_BRANCH}"
29 30
fi

31 32
# Git will complain if these fields don't work when committing,
# so set them up.
33 34
git config --global user.name "$(git --no-pager show -s --format='%an' $COMMIT)"
git config --global user.email "$(git --no-pager show -s --format='%ae' $COMMIT)"
35 36 37 38
git config --global push.default simple

cd travis

39 40 41
# Setup SSH key we will use to push to binaries repository.
# umask to get the permissions to be 600 (not 400, because the deploy
# script in .travis.yml is going to clobber this private key)
42
(umask 177 && tr A-Za-z N-ZA-Mn-za-m < id_rsa.rot13 > $HOME/.ssh/id_rsa)
43 44 45 46 47 48 49 50 51 52 53 54 55

# Setup SSH keys
ssh-keyscan github.com >> $HOME/.ssh/known_hosts

cd binaries

# Setup binaries repository for pushing
git init
# TODO: Update this
git remote add origin git@github.com:haskell-pushbot/cabal-binaries.git

# Make some final modifications to .travis.yml based so
# that downstream builds with the correct configuration
Oleg Grenrus's avatar
Oleg Grenrus committed
56
echo "env: GHCVER=$GHCVER UPSTREAM_BUILD_DIR=$TRAVIS_BUILD_DIR CABAL_LIB_ONLY=$CABAL_LIB_ONLY TEST_OTHER_VERSIONS=$TEST_OTHER_VERSIONS" >> .travis.yml
57 58 59 60 61
echo "os: $TRAVIS_OS_NAME" >> .travis.yml
if [ "x$GHCVER" = "x7.8.4" ] && [ "x$TRAVIS_OS_NAME" = "xosx" ]; then
    echo "osx_image: xcode6.4" >> .travis.yml
fi

62 63 64 65 66
# Make directory layout
mkdir Cabal
mkdir cabal-install
cp -R $TRAVIS_BUILD_DIR/Cabal/tests                                  Cabal
cp -R $TRAVIS_BUILD_DIR/cabal-install/tests                          cabal-install
67
# Copy in credentials so we can delete branch when done
68
tr A-Za-z N-ZA-Mn-za-m < $TRAVIS_BUILD_DIR/travis/id_rsa.rot13 > id_rsa
69 70 71
# Install all of the necessary files for testing
cp $TRAVIS_BUILD_DIR/travis-install.sh .
cp $TRAVIS_BUILD_DIR/travis-common.sh .
72
# The binaries to test (statically linked, of course!)
73 74 75 76
cp ${CABAL_BDIR}/c/unit-tests/build/unit-tests/unit-tests          Cabal
cp ${CABAL_BDIR}/c/check-tests/build/check-tests/check-tests       Cabal
cp ${CABAL_BDIR}/c/parser-tests/build/parser-tests/parser-tests    Cabal
cp ${CABAL_BDIR}/c/hackage-tests/build/hackage-tests/hackage-tests Cabal
77 78 79
if [ "x$CABAL_LIB_ONLY" != "xYES" ]; then
    cp ${CABAL_INSTALL_BDIR}/build/cabal/cabal                       cabal-install
fi
80 81 82 83 84 85

# Add, commit, push
git add .
# The JSON in the commit message is used by the webhook listening
# on the downstream repo to figure out who to communicate the
# status update back to
86 87 88 89 90 91 92 93 94
git commit -m '{"origin":"'$ORIGIN'",

"url":"'$URL'",
"account":"'$ACCOUNT'",
"repo":"'$REPO'",
"commit": "'$COMMIT'",
"tag":"'$TAG'"
}'
travis_retry git push -f origin "HEAD:$TAG/$COMMIT"