Skip to content

npm Package Existence Checker

Actions
Check package existence for npm Trusted Publishing
v1.0.0
Latest
Verified creator
Star (3)

Verified

GitHub has manually verified the creator of the action as an official partner organization. For more info see About badges in GitHub Marketplace.

npm Package Existence Checker

GitHub Action to check if all public npm packages in a pnpm workspace exist on npm before publishing.

Useful for npm Trusted Publishing workflows where packages must already exist on npm before the first publish.

Usage

- name: Check if packages exist on npm
  uses: directus/npm-package-existence-checker@v1
  with:
    # Optional: Root directory to check (defaults to current directory)
    directory: '.'

Inputs

Input Description Default
directory Root directory to check. .

Outputs

Output Description
existing-packages Comma-separated list of packages that exist on npm
missing-packages Comma-separated list of packages missing on npm
private-packages Comma-separated list of private packages skipped

How it works

  1. Checks the root package.json (if public)
  2. Looks for pnpm-workspace.yaml
  3. Identify all workspace packages
  4. Checks if each non-private package exists on npm
  5. Fails if any packages are missing

Example

name: Release

on:
  release:
    types: [published]

jobs:
  check-packages:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Check packages exist
        uses: directus/npm-package-existence-checker@v1

  publish:
    needs: check-packages
    runs-on: ubuntu-latest
    steps:
      # ... your publish steps

Development

Setup

  1. Install dependencies:

    pnpm install
  2. Create a .env file (required for local testing):

    cp .env.example .env

Running Tests

Run unit tests:

pnpm test

Testing locally

Test the action locally using the dev script.

Test against the current repository:

pnpm dev

Test against a different project directory:

INPUT_DIRECTORY=../path/to/other/project pnpm dev

Building

Build for distribution:

pnpm build

npm Package Existence Checker is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Check package existence for npm Trusted Publishing
v1.0.0
Latest

Verified

GitHub has manually verified the creator of the action as an official partner organization. For more info see About badges in GitHub Marketplace.

npm Package Existence Checker is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.