aboutsummaryrefslogtreecommitdiffstats
path: root/.circleci/scripts/release-create-release-pr
diff options
context:
space:
mode:
Diffstat (limited to '.circleci/scripts/release-create-release-pr')
-rwxr-xr-x.circleci/scripts/release-create-release-pr54
1 files changed, 54 insertions, 0 deletions
diff --git a/.circleci/scripts/release-create-release-pr b/.circleci/scripts/release-create-release-pr
new file mode 100755
index 000000000..8a2238ec4
--- /dev/null
+++ b/.circleci/scripts/release-create-release-pr
@@ -0,0 +1,54 @@
+#!/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
+}
+
+version="${CIRCLE_BRANCH/Version-v/}"
+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 for $version on GitHub"
+
+if ! hub pull-request \
+ --reviewer '@MetaMask/extension-release-team' \
+ --message "${CIRCLE_BRANCH/-/ } RC" --message ':package: :rocket:' \
+ --base "$CIRCLE_PROJECT_USERNAME:$base_branch" \
+ --head "$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH";
+then
+ printf '%s\n' 'Pull Request already exists'
+fi