Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/compiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <patch|minor>
--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
Expand Down
8 changes: 0 additions & 8 deletions compiler/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
13 changes: 9 additions & 4 deletions compiler/scripts/sync-optional-deps.mjs
Original file line number Diff line number Diff line change
@@ -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);
Loading