diff --git a/.github/workflows/compiler.yml b/.github/workflows/compiler.yml index 3aa365aa..8e82393e 100644 --- a/.github/workflows/compiler.yml +++ b/.github/workflows/compiler.yml @@ -109,7 +109,7 @@ jobs: - run: npm install -g npm@latest # trusted publishing needs npm 11.5.1 or later - name: Platform packages run: | - node scripts/sync-optional-deps.mjs + node scripts/sync-optional-deps.mjs --publish npx napi artifacts --output-dir artifacts --npm-dir npm for d in npm/*/; do npm publish "$d" --access public; done - run: npm publish --access public diff --git a/compiler/README.md b/compiler/README.md index 80cf3059..17769fb8 100644 --- a/compiler/README.md +++ b/compiler/README.md @@ -94,8 +94,11 @@ needs a request-scoped app for server functions to run in. ### Releasing A release is a version bump merged to `main`: `npm version ---no-git-tag-version` here, whose `version` script brings `npm/*` and -`optionalDependencies` along. The `compiler` workflow builds and tests +--no-git-tag-version` here, whose `version` script brings `npm/*` along. The +`optionalDependencies` on the platform packages are written by the publish +job, never committed: committed, they would put the platform packages in the +lock once they are on npm, and the next version bump would leave the lock out +of sync until the new ones were published. The `compiler` workflow builds and tests every platform on every change; on `main`, once the repository variable `RELEASES` is `on`, it publishes a version npm does not have, platform packages first, by trusted publishing from the `release` environment, and diff --git a/compiler/package-lock.json b/compiler/package-lock.json index dfa4a3b5..a96492fe 100644 --- a/compiler/package-lock.json +++ b/compiler/package-lock.json @@ -15,14 +15,6 @@ "@napi-rs/wasm-runtime": "^1.1.6", "emnapi": "^1.11.3" }, - "optionalDependencies": { - "@reactivescript/compiler-darwin-arm64": "0.1.0", - "@reactivescript/compiler-darwin-x64": "0.1.0", - "@reactivescript/compiler-linux-arm64-gnu": "0.1.0", - "@reactivescript/compiler-linux-x64-gnu": "0.1.0", - "@reactivescript/compiler-win32-x64-msvc": "0.1.0", - "@reactivescript/compiler-wasm32-wasi": "0.1.0" - }, "peerDependencies": { "@solidjs/vite-plugin": "*" }, diff --git a/compiler/package.json b/compiler/package.json index eb3a2020..bc07d885 100644 --- a/compiler/package.json +++ b/compiler/package.json @@ -68,13 +68,5 @@ "@napi-rs/cli": "^3.10.6", "@napi-rs/wasm-runtime": "^1.1.6", "emnapi": "^1.11.3" - }, - "optionalDependencies": { - "@reactivescript/compiler-darwin-x64": "0.1.0", - "@reactivescript/compiler-darwin-arm64": "0.1.0", - "@reactivescript/compiler-linux-x64-gnu": "0.1.0", - "@reactivescript/compiler-linux-arm64-gnu": "0.1.0", - "@reactivescript/compiler-win32-x64-msvc": "0.1.0", - "@reactivescript/compiler-wasm32-wasi": "0.1.0" } } diff --git a/compiler/scripts/sync-optional-deps.mjs b/compiler/scripts/sync-optional-deps.mjs index a74cf579..6eef7fdc 100644 --- a/compiler/scripts/sync-optional-deps.mjs +++ b/compiler/scripts/sync-optional-deps.mjs @@ -1,14 +1,19 @@ -// The platform packages (npm/*) at this package's version, and this package's optionalDependencies on them: what -// `npm run version` leaves before a release is published (.github/workflows/compiler.yml). +// The platform packages (npm/*) at this package's version (`npm version` runs this), and, with `--publish`, this +// package's optionalDependencies on them, which the publish job writes just before it publishes +// (.github/workflows/compiler.yml). They are never committed: a committed optionalDependencies puts the platform +// packages in the lock once they exist on npm, and a version bump then leaves the lock out of sync (`npm ci` refuses +// it) until the new ones are published. import { readFileSync, readdirSync, writeFileSync } from "node:fs"; const read = f => JSON.parse(readFileSync(f, "utf8")); const write = (f, j) => writeFileSync(f, JSON.stringify(j, null, 2) + "\n"); +const publish = process.argv.includes("--publish"); const pkg = read("package.json"); +if (publish) pkg.optionalDependencies = {}; for (const dir of readdirSync("npm")) { const p = read(`npm/${dir}/package.json`); p.version = pkg.version; write(`npm/${dir}/package.json`, p); - pkg.optionalDependencies[p.name] = pkg.version; + if (publish) pkg.optionalDependencies[p.name] = pkg.version; } -write("package.json", pkg); +if (publish) write("package.json", pkg);