Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish GitHub release from master branch #7136

Merged
merged 5 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ workflows:
- prep-build:
requires:
- prep-deps
- create_github_release:
requires:
- prep-build
filters:
branches:
only:
- develop
# - prep-docs:
# requires:
# - prep-deps
Expand Down Expand Up @@ -243,6 +236,13 @@ jobs:
- run:
name: sentry sourcemaps upload
command: yarn sentry:publish
- run:
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: >
Expand Down Expand Up @@ -321,15 +321,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
10 changes: 5 additions & 5 deletions .circleci/scripts/release-create-gh-release
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Gudahtt marked this conversation as resolved.
Show resolved Hide resolved
--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
53 changes: 53 additions & 0 deletions .circleci/scripts/release-create-master-pr
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .circleci/scripts/release-create-release-pr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down