diff --git a/.github/workflows/continuous-releases.yml b/.github/workflows/continuous-releases.yml new file mode 100644 index 0000000..914d972 --- /dev/null +++ b/.github/workflows/continuous-releases.yml @@ -0,0 +1,46 @@ +# Every commit pushed to a branch of this repo gets an installable preview of +# the package, without publishing anything to npm: +# +# npm i https://pkg.pr.new/@datocms/content-link@ +# +# The point is to cross a repo boundary while developing. A change here can be +# tried inside a site or a demo that lives in another repository from a real +# tarball, instead of `npm link` or pinning a git branch by hand and +# remembering to unpin it later. It also means a fix can be handed to whoever +# reported it before we cut a release. +# +# Pull requests opened from forks are deliberately not published: this runs on +# pushes to branches of *this* repo, which only people with write access can +# make, so an unreviewed fork cannot mint a URL under our namespace. If we ever +# want fork previews too, pkg.pr.new documents an "approved pull requests only" +# recipe that gates them behind a maintainer's review. +name: Continuous releases + +on: + push: + # Every branch. Defining `branches` on its own also means tag pushes don't + # trigger this, which is what we want: a tag points at a commit that was + # already published when it landed on its branch. + branches: ["**"] + +permissions: {} + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + # Pinned, and deliberately not the matrix `node.js.yml` runs: this + # job only has to build a tarball, not prove which Node versions the + # package supports. + node-version: 22 + cache: "npm" + - run: npm ci + - run: npm run build + # No path argument: this is a single-package repo, so pkg-pr-new packs + # the working directory. + - run: npm exec -- pkg-pr-new publish --commentWithSha diff --git a/README.md b/README.md index 693f151..f30149d 100644 --- a/README.md +++ b/README.md @@ -562,6 +562,23 @@ it, disable encoding for that field by setting [`content_link_enabled: false`](#disabling-content-link-encoding-for-a-specific-field) via the CMA. To strip it at render time instead, use [`stripStega`](#low-level-utilities). +## Trying a change before it's released + +Every push to a branch here publishes a preview of the package, which you can +install anywhere — no npm release, no `npm link`: + +``` +npm i https://pkg.pr.new/@datocms/content-link@ +``` + +The exact URL shows up in the commit's check run on GitHub, and in a comment on +the pull request once there is one. This is the supported way to try a change +inside a site that lives in another repository, or to hand a fix to whoever +reported it before it is released. + +Previews are throwaway: they are never published to npm, and the URL stops +resolving after a while. Never commit one to a `package.json` that ships. + ## License MIT © DatoCMS diff --git a/package-lock.json b/package-lock.json index 6200692..b418ee1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "jsdom": "^24.0.0", "np": "^10.2.0", "penpal": "^4.1.1", + "pkg-pr-new": "^0.0.88", "rimraf": "^5.0.5", "serve": "^14.2.4", "tsup": "^8.5.1", @@ -6456,6 +6457,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pkg-pr-new": { + "version": "0.0.88", + "resolved": "https://registry.npmjs.org/pkg-pr-new/-/pkg-pr-new-0.0.88.tgz", + "integrity": "sha512-Xc6PMJ2gher0WZP+rtjefFk26hIb7V1PTLL30bmy1Z2vsRmSvqiss7Ag1XUdyplTGYzIlFNJp4L3vMNmK44N6g==", + "dev": true, + "license": "MIT", + "bin": { + "pkg-pr-new": "bin/cli.js" + } + }, "node_modules/pkg-types": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", diff --git a/package.json b/package.json index dbf9c27..4a26866 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,7 @@ "jsdom": "^24.0.0", "np": "^10.2.0", "penpal": "^4.1.1", + "pkg-pr-new": "^0.0.88", "rimraf": "^5.0.5", "serve": "^14.2.4", "tsup": "^8.5.1",