Use npm to Tag and Version a Github Action Package for Workflow Version Control

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

In this lesson, you'll learn how to use the version tool from npm to increment the version of your new Github Action. We'll walk through setting up a convenience npm script and using it to both update the package's version in package.json and adding a git tag for external use.

Colby Fayock: [0:00] We're going to start off with a new custom Action in GitHub. When using Actions in your workflow, you want to make sure you are using a tag. This way, you can specify the exact version that you're using for your project.

[0:09] Inside our project, we're specifying our version, but we are not adding tags. [inaudible] want to use the Git Tag functionality. This is [inaudible] right into Git. Alternatively, we can use npm-version. This feature from npm will both update the version of your package and add a tag.

[0:23] To do that, we're going to start off by adding an npm script called bump. Here we simply get to run the command npm version. Really, you don't need bump and can instead use npm. We're adding bump just to make it a little bit easier.

[0:35] By default, running npm version just shows the version information of our environment. Instead, we want to use it to bump up the version.

[0:41] Npm uses semantic versioning. This means we have a few different options for what we want to upgrade. In our case, let's make this 1..1. In order to bump just that last number, we're going to use patch. Let's run yarn bump patch. Once it's finished, we can see the new version.

[0:56] If you notice, in your package.json file you'll also see that the version there is incremented. Part of the goal is to get a tag. If we run git tag, we can now see our version. Once we push that to GitHub, we can see our new package version. We can also see that we have a new tag. Now that we have our new tag, when we reference our Action externally, we can add a tag just like actions/checkout.

[1:16] In review, we wanted to add versioning and tagging to our Action. Inside our package.json we added a bump script that ran npm version. Once we ran that script with patch, we saw our version increment and we saw our new tag on our project.

egghead
egghead
~ 2 hours ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today