Skip to content

Commit

Permalink
Modifying notify script to publish from each package
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrohan committed Jun 28, 2018
1 parent df7a882 commit ce54470
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 39 deletions.
4 changes: 3 additions & 1 deletion modules/primer-alerts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"build": "../../script/npm-run primer-module-build index.scss",
"prepare": "npm run build",
"lint": "../../script/lint-scss",
"test": "../../script/npm-run-all build lint"
"test": "../../script/npm-run-all build lint",
"prepublishOnly": "../../script/notify pending",
"publish": "../../script/notify success"
},
"dependencies": {
"primer-support": "4.5.4"
Expand Down
4 changes: 3 additions & 1 deletion modules/primer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"build": "../../script/npm-run primer-module-build index.scss",
"prepare": "npm run build",
"lint": "../../script/lint-scss",
"test": "../../script/npm-run-all build lint"
"test": "../../script/npm-run-all build lint",
"prepublishOnly": "../../script/notify pending",
"publish": "../../script/notify success"
},
"dependencies": {
"primer-alerts": "1.5.7",
Expand Down
30 changes: 12 additions & 18 deletions script/notify
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,28 @@
set -e

if [[ "$CI" != "true" ]]; then
echo "(notify bailing: not in CI)"
echo "(bailing: not in CI)"
exit
elif [[ $# -lt 1 ]]; then
echo "No status provided!" >&2
exit 1
fi

# the commit status context
context="npm publish"
_status=$1

# get the published version of primer from its package.json
package=primer
version=$(jq -r .version modules/$package/package.json)
published="$package@$version"

message=""
if [[ "$_status" = "success" ]]; then
# TODO point this at the contributing docs!
message="https://unpkg.com/$published/build/build.css"
fi

# XXX this will go away if we build pushes instead of PRs
if [[ "$TRAVIS_PULL_REQUEST_SHA" != "" ]]; then
# setting TRAVIS_COMMIT inline here is a fix for:
# <https://github.com/taskworld/commit-status/issues/5>
export TRAVIS_COMMIT=$TRAVIS_PULL_REQUEST_SHA
fi

echo "📡 Transmitting publish status for $published..."
commit-status "$_status" "$context" "$published" "$message"
_status=$1

version=$(jq -r .version package.json)
name=$(jq -r .name package.json)

# the commit status context
context="npm publish $name"
message="https://unpkg.com/$name@$version/"

echo "📡 Transmitting publish status for $context $name@$version..."
commit-status "$_status" "$context" "$name@$version" "$message"
4 changes: 0 additions & 4 deletions script/release
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
set -e
echo "📦 Publishing latest release..."

$(dirname $0)/notify pending

# note: try-publish should exit cleanly if it detects a duplicate
# published version
$(npm bin)/lerna exec -- $(pwd)/script/try-publish

echo "📓 Updated CHANGELOG..."

$(npm bin)/lerna-changelog

$(dirname $0)/notify success
10 changes: 1 addition & 9 deletions script/release-candidate
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ const getUpdated = (args) => {
.then(updated => updated.map(pkg => pkg.name))
}

const notify = status => {
return execa('script/notify', [status], {env: process.env})
.catch(error => {
console.error('notify error:', error)
})
}

const writePackage = (pkg) => {
const {dir} = pkg
delete pkg.dir
Expand Down Expand Up @@ -152,12 +145,11 @@ revertPackages()
console.error('lerna-changelog error:', error)
})
})
.then(() => notify('success'))
})
})
.catch(error => {
console.error('Error:', error)
process.exitCode = 1
return notify('error')
return
})
.then(() => process.exit())
6 changes: 0 additions & 6 deletions script/release-pr
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
set -e
echo "🐦 Publishing PR (canary) release..."

# don't notify of a pending publish event because the version will differ from
# what lerna creates as a canary release
# $(dirname $0)/notify pending

$(npm bin)/lerna publish --npm-tag=pr --canary --exact $@

echo "📓 Updated CHANGELOG..."

$(npm bin)/lerna-changelog

$(dirname $0)/notify success

0 comments on commit ce54470

Please sign in to comment.