Skip to content

Commit

Permalink
chore: further automate release process
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akash1810 committed Feb 5, 2021
1 parent 86bf433 commit 0b78437
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions script/release
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down

0 comments on commit 0b78437

Please sign in to comment.