From 477945e5a082747352af20dd5cbb44ef652eaeb3 Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Thu, 27 Jul 2017 13:23:12 -0700 Subject: [PATCH 1/8] reorganize CI release logic - move final release into Travis 'deploy' stage - move PR and RC release logic into script/after_success - kill script/cibuild --- .travis.yml | 17 +++++++++++++++-- script/after_success | 13 +++++++++++++ script/cibuild | 41 ----------------------------------------- 3 files changed, 28 insertions(+), 43 deletions(-) create mode 100644 script/after_success delete mode 100755 script/cibuild diff --git a/.travis.yml b/.travis.yml index abfae4e5..b8a1aaa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,13 @@ language: node_js node_js: - 7 +env: + global: + - secure: fsY9o/wT4lfo7nUTNe772p2+A8UmUNe6gq1NFVtX0+GHUNXQg2pAtQqWLTwOisylGlSaTYF1eO5TwBlcaiujzQj5IULmJARFM3ELPGDmXIy0o2Bl9iVk/97NsVHvFApiwsKk4PQhDZw6bRJPNqVGw8d5bEuCslv0W6ZpvPz/jpk= + +before_install: + - npm config set "//registry.npmjs.org/:_authToken=\${NPM_API_KEY}" + before_script: - lerna bootstrap @@ -9,8 +16,14 @@ script: - npm test after_success: - - npm config set "//registry.npmjs.org/:_authToken=\${NPM_API_KEY}" - - script/cibuild --yes + - script/after_success + +deploy: + # publish "final" releases on master + - provider: script + script: script/release + on: + branch: master notifications: slack: diff --git a/script/after_success b/script/after_success new file mode 100644 index 00000000..cccb482c --- /dev/null +++ b/script/after_success @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +if [[ "$TRAVIS_EVENT_TYPE" = "pull_request" ]]; then + if [[ "$TRAVIS_BRANCH" = "dev" ]]; then + script/release-pr + exit + elif [[ "$TRAVIS_PULL_REQUEST_BRANCH" =~ ^release ]]; then + script/release-candidate + exit + fi +fi +echo "⚠️ This is not a PR against 'dev', so skipping the canary release" diff --git a/script/cibuild b/script/cibuild deleted file mode 100755 index d363438c..00000000 --- a/script/cibuild +++ /dev/null @@ -1,41 +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 - -echo "🐛 script/cibuild" -( - echo "TRAVIS_EVENT_TYPE,$TRAVIS_EVENT_TYPE" - echo "TRAVIS_BRANCH,$TRAVIS_BRANCH" - echo "TRAVIS_PULL_REQUEST,$TRAVIS_PULL_REQUEST" - echo "TRAVIS_PULL_REQUEST_BRANCH,$TRAVIS_PULL_REQUEST_BRANCH" -) | column -t -s=, - -# 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 - From 7525bcbc27b1e1386baea30afc841df00054dbda Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Thu, 27 Jul 2017 13:26:21 -0700 Subject: [PATCH 2/8] clean up release scripts --- script/release | 9 ++++++--- script/release-candidate | 9 +++++---- script/release-pr | 14 +++++++++----- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/script/release b/script/release index 557aac99..3b2606c7 100755 --- a/script/release +++ b/script/release @@ -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 diff --git a/script/release-candidate b/script/release-candidate index 85f4608b..b4a10b3b 100755 --- a/script/release-candidate +++ b/script/release-candidate @@ -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 diff --git a/script/release-pr b/script/release-pr index b30f6060..0c3c213c 100755 --- a/script/release-pr +++ b/script/release-pr @@ -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 --yes + +$(dirname $0)/notify success + +# FIXME remove this before merging; just for testing +$(dirname $0)/notify-slack From 1ef281643b2e3260846c0c38c356f607f3b528fc Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Fri, 28 Jul 2017 13:53:40 -0700 Subject: [PATCH 3/8] publish release candidates from release branches --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index b8a1aaa0..dca987d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,12 @@ after_success: - script/after_success deploy: + # publish release candidates on release branches + - provider: sript + script: script/release-candidate + on: + branch: /^release/ + # publish "final" releases on master - provider: script script: script/release From 5b7d987f2c0373d1483f413b2db63829c039fe92 Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Fri, 28 Jul 2017 13:55:13 -0700 Subject: [PATCH 4/8] simplify script/after_success --- script/after_success | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/script/after_success b/script/after_success index cccb482c..746ff81d 100644 --- a/script/after_success +++ b/script/after_success @@ -1,13 +1,10 @@ #!/bin/bash set -e -if [[ "$TRAVIS_EVENT_TYPE" = "pull_request" ]]; then - if [[ "$TRAVIS_BRANCH" = "dev" ]]; then - script/release-pr - exit - elif [[ "$TRAVIS_PULL_REQUEST_BRANCH" =~ ^release ]]; then - script/release-candidate - exit - fi +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 fi -echo "⚠️ This is not a PR against 'dev', so skipping the canary release" From 0864919264f6e2727582da0721cb210db3d47911 Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Fri, 28 Jul 2017 13:58:38 -0700 Subject: [PATCH 5/8] nix unused encrypted env var --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index dca987d6..722250a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,6 @@ language: node_js node_js: - 7 -env: - global: - - secure: fsY9o/wT4lfo7nUTNe772p2+A8UmUNe6gq1NFVtX0+GHUNXQg2pAtQqWLTwOisylGlSaTYF1eO5TwBlcaiujzQj5IULmJARFM3ELPGDmXIy0o2Bl9iVk/97NsVHvFApiwsKk4PQhDZw6bRJPNqVGw8d5bEuCslv0W6ZpvPz/jpk= - before_install: - npm config set "//registry.npmjs.org/:_authToken=\${NPM_API_KEY}" From 21d4d7071d309390e7ba36fef60302c58498e6aa Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Fri, 28 Jul 2017 14:01:06 -0700 Subject: [PATCH 6/8] fix typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 722250a1..a86112af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ after_success: deploy: # publish release candidates on release branches - - provider: sript + - provider: script script: script/release-candidate on: branch: /^release/ From 9b03481ae388428d5814e662b2cf838f423127b9 Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Fri, 28 Jul 2017 14:02:15 -0700 Subject: [PATCH 7/8] move lerna publish --yes option to script/after_success --- script/after_success | 2 +- script/release-pr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/after_success b/script/after_success index 746ff81d..4de048b3 100644 --- a/script/after_success +++ b/script/after_success @@ -6,5 +6,5 @@ event=$TRAVIS_EVENT_TYPE # only publish canary releases on PRs against dev if [[ "$event" = "pull_request" && "$branch" = "dev" ]]; then - script/release-pr + script/release-pr --yes fi diff --git a/script/release-pr b/script/release-pr index 0c3c213c..94fe85ca 100755 --- a/script/release-pr +++ b/script/release-pr @@ -6,7 +6,7 @@ PATH=$(npm bin):$PATH # script/notify pending -lerna publish --npm-tag=pr --canary --no-git --yes +lerna publish --npm-tag=pr --canary --no-git $@ $(dirname $0)/notify success From ab913f229d9b916c6b1f46dc96ad983108164b41 Mon Sep 17 00:00:00 2001 From: Shawn Allen Date: Fri, 28 Jul 2017 14:09:04 -0700 Subject: [PATCH 8/8] chmod +x, derp --- script/after_success | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 script/after_success diff --git a/script/after_success b/script/after_success old mode 100644 new mode 100755