2017-07-08 05:59:11 +03:00
|
|
|
#!/bin/bash
|
2017-07-08 01:57:33 +03:00
|
|
|
set -e
|
2017-07-08 02:00:22 +03:00
|
|
|
|
2017-07-12 23:43:31 +03:00
|
|
|
# --yes gets passed in by .travis.yml,
|
|
|
|
# which makes this easier to test locally
|
2017-07-21 00:13:49 +03:00
|
|
|
args=$@
|
2017-07-11 01:48:41 +03:00
|
|
|
|
2017-07-21 03:28:05 +03:00
|
|
|
event="$TRAVIS_EVENT_TYPE"
|
|
|
|
branch="${TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_BRANCH}}"
|
2017-07-21 03:02:11 +03:00
|
|
|
|
|
|
|
echo "==== CI env ===="
|
|
|
|
echo "event: $event"
|
|
|
|
echo "branch: $branch"
|
|
|
|
echo "================"
|
2017-07-21 03:28:05 +03:00
|
|
|
if [[ "$event" = "" || "$branch" = "" ]]; then
|
|
|
|
echo '❌ Missing $TRAVIS_EVENT_TYPE or $TRAVIS_BRANCH!'
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-07-21 02:49:22 +03:00
|
|
|
|
2017-07-21 03:02:11 +03:00
|
|
|
# release branches publish a release candidate
|
2017-07-21 03:28:05 +03:00
|
|
|
if [[ "$branch" =~ ^release- ]]; then
|
2017-07-21 03:02:11 +03:00
|
|
|
# only publish RCs for push builds
|
2017-07-21 03:08:47 +03:00
|
|
|
if [[ "$event" = "push" ]]; then
|
2017-07-21 03:02:11 +03:00
|
|
|
script/notify pending
|
|
|
|
script/release-candidate $args
|
|
|
|
script/notify success
|
|
|
|
fi
|
2017-07-21 03:28:05 +03:00
|
|
|
echo "⚠️ This appears to be a release branch, but we only publish *push* builds."
|
2017-07-21 03:08:47 +03:00
|
|
|
echo "(TRAVIS_EVENT_TYPE: $event)"
|
|
|
|
exit 1
|
2017-07-14 02:36:27 +03:00
|
|
|
# always publish a pr release if this is a PR build
|
2017-07-21 03:08:47 +03:00
|
|
|
elif [[ "$event" = "pull_request" ]]; then
|
2017-07-21 03:02:11 +03:00
|
|
|
script/notify pending
|
2017-07-21 01:21:59 +03:00
|
|
|
script/release-pr $args
|
2017-07-21 03:02:11 +03:00
|
|
|
script/notify success
|
2017-07-11 01:48:41 +03:00
|
|
|
# publish a release when we merge to master
|
2017-07-21 03:08:47 +03:00
|
|
|
elif [[ "$branch" = "master" ]]; then
|
2017-07-21 03:02:11 +03:00
|
|
|
script/notify pending
|
2017-07-21 01:21:59 +03:00
|
|
|
script/release $args
|
2017-07-21 03:02:11 +03:00
|
|
|
script/notify success
|
2017-07-08 01:57:33 +03:00
|
|
|
else
|
2017-07-21 03:08:47 +03:00
|
|
|
echo "⚠️ This isn't a PR and '$branch' isn't a release branch."
|
2017-07-08 01:57:33 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-07-21 01:21:59 +03:00
|
|
|
|