mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Add scripts to automate GitHub releases (#6653)
* ci: Rename full_test to test_and_release * ci: Add scripts to automate GH releases * Add .bak files to .gitignore * ci: Add reviewer to the auto version PR
This commit is contained in:
parent
33071e3014
commit
83c2440509
@ -2,12 +2,24 @@ version: 2
|
|||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
full_test:
|
test_and_release:
|
||||||
jobs:
|
jobs:
|
||||||
|
- create_release_pull_request:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- /^Version-v(\d+)[.](\d+)[.](\d+)/
|
||||||
- prep-deps-npm
|
- prep-deps-npm
|
||||||
- prep-build:
|
- prep-build:
|
||||||
requires:
|
requires:
|
||||||
- prep-deps-npm
|
- prep-deps-npm
|
||||||
|
- create_github_release:
|
||||||
|
requires:
|
||||||
|
- prep-build
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- develop
|
||||||
# - prep-docs:
|
# - prep-docs:
|
||||||
# requires:
|
# requires:
|
||||||
# - prep-deps-npm
|
# - prep-deps-npm
|
||||||
@ -66,6 +78,18 @@ workflows:
|
|||||||
- all-tests-pass
|
- all-tests-pass
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
create_release_pull_request:
|
||||||
|
docker:
|
||||||
|
- image: circleci/node:8.15.1-browsers
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Create GitHub Pull Request for version
|
||||||
|
command: |
|
||||||
|
.circleci/scripts/release-bump-changelog-version
|
||||||
|
.circleci/scripts/release-bump-manifest-version
|
||||||
|
.circleci/scripts/release-create-release-pr
|
||||||
|
|
||||||
prep-deps-npm:
|
prep-deps-npm:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10.16-browsers
|
- image: circleci/node:10.16-browsers
|
||||||
@ -280,3 +304,15 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: All Tests Passed
|
name: All Tests Passed
|
||||||
command: echo 'weew - everything passed!'
|
command: echo 'weew - everything passed!'
|
||||||
|
|
||||||
|
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
|
||||||
|
44
.circleci/scripts/release-bump-changelog-version
Executable file
44
.circleci/scripts/release-bump-changelog-version
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
version="${CIRCLE_BRANCH/Version-v/}"
|
||||||
|
|
||||||
|
if ! grep --quiet --fixed-strings "$version" CHANGELOG.md
|
||||||
|
then
|
||||||
|
printf '%s\n' 'Adding this release to CHANGELOG.md'
|
||||||
|
date_str="$(date '+%a %b %d %Y')"
|
||||||
|
cp CHANGELOG.md{,.bak}
|
||||||
|
|
||||||
|
update_headers=$(cat <<END
|
||||||
|
/## Current Develop Branch/ {
|
||||||
|
print "## Current Develop Branch\n";
|
||||||
|
print "## ${version} ${date_str}";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
print;
|
||||||
|
}
|
||||||
|
END
|
||||||
|
)
|
||||||
|
|
||||||
|
awk "$update_headers" CHANGELOG.md.bak > CHANGELOG.md
|
||||||
|
rm CHANGELOG.md.bak
|
||||||
|
else
|
||||||
|
printf '%s\n' "CHANGELOG.md already includes a header for ${version}"
|
||||||
|
exit 0
|
||||||
|
fi
|
38
.circleci/scripts/release-bump-manifest-version
Executable file
38
.circleci/scripts/release-bump-manifest-version
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
printf '%s\n' 'Updating the manifest version if needed'
|
||||||
|
|
||||||
|
version="${CIRCLE_BRANCH/Version-v/}"
|
||||||
|
updated_manifest="$(jq ".version = \"$version\"" app/manifest.json)"
|
||||||
|
printf '%s\n' "$updated_manifest" > app/manifest.json
|
||||||
|
|
||||||
|
if [[ -z $(git status --porcelain) ]]
|
||||||
|
then
|
||||||
|
printf '%s\n' 'App manifest version already set'
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git \
|
||||||
|
-c user.name='MetaMask Bot' \
|
||||||
|
-c user.email='metamaskbot@users.noreply.github.com' \
|
||||||
|
commit --message "${CIRCLE_BRANCH/-/ }" \
|
||||||
|
CHANGELOG.md app/manifest.json
|
||||||
|
|
||||||
|
repo_slug="$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
|
||||||
|
git push "https://$GITHUB_TOKEN_USER:$GITHUB_TOKEN@github.com/$repo_slug" "$CIRCLE_BRANCH"
|
51
.circleci/scripts/release-create-gh-release
Executable file
51
.circleci/scripts/release-create-gh-release
Executable file
@ -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
|
54
.circleci/scripts/release-create-release-pr
Executable file
54
.circleci/scripts/release-create-release-pr
Executable file
@ -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
|
52
.circleci/scripts/show-changelog.awk
Normal file
52
.circleci/scripts/show-changelog.awk
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# This script will print out all of the CHANGELOG.md lines for a given version
|
||||||
|
# with the assumption that the CHANGELOG.md files looks something along the
|
||||||
|
# lines of:
|
||||||
|
#
|
||||||
|
# ```
|
||||||
|
# ## 6.6.2 Fri Jun 07 2019
|
||||||
|
#
|
||||||
|
# - [#6690](https://github.com/MetaMask/metamask-extension/pull/6690): Some words
|
||||||
|
# - [#6700](https://github.com/MetaMask/metamask-extension/pull/6700): some more words
|
||||||
|
#
|
||||||
|
# ## 6.6.1 Thu Jun 06 2019
|
||||||
|
#
|
||||||
|
# - [#6691](https://github.com/MetaMask/metamask-extension/pull/6691): Revert other words
|
||||||
|
#
|
||||||
|
# ## 6.6.0 Mon Jun 03 2019
|
||||||
|
#
|
||||||
|
# - [#6659](https://github.com/MetaMask/metamask-extension/pull/6659): foo
|
||||||
|
# - [#6671](https://github.com/MetaMask/metamask-extension/pull/6671): bar
|
||||||
|
# - [#6625](https://github.com/MetaMask/metamask-extension/pull/6625): baz
|
||||||
|
# - [#6633](https://github.com/MetaMask/metamask-extension/pull/6633): Many many words
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# ```
|
||||||
|
#
|
||||||
|
# EXAMPLE
|
||||||
|
#
|
||||||
|
# Run this script like so, passing in the version:
|
||||||
|
#
|
||||||
|
# ```
|
||||||
|
# awk -v version='6.6.0' -f .circleci/scripts/show-changelog.awk CHANGELOG.md
|
||||||
|
# ```
|
||||||
|
#
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
inside_section = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$1 == "##" && $2 == version {
|
||||||
|
inside_section = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$1 == "##" && $2 != version {
|
||||||
|
inside_section = 0;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
inside_section && !/^$/ {
|
||||||
|
print $0;
|
||||||
|
}
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,6 +11,8 @@ package
|
|||||||
.vscode
|
.vscode
|
||||||
.sublime-project
|
.sublime-project
|
||||||
|
|
||||||
|
*.bak
|
||||||
|
|
||||||
# VIM
|
# VIM
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
Loading…
Reference in New Issue
Block a user