1
1
mirror of https://github.com/primer/css.git synced 2024-09-21 05:39:15 +03:00

Merge pull request #290 from primer/shawnbot/travis-deploy

Use Travis conditional deployment
This commit is contained in:
Shawn Allen 2017-07-28 15:37:23 -07:00 committed by GitHub
commit 420ce3aa66
6 changed files with 47 additions and 47 deletions

View File

@ -2,6 +2,9 @@ language: node_js
node_js:
- 7
before_install:
- npm config set "//registry.npmjs.org/:_authToken=\${NPM_API_KEY}"
before_script:
- lerna bootstrap
@ -9,8 +12,20 @@ script:
- npm test
after_success:
- npm config set "//registry.npmjs.org/:_authToken=\${NPM_API_KEY}"
- script/cibuild --yes
- script/after_success
deploy:
# publish release candidates on release branches
- provider: script
script: script/release-candidate
on:
branch: /^release/
# publish "final" releases on master
- provider: script
script: script/release
on:
branch: master
notifications:
slack:

10
script/after_success Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
set -e
branch=$TRAVIS_BRANCH
event=$TRAVIS_EVENT_TYPE
# only publish canary releases on PRs against dev
if [[ "$event" = "pull_request" && "$branch" = "dev" ]]; then
script/release-pr --yes
fi

View File

@ -1,33 +0,0 @@
#!/bin/bash
set -e
# --yes gets passed in by .travis.yml,
# which makes this easier to test locally
args=$@
event=$TRAVIS_EVENT_TYPE
branch=$TRAVIS_BRANCH
# the presence of $TRAVIS_PULL_REQUEST_BRANCH tells us
# whether this is a pull request
if [[ "$event" = "pull_request" ]]; then
upstream_branch=$branch
branch=$TRAVIS_PULL_REQUEST_BRANCH
# if the *source* branch begins with "release"
if [[ "$branch" =~ ^release ]]; then
script/release-candidate $args
# otherwise, if the *target* branch is dev
elif [[ "$upstream_branch" = "dev" ]]; then
script/release-pr $args
else
echo "⚠️ This is a PR, but '$branch' isn't a release branch"
echo " and '$upstream_branch' isn't a recognized upstream branch."
exit 1
fi
elif [[ "$branch" = "master" ]]; then
script/release $args
else
echo "⚠️ This isn't a PR and '$branch' isn't a release branch."
exit 1
fi

View File

@ -1,8 +1,11 @@
#!/bin/bash
set -e
echo "📦 Publishing latest release..."
script/notify pending
$(dirname $0)/notify pending
# note: try-publish should exit cleanly if it detects a duplicate
# published version
lerna exec -- $(pwd)/script/try-publish
script/notify success
$(npm bin)/lerna exec -- $(pwd)/script/try-publish
$(dirname $0)/notify success

View File

@ -6,7 +6,6 @@ PATH=$(npm bin):$PATH
package=primer-css
npm_tag=rc
log=/tmp/rc.log
# get the version we're publishing as a release candidate
local_version=$(jq -r .version modules/$package/package.json)
@ -53,13 +52,15 @@ for module_dir in $module_dirs; do
echo "$module@$module_version => $module_next_version"
# "upgrade" to the most recent RC version so that
# `npm version prerelease` can increment automatically
npm version --no-git --quiet "$module_next_version" >> $log
npm version --no-git --quiet "$module_next_version"
popd > /dev/null
done
# publish all the things!
script/notify pending
$(dirname $0)/notify pending
# note: this should NOT fail, so --bail=true applies
lerna exec -- npm publish --tag=$npm_tag
script/notify success
$(dirname $0)/notify success

View File

@ -1,10 +1,14 @@
#!/bin/bash
set -e
echo "🐦 Publishing PR (canary) release..."
args=$@
npm_tag=pr
PATH=$(npm bin):$PATH
echo "🐦 Publishing PR release to dist-tag '$npm_tag'..."
# script/notify pending
lerna publish --npm-tag=$npm_tag --canary --no-git $args
script/notify success
lerna publish --npm-tag=pr --canary --no-git $@
$(dirname $0)/notify success
# FIXME remove this before merging; just for testing
$(dirname $0)/notify-slack