Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Release on NPM using Github Actions
Giuliano1993
Giuliano1993

Posted on

     

Release on NPM using Github Actions

Good morning everyone and happy MonDEV! ☕
How was your week? Have you tried creating your own npx command? If you have, today's newsletter will help streamline the release process; if you haven't, it might still be useful in the future or offer inspiration for other projects that could benefit from a GitHub passage to implement CI/CD.

Today we talk about GitHub Actions and how to automate the release of new versions of your package! Did you know that, whether for the less experienced, those wanting to learn, or simply to save time, GitHub has a rich list of preconfigured actions to perform releases on the most well-known package managers? NPM is, of course, a leader in this list!

Let's see how to release a package in a few simple steps! First of all, we'll need a token issued by npm: to get it, log in to your account, click on the profile picture in the top right, then onAccess Tokens, and then onGenerate New Token > Classic Token; after confirming using the password, name your token and selectPublish as the type; copy your token and set it aside.

Now, going into your repo, on the Action panel, it will suggest workflows to start from; searching for npm, you will find "publish npm package". A new file will be created with a working workflow that by default will release your package every time you create a new release. If you don't use tests (oh no!), remove the line withrun: npm test... Then hurry to write tests and reintegrate it ;) In the last line, you'll notice a value in curly braces; that represents your npm token. Save the file and in the repo'ssettings, undersecrets and variables > Actions, add a new secret with the keynpm_token.

You're done! Now, every time you create a release, your repo will be directly distributed on npm! Of course, it's also possible to modify the trigger and activate it on every push or pull request to a specific branch, it's all up to your preferences!


I hope you have fun with GitHub Actions and that, regardless of the project you want to release, you find some interesting insights!
Have a great start of the week and happy coding 0_1

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Hi, I'm Giuliano and I'm a full stack web developer based in Rome. I love playing around with code trying out new things. I love to share knowledge and get into inspiring conversations.
  • Location
    Rome, Italy
  • Pronouns
    he/him
  • Work
    Full-stack web developer and dev mentor
  • Joined

More fromGiuliano1993

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp