/pkg.pr.new

Continuous (Preview) Releases for your libraries!

Primary LanguageTypeScript

pkg.pr.new

We call it "Continuous Releases" too.

With pkg.pr.new, each of your commits and pull requests will trigger an instant preview release without publishing anything to NPM. This enables users to access features and bug-fixes without the need to wait for release cycles using npm or pull request merges.

  • 🚀 Instant Builds
  • 🍕 No Need for NPM Access
  • 🛠️ Github Workflows Friendly
  • 📦️ No Configuration
  • 🔩 Single Command
  • ✉️ Pull Request Comments
  • 🔥 Check Runs

pkg.pr.new won't publish anything to NPM; instead, it leverages its own URLs, which are npm-compatible.

npm i https://pkg.pr.new/tinylibs/tinybench/tinybench@a832a55

# npm i https://pkg.pr.new/${owner}/${repo}/${package}@{commit}

It is aiming to reduce the number of these comments :)

This was fixed in #18. Can we release that fix?

Setup

The Github Application is available here.

Important

Make sure it's installed on the repository before trying to publish a package.

After installing on your repository, you can run npx pkg-pr-new publish in your workflows and then you have continuous releases!

npm install --save-dev pkg-pr-new # or `npx pkg-pr-new publish`

For workspaces:

npx pkg-pr-new publish ./packages/A ./packages/B # or `npx pkg-pr-new publish ./packages/*`

For templates (experimental):

Note

With templates, pkg.pr.new will generate Stackblitz instances for the given directories with the new built packages.

npx pkg-pr-new publish ./packages/A --template ./examples/*

For shorter urls, --compact can be useful:

npx pkg-pr-new publish --compact ./packages/A ./packages/B

--compact requires your package to be a valid (published) package on npm with a specified repository field in the package.json! See this.

With --compact:

npm i https://pkg.pr.new/tinybench@a832a55

Without --compact:

npm i https://pkg.pr.new/tinylibs/tinybench/tinybench@a832a55

pkg.pr.new uses npm pack --json under the hood, in case you face issues, you can also use the --pnpm flag so it starts using pnpm pack. This is not necessary in most cases.

pkg.pr.new is not available in your local environment and it only works in workflows since it is not a js registry.

Examples

Release each commit and pull request:

name: Publish Any Commit
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - run: corepack enable
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: "pnpm"

      - name: Install dependencies
        run: pnpm install

      - name: Build
        run: pnpm build

      - run: pnpx pkg-pr-new publish

Release approved pull requests only:

name: Publish Approved Pull Requests
on:
  pull_request_review:
    types: [submitted]

jobs:
  approved:
    if: github.event.review.state == 'APPROVED'
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - run: corepack enable
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: "pnpm"

      - name: Install dependencies
        run: pnpm install

      - run: pnpx pkg-pr-new publish

Releasing approved pull requests is the recommended way of having continuous releases. This ensures users always install approved and safe packages.

Publishing is only available in workflows and it supports any workflow trigger event, more information here.