DEV Community

Avelyn Hyunjeong Choi
Avelyn Hyunjeong Choi

Posted on

Release project with npm

In this blog, I will be releasing my til_tracker project with npm

Process for creating a release

  1. Create an account for npm.
  2. Ensure you have package.json file in the root directory.
  3. Add/Update README.md file go give full instructions on how to your code.
  4. Tag your release, using npm version 1.0.0 -m "Release v1.0.0"
  5. Push the new tag to GitHub, using git push origin main --tags
  6. Enter npm login in the terminal to log in to npm first.
  7. Use npm publish --access public for final release.
  8. Now, you can run npm i til_tracker. https://www.npmjs.com/package/til_tracker

Automate Release Process with GitHub Actions
Following cd.yml was implemented to automate a new release whenever a new tag is pushed to the main branch.

// .github/workflows/cd.yml

name: cd

on:
  push:
    tags:
      - 'v**'

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Setup .npmrc file to publish to npm
        uses: actions/setup-node@v1
        with:
          node-version: '20.x'
          registry-url: 'https://registry.npmjs.org'

      - name: Install node dependencies
        run: npm ci

      - name: Build
        run: npm run build

      - name: Publish to npm
        run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

*NOTE: you need to set up an access token from npm. Click your profile, and you will see "Access Tokens". Copy the access token and paste the token in GitHub Settings/Secrets, as NPM_TOKEN.

Image description

Workflow Result
Image description

Installation Guide

  1. Run npm i til_tracker in the terminal
  2. Run cd node_modules/til_tracker to go to the root directory of the til_tracker
  3. Install ts-node if your current project does not have one
  4. Now you can use the til_tracker

User Testing
It was noted that the documentation lacked information on certain prerequisites essential for executing til_tracker. Specifically, the current documentation omitted two crucial steps: the requirement of ts-node as a prerequisite and the necessity for the user to navigate to the root directory of til_tracker in node_modules to enable the use of til_tracker. So, adjustments were made to the README.md file to incorporate these details. Following these changes, the instructions in the README.md file became more user-friendly, allowing my reviewer to use it without any issues.

You can find the complete README.md file in here: README.md

Top comments (0)