From 4900e3b8218c2da1ddb74ce190d5cac1f8a9a992 Mon Sep 17 00:00:00 2001 From: Stefano Verna Date: Mon, 31 Aug 2026 11:01:07 +0200 Subject: [PATCH] ci: publish a preview of the package on every push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every commit pushed to a branch now produces an installable tarball, so a component change can be tried in a real Astro site without a release: npm i https://pkg.pr.new/datocms/astro-datocms/@datocms/astro@ Nothing reaches npm, no version is spent, and there is nothing to clean up afterwards. This replaces `npm link` and pinning a git branch by hand, and it means a fix can be handed to whoever reported it before we cut a release. Runs only on pushes to branches of this repo, so a fork cannot mint a URL under our namespace without a maintainer pushing the code first. Also replaces the `git://` in `repository.url` with `git+https://`. GitHub stopped serving `git://` in 2022, so the field was stale either way; it is also what pkg.pr.new reads — from the npm registry, not from here — to decide whether it can mint the shorter URL form. So the short form starts working one release from now, and until then the URL above is the one to use. Claude-Session: https://claude.ai/code/session_01TbxhxyU1XBsSKtoCJXwAoD --- .github/workflows/continuous-releases.yml | 46 +++++++++++++++++++++++ README.md | 18 +++++++++ package-lock.json | 11 ++++++ package.json | 3 +- 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/continuous-releases.yml diff --git a/.github/workflows/continuous-releases.yml b/.github/workflows/continuous-releases.yml new file mode 100644 index 0000000..6feae92 --- /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/astro-datocms/@datocms/astro@ +# +# 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: + node-version-file: .nvmrc + cache: 'npm' + - run: npm ci + # `astro check`, really: this package ships `src/` uncompiled, so there is + # nothing to build. Kept because it is the only type checking that runs + # anywhere in this repo. + - 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 ce03097..aea74e3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ A set of TypeScript-ready components and utilities to work faster with [DatoCMS] - [Features](#features) - [Installation](#installation) +- [Trying a change before it's released](#trying-a-change-before-its-released) - [What is DatoCMS?](#what-is-datocms) @@ -43,6 +44,23 @@ npm install @datocms/astro --- +## 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/astro-datocms/@datocms/astro@ +``` + +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. + # What is DatoCMS? DatoCMS - The Headless CMS for the Modern Web diff --git a/package-lock.json b/package-lock.json index 53ebdc1..e20f2b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "astro": "^5.16.15", "doctoc": "^2.2.1", "np": "^10.0.7", + "pkg-pr-new": "^0.0.88", "prettier": "^3.3.3", "prettier-plugin-astro": "^0.14.1", "simple-git-hooks": "^2.11.1", @@ -9434,6 +9435,16 @@ "node": ">=8" } }, + "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/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", diff --git a/package.json b/package.json index 4ebca4a..abb621f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "sideEffects": false, "repository": { "type": "git", - "url": "git://github.com/datocms/astro-datocms.git" + "url": "git+https://github.com/datocms/astro-datocms.git" }, "homepage": "https://github.com/datocms/astro-datocms", "license": "MIT", @@ -58,6 +58,7 @@ "astro": "^5.16.15", "doctoc": "^2.2.1", "np": "^10.0.7", + "pkg-pr-new": "^0.0.88", "prettier": "^3.3.3", "prettier-plugin-astro": "^0.14.1", "simple-git-hooks": "^2.11.1",