From 0b7843711e78257b05def04408bcc6c34fee5aba Mon Sep 17 00:00:00 2001 From: Akash Askoolum Date: Fri, 5 Feb 2021 13:09:38 +0000 Subject: [PATCH] chore: further automate release process We use `np` to orchestrate the publication of a module to NPM. One of the steps `np` performs is a commit to edit `package.json`'s `version`. As we have branch protection enabled for `main`, we have to raise a PR to get this commit in. Automate this process in the release script as it's pretty boring! This change assumes one has the GitHub CLI installed. --- README.md | 2 +- script/release | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 49b59251e7..1e549436d0 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ To release a new version, run `./script/release`. You will need to be logged in The script automatically prepares a [GitHub Release](https://docs.github.com/en/github/administering-a-repository/about-releases) and opens a pre-populated form in your browser. Please complete the GitHub Release creation manually. -You will also need to manually checkout a new branch and open a PR containing version bump changes which are automatically committed during the release process. +It will also automatically create a PR to edit `version` in [`package.json`](./package.json). ### A note about release numbers diff --git a/script/release b/script/release index 9c63853d3b..6b949ea547 100755 --- a/script/release +++ b/script/release @@ -9,6 +9,13 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) if npm whoami &>/dev/null; then rm -rf ./lib npm run release + + # The default branch is protected. + # Raise a chore PR to bump `version` in `package.json`. + NEW_VERSION=$(git log -1 --pretty=%B) + git checkout -b "release-${NEW_VERSION}" + git push -u origin "release-${NEW_VERSION}" + gh pr create --title "chore: ${NEW_VERSION}" --body "" else echo "You are not logged into npm!" echo " Run 'npm login' first!"