Skip to content

Add GitHub Action to auto-publish npm package #120

@vinitkhandal717

Description

@vinitkhandal717

Issue Type

  • Feature Request

Description

Add a GitHub Actions workflow that automatically publishes the npm package to the registry when a PR is merged to the main branch, and a new version is released via GitHub Release or tag.


Expected Behavior

  • When a pull request is merged into main:
    • If the commit includes a version bump (e.g., via Changesets or package.json update)
    • And if a GitHub Release is created or a tag matching v*.*.* is pushed

Then:

  • A GitHub Actions workflow should:
    • Run pnpm build
    • Run pnpm publish using an npm auth token
    • Update the changelog if using Changesets
    • Confirm the package is available on npm

Requirements

  • Supports monorepo structure (turbo, pnpm, etc.)
  • Validates that the release/tag follows semver (v1.2.3)
  • Uses GitHub-provided NODE_AUTH_TOKEN secret
  • Fails gracefully with proper logging on publish errors
  • Optional: updates or generates changelog from changesets

Additional Context

  • This should support both public and internal packages
  • Must not publish from non-main branches
  • Use conventional naming or changeset to trigger version bumps

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions