This content originally appeared on Go Make Things and was authored by Go Make Things
Wow, that title is a mouthful!
Today, I wanted to share the GitHub Action I built to automatically create a new release for Kelp whenever I update the version number in the package.json
file.
Let’s dig in!
(Don’t want to read all of those. Grab the GitHub Action script here.)
Automate the boring stuff!
Every time I add a new feature to Kelp, my UI library for people who love HTML, I have complete a series of steps…
- Update the
package.json
. - Create a PR.
- Wait for tests to pass.
- Merge the PR.
- Create a new git tag with release details.
- Push the new git tag to GitHub.
- Run
npm publish
to deploy the code the CDN.
I know from past experience that I often forget one or more of those last few steps.
I’ll forget to create a release note on GitHub, or forget to push to NPM. Then someone opens a GitHub issue asking me to fix it so they can grab the latest version of the code.
It’s the perfect set of tasks to automate (I already automate testing when a PR is opened).
My preferred workflow
When code is pushed to main
, I want a GitHub action that…
- Checks the version in
package.json
. - Compares it to the current version tag in GitHub.
- If they’re different…
- Generates a new GitHub Release summarizing all of the PRs since the last one.
- Runs
npm publish
to deploy the latest code to CDN.
That seems like it should be easy, but finding the right combination of tools was annoying difficult!
Common workflows
Most popular libraries I looked at used something like Release Drafter to create a draft release, which they would then manually publish when ready.
By default, Release Drafter looking for version tags on each PR (major
, minor
, and patch
), and automatically creates a release version based on the highest level tag and last release version.
I think this kind of flow caters well to big projects like Bootstrap that will release a bunch of stuff all at once.
For my libraries, I prefer to release lots of small updates frequently. I’m a big fan of shipping small updates early-and-often.
I’m also not great at remembering to tag PRs with version categories, and frankly, I want to manually control that in the package.json
file myself anyways.
And most NPM release scripts I found rely on the tag update.
When a new tag is published, it grabs that tag and pushes a new NPM release with that as the version number. In most scripts I found, the package.json
file is cut out of the process.
DIY it!
I didn’t fork or modify any of these existing tools.
But I did dig deeper into their configurations to get a setup that worked better for me.
- I found an Action in the GitHub Actions Marketplace that let me grab the version number from
package.json
. - I found an Action to get the current tag version from the GitHub repository.
- I setup my script to compare the two, and only run if they’re not the same.
- I found the Release Drafter docs on how to manually set the version number and automatically publish the release instead of just drafting it.
Now, any time the package.json
changes, the whole “deploy it” process is automated for me.
If you use this script…
There are a few things you need to know.
- It uses outputs, which GitHub has deprecated and will stop supporting in the future. They recommend
env
variables now, so I’ll need to update things in the future. - It requires a fine-grained GitHub token named
GH_SECRET
that requires read/write permission for both content and PRs. - It requires an NPM CLI token named
NPM_TOKEN
. - You’ll want to change the
github.repository
value to your own. This prevents forks from running the CI script.
Both of those tokens get saved in your repository’s “Secrets” section in settings.
You can download the GitHub Action to use yourself here.
If you have any questions about all this, let me know!
Like this? A Lean Web Club membership is the best way to support my work and help me create more free content.
This content originally appeared on Go Make Things and was authored by Go Make Things

Go Make Things | Sciencx (2025-07-07T14:30:00+00:00) How to automatically create a new release and publish to NPM whenever package.json is updated using a GitHub Action. Retrieved from https://www.scien.cx/2025/07/07/how-to-automatically-create-a-new-release-and-publish-to-npm-whenever-package-json-is-updated-using-a-github-action/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.