diff --git a/.github/workflows/continuous-releases.yml b/.github/workflows/continuous-releases.yml new file mode 100644 index 0000000..11f76eb --- /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: +# +# npx https://pkg.pr.new/datocms@ environments:list +# +# 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 0dc3e89..968d1a6 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,24 @@ live APIs: they need a `.env` at the root (copy `.env.sample`) and, for WordPress, `docker compose up` in `packages/cli-plugin-wordpress`. Each suite checks its prerequisites first and tells you which one is missing. +## Trying a change before it's released + +Every push to a branch here publishes a preview of all the packages, which you +can run or install anywhere — no npm release, no `npm link`: + +``` +npx https://pkg.pr.new/datocms@ environments:list +npm i https://pkg.pr.new/@datocms/cli-plugin-wordpress@ +``` + +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. A release publishes the packages that changed, and gives them diff --git a/package-lock.json b/package-lock.json index f04ccf4..dd3a9a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "lint-staged": "^13.1.0", "mocha": "^10", "oclif": "^4", + "pkg-pr-new": "^0.0.88", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tslib": "^2.3.1", @@ -10970,6 +10971,16 @@ "node": ">=0.10" } }, + "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.1.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", @@ -20858,6 +20869,12 @@ "integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==", "dev": true }, + "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 + }, "possible-typed-array-names": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", diff --git a/package.json b/package.json index b4d3c81..6069922 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "lint-staged": "^13.1.0", "mocha": "^10", "oclif": "^4", + "pkg-pr-new": "^0.0.88", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tslib": "^2.3.1", diff --git a/packages/cli-utils/package.json b/packages/cli-utils/package.json index 19441c4..b6a4a82 100644 --- a/packages/cli-utils/package.json +++ b/packages/cli-utils/package.json @@ -5,6 +5,11 @@ "author": "Stefano Verna ", "homepage": "https://github.com/datocms/cli", "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/datocms/cli.git", + "directory": "packages/cli-utils" + }, "main": "lib/index.js", "types": "lib/index.d.ts", "directories": {