DEV Community

Kevan Y
Kevan Y

Posted on

Lab 10 - Time to release

Introduction

For the tenth lab, It finally time to release our SSG to the public.

Process

First of all there is 2 kind of registry for node.js, it either GitHub's npm registry or npm registry.

GitHub's npm registry

Package Hosted on GitHub.
Steps:

  • Create a GitHub Token with repo, read:package, and write:package.
  • Create a .npmrc file in the root of your repo and add @OWNER:registry=https://npm.pkg.github.com where @OWNER represent your GitHub Username.
  • Rename package name to @OWNER/name where @OWNER represent your GitHub Username, and name represent your package name.
  • Make sure repository field in your project's package.json match URL of your project GitHub repo.
  • Login to GitHub registry
$ npm login --scope=@OWNER --registry=https://npm.pkg.github.com

> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
Enter fullscreen mode Exit fullscreen mode

Where @OWNER represent your GitHub Username, Username your GitHub Username, Password your GitHub Token generated in previous steps, and email a public email.

  • Time to publish by running npm publish

Now your package is published to GitHub's npm registry and can view your package in your repo package tab.

Npm registry

Package Hosted on npmjs.
Steps:

  • Create an account in npmjs
  • Verify your email (Important to do for publishing your package)
  • Login to NPM registry
$ npm login 

> Username: USERNAME
> Password: PASSSORD
> Email: PUBLIC-EMAIL-ADDRESS
Enter fullscreen mode Exit fullscreen mode

Where Username your npm Username, Password your npm password, and email your email that was used to setup to npmjs.

  • Time to publish by running npm publish

Now your package is published to npm registry and can view your package in package tab.

For me, I picked npm registry. But before publishing we need to create a tag and post a release on GitHub.

I make sure everything is ready for release such as updating readme, fix some function, package.json...
After that I committed my change and create a tag using git tag -a 1.0.2 -m "Release 1.0.2" then after that I pushed to remote using git push origin --follow-tags.
After that on GitHub I click on create release, I select my tag previously created and put a description.
Image description

Now after created a release I can publish my package by running npm publish.

Now my package is viewable in https://www.npmjs.com/package/text-ssg

Time to test if uploading my package is successful.
Command ran npx text-ssg@latest -h

Image description

Conclusion

After 12 weeks of development It feels great to publish my CLI to the public. Even thought it looks small but it's a goal achieved in my developer life.

GitHub: @Kevan-Y
Repo: https://github.com/Kevan-Y/text-ssg
Thanks contributor:
@irenejoeunpark
@DukeManh
@AndreWillomitzer

Top comments (0)