Fix a TODO.
[cabal.git] / travis / upload.sh
blob373e553956bb729c922694214b6b875dc94cad98
1 #!/bin/sh
3 set -x
5 . ./travis-common.sh
7 # Read out ACCOUNT and REPO from the slug
8 # Cribbed from http://unix.stackexchange.com/a/53323/118117
9 ACCOUNT=${TRAVIS_REPO_SLUG%%"/"*}
10 REPO=${TRAVIS_REPO_SLUG#*"/"}
12 # TAG will be used to uniquely identify a matrix entry; we
13 # need to push each matrix entry to a separate branch.
14 TAG="$TRAVIS_OS_NAME-$GHCVER$TAGSUFFIX"
16 # This is the commit for which we want a GitHub status update
17 # ping to go to. Note that it is NOT TRAVIS_COMMIT unconditionally,
18 # since if we have a pull request, this commit will be a merge
19 # commit which no one from GitHub will be able to see.
20 COMMIT=${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}
22 # This is just to help you correlate the build to what it's for
23 if [ "x$TRAVIS_PULL_REQUEST" != "xfalse" ]; then
24 ORIGIN="${TRAVIS_REPO_SLUG}/pull/$TRAVIS_PULL_REQUEST"
25 URL="pull/${TRAVIS_PULL_REQUEST}"
26 else
27 ORIGIN="${TRAVIS_REPO_SLUG}/${TRAVIS_BRANCH}"
28 URL="commits/${TRAVIS_BRANCH}"
31 # Git will complain if these fields don't work when committing,
32 # so set them up.
33 git config --global user.name "$(git --no-pager show -s --format='%an' $COMMIT)"
34 git config --global user.email "$(git --no-pager show -s --format='%ae' $COMMIT)"
35 git config --global push.default simple
37 cd travis
39 # Setup SSH key we will use to push to binaries repository.
40 # umask to get the permissions to be 600 (not 400, because the deploy
41 # 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)
44 # Setup SSH keys
45 ssh-keyscan github.com >> $HOME/.ssh/known_hosts
47 cd binaries
49 # Setup binaries repository for pushing
50 git init
51 # TODO: Update this
52 git remote add origin git@github.com:haskell-pushbot/cabal-binaries.git
54 # Make some final modifications to .travis.yml based so
55 # that downstream builds with the correct configuration
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 echo "os: $TRAVIS_OS_NAME" >> .travis.yml
58 if [ "x$GHCVER" = "x7.8.4" ] && [ "x$TRAVIS_OS_NAME" = "xosx" ]; then
59 echo "osx_image: xcode6.4" >> .travis.yml
62 # Make directory layout
63 mkdir Cabal
64 mkdir cabal-install
65 cp -R $TRAVIS_BUILD_DIR/Cabal/tests Cabal
66 cp -R $TRAVIS_BUILD_DIR/cabal-install/tests cabal-install
67 # Copy in credentials so we can delete branch when done
68 cp $TRAVIS_BUILD_DIR/travis/id_rsa.rot13 .
69 # Install all of the necessary files for testing
70 cp $TRAVIS_BUILD_DIR/travis-install.sh .
71 cp $TRAVIS_BUILD_DIR/travis-common.sh .
72 # The binaries to test (statically linked, of course!)
73 cp ${CABAL_BDIR}/c/unit-tests/build/unit-tests/unit-tests Cabal
74 cp ${CABAL_BDIR}/c/check-tests/build/check-tests/check-tests Cabal
75 cp ${CABAL_BDIR}/c/parser-tests/build/parser-tests/parser-tests Cabal
76 cp ${CABAL_BDIR}/c/hackage-tests/build/hackage-tests/hackage-tests Cabal
77 if [ "x$CABAL_LIB_ONLY" != "xYES" ]; then
78 cp ${CABAL_INSTALL_BDIR}/build/cabal/cabal cabal-install
81 # Add, commit, push
82 git add .
83 # The JSON in the commit message is used by the webhook listening
84 # on the downstream repo to figure out who to communicate the
85 # status update back to
86 git commit -m '{"origin":"'$ORIGIN'",
88 "url":"'$URL'",
89 "account":"'$ACCOUNT'",
90 "repo":"'$REPO'",
91 "commit": "'$COMMIT'",
92 "tag":"'$TAG'"
94 travis_retry git push -f origin "HEAD:$TAG/$COMMIT"