From 71e3354b027c26efe0b1e0e47bcec2aecf5222a0 Mon Sep 17 00:00:00 2001 From: Stefano Verna Date: Mon, 31 Aug 2026 10:40:47 +0200 Subject: [PATCH] ci: publish a preview of both packages on every push An SDK change can now be installed into a real plugin straight from a branch, without a release: npm i https://pkg.pr.new/datocms-plugin-sdk@ Nothing reaches npm, no version is spent, and there is nothing to clean up afterwards. Installing one preview pulls in the other from the same commit, so a change touching both is tried as one set. 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. Claude-Session: https://claude.ai/code/session_01TbxhxyU1XBsSKtoCJXwAoD --- .github/workflows/continuous-releases.yml | 44 +++++++++++++++++++++++ README.md | 18 ++++++++++ package-lock.json | 17 +++++++++ package.json | 1 + 4 files changed, 80 insertions(+) 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..bb38d33 --- /dev/null +++ b/.github/workflows/continuous-releases.yml @@ -0,0 +1,44 @@ +# Every commit pushed to a branch of this repo gets an installable preview of +# every package, without publishing anything to npm: +# +# npm i https://pkg.pr.new/datocms-plugin-sdk@ +# +# The point is to cross a repo boundary while developing. A change here can be +# tried inside a consumer that lives in another repository — `cms`, a demo, a +# customer project — from a real tarball, instead of `npm link` or pinning a +# git branch by hand and remembering to unpin it later. Installing one preview +# pulls in the previews of its siblings from the same commit, so a change that +# spans several packages is tried as one coherent set. +# +# 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@v7 + - name: Use Node.js + uses: actions/setup-node@v7 + with: + node-version-file: .nvmrc + cache: "npm" + - run: npm ci + - run: npm run build + # Once for all the packages, not once per package: pkg.pr.new expects a + # single invocation per workflow run, and rejects the rest as spam. + - run: npm exec -- pkg-pr-new publish --commentWithSha './packages/*' diff --git a/README.md b/README.md index e1da34a..4957a85 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,24 @@ From there, the [Plugin SDK documentation](https://www.datocms.com/docs/plugin-s To work on the packages themselves (e.g. to prepare a PR or debug an issue in the framework itself), see the "Developing" section of each package's README: [`datocms-plugin-sdk`](https://github.com/datocms/plugins-sdk/blob/master/packages/sdk/README.md#developing), [`datocms-react-ui`](https://github.com/datocms/plugins-sdk/blob/master/packages/react-ui/README.md#developing). Both are developed in this npm-workspaces monorepo, and share a version number whenever they are released together. +## Trying a change before it's released + +Every push to a branch here publishes a preview of both packages, which you can +install into a real plugin — no npm release, no `npm link`: + +``` +npm i https://pkg.pr.new/datocms-plugin-sdk@ +npm i https://pkg.pr.new/datocms-react-ui@ +``` + +The exact URLs show up in the commit's check run on GitHub, and in a comment on +the pull request once there is one. Installing one preview pulls in the previews +of its siblings built from the same commit, so a change spanning several +packages can be tried as one coherent set. + +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. + ## Releasing Maintainers only. The two packages share one version number and are always diff --git a/package-lock.json b/package-lock.json index 6417454..f923835 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@typescript-eslint/parser": "^5.42.0", "husky": "^9.0.11", "jest": "^29.2.2", + "pkg-pr-new": "^0.0.88", "ts-jest": "^29.0.3", "tsx": "^4.19.1", "turbo": "^2.10.11", @@ -8049,6 +8050,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/postcss": { "version": "8.5.26", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", @@ -16203,6 +16214,12 @@ "find-up": "^4.0.0" } }, + "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 + }, "postcss": { "version": "8.5.26", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", diff --git a/package.json b/package.json index 4b63de3..49e0a32 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@typescript-eslint/parser": "^5.42.0", "husky": "^9.0.11", "jest": "^29.2.2", + "pkg-pr-new": "^0.0.88", "ts-jest": "^29.0.3", "tsx": "^4.19.1", "turbo": "^2.10.11",