From 5633f65e8df8cfe72a38d058f7f81217a875c5d3 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 9 Sep 2019 21:43:32 -0300 Subject: [PATCH 1/5] Publish GitHub release from master branch This ensures that changes made on `develop` since branching for the release are not included. It also ensures that the final release sourcemaps line-up correctly (they were always build on master)`. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b5eb6fe85221..223ed2a81ebb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ workflows: filters: branches: only: - - develop + - master # - prep-docs: # requires: # - prep-deps From 2264f4fb37546a3bc750d7a70f87d4cf1e41433c Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 9 Sep 2019 22:42:06 -0300 Subject: [PATCH 2/5] Consolidate publish jobs The jobs `job-publish-release` and `create_github_release` both handle different parts of publishing a release. They have been consolidated into a single `job-publish-release` job. --- .circleci/config.yml | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 223ed2a81ebb..d18a9c9e7d18 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,13 +14,6 @@ workflows: - prep-build: requires: - prep-deps - - create_github_release: - requires: - - prep-build - filters: - branches: - only: - - master # - prep-docs: # requires: # - prep-deps @@ -243,6 +236,10 @@ jobs: - run: name: sentry sourcemaps upload command: yarn sentry:publish + - run: + name: Create GitHub release + command: | + .circleci/scripts/release-create-gh-release # - run: # name: github gh-pages docs publish # command: > @@ -321,15 +318,3 @@ jobs: - run: name: Coveralls upload command: yarn test:coveralls-upload - - create_github_release: - docker: - - image: circleci/node:8.15.1-browsers - steps: - - checkout - - attach_workspace: - at: . - - run: - name: Create GitHub release - command: | - .circleci/scripts/release-create-gh-release From a3fcb76b845486307492cb49584c855b061dd504 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 10 Sep 2019 14:53:38 -0300 Subject: [PATCH 3/5] Update release script to expect a merge commit The release script was originally written to be run on `develop`, so it expected the current commit to be a result of `Squash & Merge`. Now that it's run on `master`, it will generally be run against a merge commit. The version is now extracted from the commit message using a regular expression that should work on all version of Bash v3+, and should be tolerant of both merge commits and `Squash & Merge` commits. --- .circleci/scripts/release-create-gh-release | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/scripts/release-create-gh-release b/.circleci/scripts/release-create-gh-release index f40df49983fd..22d998696429 100755 --- a/.circleci/scripts/release-create-gh-release +++ b/.circleci/scripts/release-create-gh-release @@ -28,24 +28,24 @@ function install_github_cli () current_commit_msg=$(git show -s --format='%s' HEAD) -if grep --quiet '^Version v' <<< "$current_commit_msg" +if [[ $current_commit_msg =~ Version[-[:space:]]v([[:digit:]]+.[[:digit:]]+.[[:digit:]]+) ]] then + tag="${BASH_REMATCH[1]}" + install_github_cli printf '%s\n' 'Creating GitHub Release' - read -ra commit_words <<< "$current_commit_msg" - tag="${commit_words[1]}" release_body="$(awk -v version="${tag##v}" -f .circleci/scripts/show-changelog.awk CHANGELOG.md)" pushd builds hub release create \ --attach metamask-chrome-*.zip \ --attach metamask-firefox-*.zip \ - --message "${commit_words[0]} ${commit_words[1]#v}" \ + --message "Version ${tag##v}" \ --message "$release_body" \ --commitish "$CIRCLE_SHA1" \ "$tag" popd else - printf '%s\n' 'Skipping GitHub Release' + printf '%s\n' 'Version not found in commit message; skipping GitHub Release' exit 0 fi From c8b0c3732765a0f5104c29c8edcbeed9ceaebae2 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 10 Sep 2019 16:21:04 -0300 Subject: [PATCH 4/5] Target `master` with release PR `master` is now targetted by the release PR instead of `develop`, as the release has to be created from the master branch. The update to `develop` is handled after the release by a PR from `master` to `develop`, which is created automatically after the release. --- .circleci/config.yml | 3 ++ .circleci/scripts/release-create-master-pr | 53 +++++++++++++++++++++ .circleci/scripts/release-create-release-pr | 2 +- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100755 .circleci/scripts/release-create-master-pr diff --git a/.circleci/config.yml b/.circleci/config.yml index d18a9c9e7d18..7373aa3a258e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -240,6 +240,9 @@ jobs: name: Create GitHub release command: | .circleci/scripts/release-create-gh-release + - run: + name: Create GitHub Pull Request to sync master with develop + command: .circleci/scripts/release-create-master-pr # - run: # name: github gh-pages docs publish # command: > diff --git a/.circleci/scripts/release-create-master-pr b/.circleci/scripts/release-create-master-pr new file mode 100755 index 000000000000..74eeed86c84b --- /dev/null +++ b/.circleci/scripts/release-create-master-pr @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +if [[ "${CI:-}" != 'true' ]] +then + printf '%s\n' 'CI environment variable must be set to true' + exit 1 +fi + +if [[ "${CIRCLECI:-}" != 'true' ]] +then + printf '%s\n' 'CIRCLECI environment variable must be set to true' + exit 1 +fi + +if [[ -z "${GITHUB_TOKEN:-}" ]] +then + printf '%s\n' 'GITHUB_TOKEN environment variable must be set' + exit 1 +fi + +function install_github_cli () +{ + printf '%s\n' 'Installing hub CLI' + pushd "$(mktemp -d)" + curl -sSL 'https://github.com/github/hub/releases/download/v2.11.2/hub-linux-amd64-2.11.2.tgz' | tar xz + PATH="$PATH:$PWD/hub-linux-amd64-2.11.2/bin" + popd +} + +base_branch='develop' + +if [[ -n "${CI_PULL_REQUEST:-}" ]] +then + printf '%s\n' 'CI_PULL_REQUEST is set, pull request already exists for this build' + exit 0 +fi + +install_github_cli + +printf '%s\n' "Creating a Pull Request to sync 'master' with 'develop'" + +if ! hub pull-request \ + --reviewer '@MetaMask/extension-release-team' \ + --message "Master => develop" --message 'Merge latest release back into develop' \ + --base "$CIRCLE_PROJECT_USERNAME:$base_branch" \ + --head "$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH"; +then + printf '%s\n' 'Pull Request already exists' +fi diff --git a/.circleci/scripts/release-create-release-pr b/.circleci/scripts/release-create-release-pr index 8a2238ec4467..76f30ece4c19 100755 --- a/.circleci/scripts/release-create-release-pr +++ b/.circleci/scripts/release-create-release-pr @@ -32,7 +32,7 @@ function install_github_cli () } version="${CIRCLE_BRANCH/Version-v/}" -base_branch='develop' +base_branch='master' if [[ -n "${CI_PULL_REQUEST:-}" ]] then From 8ecd7a8bbb79e3fb78788f68b2ca417223dde83a Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 11 Sep 2019 11:27:28 -0300 Subject: [PATCH 5/5] Include `v` in regex capture group --- .circleci/scripts/release-create-gh-release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/scripts/release-create-gh-release b/.circleci/scripts/release-create-gh-release index 22d998696429..93303f576ebe 100755 --- a/.circleci/scripts/release-create-gh-release +++ b/.circleci/scripts/release-create-gh-release @@ -28,7 +28,7 @@ function install_github_cli () current_commit_msg=$(git show -s --format='%s' HEAD) -if [[ $current_commit_msg =~ Version[-[:space:]]v([[:digit:]]+.[[:digit:]]+.[[:digit:]]+) ]] +if [[ $current_commit_msg =~ Version[-[:space:]](v[[:digit:]]+.[[:digit:]]+.[[:digit:]]+) ]] then tag="${BASH_REMATCH[1]}"