Skip to main content Accessibility Feedback

How to automatically create a release for a pull request using a bash script

Last month, I did some testing on Kelp’s performance and found that because compression algorithms rely on repeated patterns, smaller modular files reduce the effectiveness of gzip and brotli.

Based on this, I’m release two versions of Kelp: a pre-bundled version and one with modular files.

Rather than trying to remember to…

  1. Bump the version,
  2. Run the build,
  3. Then add and push the files…

I decided to create a little bash script to automate the process.

You can update the version in your package.json file by running…

npm version <major|minor|patch>

You can get the name of the current branch by running this in Terminal…

git branch --show-current

I combined that with my regular git add and git push commands into a release.sh file…

BRANCH=`git branch --show-current`
npm --no-git-tag-version version $1 && npm run build && git add . && git commit -a -m "bundle for release" && git push origin ${BRANCH} && git open

I can run it like this…

sh release.sh minor

That will make a minor version increase, run my build process (I’m using ESBuild), add the new build files, commit them for release, and push them to my current branch.

I also have git-open by Paul Irish installed, and this runs that command to open GitHub so I can create a new PR.