aboutsummaryrefslogtreecommitdiffstats
path: root/.circleci/scripts/release-create-gh-release
diff options
context:
space:
mode:
Diffstat (limited to '.circleci/scripts/release-create-gh-release')
-rwxr-xr-x.circleci/scripts/release-create-gh-release51
1 files changed, 51 insertions, 0 deletions
diff --git a/.circleci/scripts/release-create-gh-release b/.circleci/scripts/release-create-gh-release
new file mode 100755
index 000000000..f40df4998
--- /dev/null
+++ b/.circleci/scripts/release-create-gh-release
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+set -x
+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
+
+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
+}
+
+current_commit_msg=$(git show -s --format='%s' HEAD)
+
+if grep --quiet '^Version v' <<< "$current_commit_msg"
+then
+ 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 "$release_body" \
+ --commitish "$CIRCLE_SHA1" \
+ "$tag"
+ popd
+else
+ printf '%s\n' 'Skipping GitHub Release'
+ exit 0
+fi