📦 npm publish with github actions
I recently published my first package to npm, eslint-config-bradgarropy. But now that it's had a few version bumps, eight to be exact, I wanted to automate the release process. Turns out I could do this without even leaving GitHub with the relatively new GitHub Actions feature.
I set up the workflow by creating a .github/main.workflow
file in the project. From there I had the choice to edit the main.workflow
file manually, or use the visual editor on GitHub. I went with the visual editor.
I clicked the create a new workflow button, gave it a name, and configured it to run when a release is created.

Next it was time to hook up an action. I dragged the blue arrow into the next box and found that GitHub already had an npm action. I edited the label, changed the args field to publish
, and added my NPM_AUTH_TOKEN
.

I clicked Done and the final workflow looks like this.

I checked the main.workflow
file and found that the visual editor had generated the following code.
workflow "🚀 release" {
on = "release"
resolves = ["📦 npm publish"]
}
action "📦 npm publish" {
uses = "actions/npm@master"
secrets = ["NPM_AUTH_TOKEN"]
args = "publish"
}
Makes sense! Then I made some releases and headed over to the Actions tab of my repository and took a look. The tab showed each run of the 🚀 release
workflow, where you can drill down and see the logs from each 📦 npm publish
action!

This process coudn't have been easier, and now I'm looking for other automation opportunities for GitHub Actions. Head over to Twitter and link me your favorite or custom actions!