#!/usr/bin/env bash set -eu +x -o pipefail ROOT=$(cd $(dirname $0) ; pwd) TARGET=$1 source aws.sh # For nightly-YYYY-MM-DD, tag should be nightly # For lts-X.Y, tag should be ltsX SHORTNAME=$(echo $TARGET | cut -d- -f 1) if [ $SHORTNAME = "lts" ] then TAG=$(echo $TARGET | sed 's@^lts-\([0-9]*\)\.[0-9]*@lts\1@') else TAG=$SHORTNAME fi IMAGE=commercialhaskell/stackage:$TAG CABAL_DIR=$ROOT/cabal PANTRY_DIR=$ROOT/pantry STACK_DIR=$ROOT/stack-$TAG GHC_DIR=$ROOT/ghc DOT_STACKAGE_DIR=$ROOT/dot-stackage WORKDIR=$ROOT/$TAG/work # ssh key is used for committing snapshots (and their constraints) to Github SSH_DIR=$ROOT/ssh USERID=$(id -u) mkdir -p \ "$CABAL_DIR" \ "$PANTRY_DIR" \ "$STACK_DIR" \ "$GHC_DIR" \ "$DOT_STACKAGE_DIR" \ "$WORKDIR" \ "$SSH_DIR" GITCONFIG=$ROOT/gitconfig cat >$GITCONFIG <&1 | tee "$SHORTNAME-build.log" # Make sure we actually need this snapshot. We used to perform this check # exclusively before building. Now we perform it after as well for the case of # nightly, where we don't perform this check beforehand. This is also slightly # safer, in case someone else already uploaded a specific snapshot while we # were building. docker run $ARGS_UPLOAD $IMAGE /bin/bash -c "exec curator check-target-available --target $TARGET" # Successful build, so we need to: # # * Upload the docs to S3 # * Upload the new snapshot .yaml file to the appropriate Github repo, also upload its constraints # * Register as a new Hackage distro (currently disabled) docker run $ARGS_UPLOAD $IMAGE /bin/bash -c "curator upload-docs --target $TARGET && curator upload-github --target $TARGET && exec curator hackage-distro --target $TARGET" # information about the new snapshots on Hackage $BINDIR/curator legacy-bulk --stackage-snapshots dot-stackage/curator/stackage-snapshots/ --lts-haskell dot-stackage/curator/lts-haskell/ --stackage-nightly dot-stackage/curator/stackage-nightly/ ( if [ $SHORTNAME = "lts" ] then cd dot-stackage/curator/lts-haskell else cd dot-stackage/curator/stackage-nightly fi git add *.yaml git diff-index --quiet HEAD && echo No changes && exit 0 git config user.name "Stackage build server" git config user.email "michael@snoyman.com" git commit -a -m "More conversions $(date)" if [ $SHORTNAME = "lts" ] then GIT_SSH_COMMAND="ssh -i $ROOT/ssh-lts/id_rsa" git push origin master else GIT_SSH_COMMAND="ssh -i $ROOT/ssh-nightly/id_rsa" git push origin master fi ) echo -n "Completed at " date