1
1
mirror of https://github.com/primer/css.git synced 2025-01-02 03:02:40 +03:00

Merge pull request #250 from primer/shawnbot/commit-status

Send commit status back after publishing canary release
This commit is contained in:
Shawn Allen 2017-07-14 11:21:57 -07:00 committed by GitHub
commit b6a0b71970
6 changed files with 43 additions and 11 deletions

View File

@ -3,11 +3,11 @@ node_js:
- 7
before_script:
- npm config set "//registry.npmjs.org/:_authToken=\${NPM_API_KEY}"
- lerna bootstrap
script:
- npm test
after_success:
- npm config set "//registry.npmjs.org/:_authToken=\${NPM_API_KEY}"
- script/cibuild --yes

View File

@ -5,12 +5,13 @@
"clean": "lerna clean",
"diff": "lerna diff",
"updated": "lerna updated",
"release": "lerna publish",
"release-candidate": "lerna publish --npm-tag=rc",
"release-canary": "lerna publish --npm-tag=canary --canary",
"release-pr": "script/release-pr",
"release-candidate": "script/release-candidate",
"release": "script/release",
"test": "lerna run test"
},
"devDependencies": {
"commit-status": "^4.1.0",
"lerna": "^2.0.0"
}
}

View File

@ -5,18 +5,15 @@ set -e
# which makes this easier to test locally
args=${@:1}
# always publish a canary release if this is a PR build
# always publish a pr release if this is a PR build
if [[ $TRAVIS_EVENT_TYPE = pull_request ]]; then
echo "🐦 Publishing canary version..."
npm run release-canary -- ${args}
script/release-pr ${args}
# merges to dev build a release candidate
elif [[ $TRAVIS_BRANCH = dev ]]; then
echo "👌 Publishing release candidate..."
echo npm run release-candidate -- ${args}
script/release-candidate ${args}
# publish a release when we merge to master
elif [[ $TRAVIS_BRANCH = master ]]; then
echo "📦 Publishing latest release!"
echo npm run release -- ${args}
script/release ${args}
else
echo "⚠️ This isn't a PR and '${TRAVIS_BRANCH}' isn't a release branch."
exit 1

4
script/release Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
set -e
echo "📦 Publishing latest release!"
echo lerna publish

4
script/release-candidate Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
set -e
echo "👌 Publishing release candidate..."
echo lerna publish --npm-tag=rc

26
script/release-pr Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
set -e
args=${@:1}
package=primer-css
npm_tag=pr
# the commit status context
context=npm/publish/${npm_tag}
echo "🐦 Publishing PR release to dist-tag '${npm_tag}'..."
lerna publish --npm-tag=${npm_tag} --canary --no-git ${args}
# get the published version of primer-css from its package.json
version=`jq -r .version modules/${package}/package.json`
slug="${package}@${version}"
echo "📡 Transmitting release success for ${slug} ..."
if [[ $TRAVIS_PULL_REQUEST_SHA ]]; then
# setting TRAVIS_COMMIT inline here is a fix for:
# <https://github.com/taskworld/commit-status/issues/5>
TRAVIS_COMMIT=$TRAVIS_PULL_REQUEST_SHA \
commit-status success ${context} \
"npm install ${slug}" \
"https://unpkg.com/${slug}/build/build.css"
fi