putitoutthere 0.2.36 → 0.2.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -16,6 +16,7 @@ are prefixed `**BREAKING**` and link to the matching section in
16
16
 
17
17
  ### Fixed
18
18
 
19
+ - Fixed: `kind = "npm"` `build = "napi"` releases now bake the planned release version into the compiled `.node`. `_matrix.yml` (and its e2e mirror `e2e-fixture-job.yml`) run a `write-crate-version` step on each per-triple napi row before `npm run build`, so `napi build` compiles the addon with the right `CARGO_PKG_VERSION` — matching the maturin `write-version` (#276) and bundled-cli `write-crate-version` (#366) pre-build bumps. Previously napi had no pre-build bump: the synthesized per-platform `package.json` carried `matrix.version`, but the `.node` inside it embedded whatever literal sat in the crate's `Cargo.toml`, so a library re-exposing the Rust core's `version()` through napi reported a version diverging from the published npm package. The bump targets `matrix.path` and runs only when a `Cargo.toml` is colocated there (the napi-rs single-crate default — the shape template-lib and the `js-napi` fixture use), resolving `version.workspace = true` to the workspace root via #428. A multi-mode package (`build = ["napi", "bundled-cli"]`) or one whose napi crate lives elsewhere has no `Cargo.toml` at the package path and is skipped with a `::notice::` — there is no per-napi `crate_path` config to point at a non-colocated crate yet, so that `.node` still embeds its on-disk version. The noarch `main` row is excluded (it compiles no `.node`). See [MIGRATIONS.md](./MIGRATIONS.md#napi-node-embeds-the-release-version). #429. (verified by: unit/ubuntu-latest)
19
20
  - Fixed: `putitoutthere`'s pre-build version rewrite now follows Cargo **workspace version inheritance** — a crate that sources its version from `[workspace.package].version` via `version.workspace = true` (the idiomatic polyglot layout: one Rust core wrapped by a PyO3 wheel and a napi addon) is now bumped correctly instead of failing the release. The maturin `write-version` (#276) and npm/pypi bundled-cli `write-crate-version` (#366) steps both rewrote only a literal `[package].version` and threw `Cargo.toml: no [package].version field found` on an inheriting member, because the inherited version lives in a different file — the workspace root — that neither step read. So a release for that layout was blocked, not merely mis-versioned. The rewrite path now resolves the manifest first: a literal `[package].version` is bumped in place byte-for-byte as before, while an inheriting member walks up to the nearest ancestor `[workspace]` `Cargo.toml` and rewrites its `[workspace.package].version`. Unparseable or version-less manifests fall through to the prior literal-only path (`replaceCargoVersion`'s existing error), so single-crate layouts are byte-for-byte unchanged. New `src/find-workspace-root.ts`, `src/replace-workspace-package-version.ts`, and `src/write-resolved-cargo-version.ts`; `write-version.ts` / `write-crate-version.ts` now delegate to the resolver. See [MIGRATIONS.md](./MIGRATIONS.md#version-bump-follows-cargo-workspace-inheritance). #428. (verified by: unit/ubuntu-latest)
20
21
  - Fixed: `putitoutthere publish` now writes a package's git tag when that version is already live on the registry but untagged, instead of skipping it silently. The publish loop's already-published branch (`isPublished` → true) returned *before* the tag-creation step, so a version that reached the registry on a half-failed run (the run died after publishing but before tagging — e.g. a cancelled downstream job) was left published-but-untagged and never self-healed: piot derives "last released version" from git tags, so on every later run the package looked unreleased, fell back to `first_version` (already live), skipped again, and stayed stuck forever — while its dependents kept bumping and publishing, opening unflagged version skew. The skip branch now calls a shared, idempotent `ensureTag` (new `src/ensure-tag.ts`; a no-op when the tag already exists, and reused by the normal post-publish tag step), so a stuck package self-heals on its next release run. See [MIGRATIONS.md](./MIGRATIONS.md#publish-path-auto-heal-missing-tags). #407. (verified by: integration, unit/ubuntu-latest)
21
22
  - Fixed: a `kind = "pypi"` `build = "maturin"` package whose wheel is **Python-version-independent** — `[tool.maturin].bindings = "bin"` (a Rust-binary wheel tagged `py3-none`) or a pyo3 `abi3` / `abi3-pyXY` extension (a stable-ABI wheel tagged `cp3x-abi3`) — no longer fans its wheel build across every CPython version `requires-python` / `python_versions` resolves to. Such a wheel is byte-identical regardless of the interpreter that built it, so the fan produced N duplicate wheels: each fanned row uploaded under its own `-py<ver>` artifact, and the documented consumer `pypi-publish` recipe's `actions/download-artifact … merge-multiple: true` then extracted N copies of the same wheel filename onto one path concurrently — a torn write that failed `twine check` with `zipfile.BadZipFile` (observed on a `bindings = "bin"`, `requires-python = ">=3.9"` package: six identical wheels per platform, the x86_64-linux copy losing its extraction race while macOS/aarch64 won theirs). The planner (`src/plan.ts`) now collapses the fan to a single wheel row per target for these packages — built once on the newest resolved interpreter, keeping the historical unsuffixed `<pkg>-wheel-<triple>` artifact name — and the new `src/wheel-abi.ts` detects version independence from the package's real `pyproject.toml` (`[tool.maturin].bindings`, `[tool.maturin].features`) and `Cargo.toml` (an `abi3` / `abi3-pyXY` feature on the `pyo3` / `pyo3-ffi` dependency). Ordinary per-version extension modules (no abi3, no `bindings = "bin"`) still fan and keep their `-py<ver>` suffixes; the sdist row is unchanged. Also saves the redundant N−1 wheel builds. Detection is conservative — an unrecognized abi3 setup (workspace-inherited `pyo3`, a target-specific dependency table) falls back to fanning, never worse than before. See [README → `kind = "pypi"`](./README.md#kind--pypi) and [MIGRATIONS.md](./MIGRATIONS.md#pypi-version-independent-wheels-build-once). #401. (verified by: integration, unit/ubuntu-latest)
package/MIGRATIONS.md CHANGED
@@ -21,6 +21,40 @@ Each section covers five things, in order:
21
21
 
22
22
  ## Unreleased
23
23
 
24
+ ### napi `.node` embeds the release version
25
+
26
+ **Summary.** `kind = "npm"` `build = "napi"` releases now rewrite the napi
27
+ crate's version to the planned release version before `napi build` compiles
28
+ the `.node`, mirroring the maturin (#276) and bundled-cli (#366) pre-build
29
+ bumps. Previously the compiled `.node` embedded whatever `[package].version`
30
+ literal sat on disk, so a library re-exposing the Rust core's `version()`
31
+ through napi reported a version diverging from the published npm package
32
+ (whose `package.json` version was already correct).
33
+
34
+ **Required changes.** None for the common case. The bump is a
35
+ workflow-internal step; a consumer whose napi crate's `Cargo.toml` is
36
+ colocated with `package.json` (the napi-rs single-crate default, including
37
+ the `version.workspace = true` workspace shape via #428) needs no config
38
+ change. A **multi-mode** package (`build = ["napi", "bundled-cli"]`) or one
39
+ whose napi crate lives outside the package directory has no `Cargo.toml` at
40
+ the package path — piot skips the bump there with a `::notice::` (no
41
+ per-napi `crate_path` config exists yet), so such a `.node` still embeds
42
+ its on-disk `CARGO_PKG_VERSION`. Until a `crate_path` field lands, bump that
43
+ crate's version yourself or colocate its manifest with `package.json`.
44
+
45
+ **Deprecations removed.** None.
46
+
47
+ **Behavior changes without code changes.** For a napi package, the
48
+ per-platform `.node` now reports the released version from any API sourced
49
+ on `CARGO_PKG_VERSION` (e.g. a Rust `version()` re-exported through napi).
50
+ The synthesized per-platform `package.json` version is unchanged (it was
51
+ already `matrix.version`). Non-napi npm packages are unaffected.
52
+
53
+ **Verification.** Release a napi package and read its Rust-sourced
54
+ `version()` from the installed addon (or inspect the crate manifest the
55
+ build rewrote): it matches the published npm version, not the pre-release
56
+ on-disk literal.
57
+
24
58
  ### Version bump follows Cargo workspace inheritance
25
59
 
26
60
  **Summary.** piot's pre-build version rewrite — the maturin `write-version`
package/README.md CHANGED
@@ -310,7 +310,7 @@ version = 1 # required; only 1 is valid today
310
310
  | `npm` | string | Override `name` → npm name (for scoped packages). |
311
311
  | `access` | enum | `public` \| `restricted`. Default `public`. |
312
312
  | `tag` | string | dist-tag. Default `latest`. |
313
- | `build` | string \| array | `"napi"` \| `"bundled-cli"` (single mode), or an array of entries (each: a bare mode string or `{ mode, name }` with a [name template](#multi-mode-npm-family)). Omitted = vanilla. See [Recipes → Bundled-CLI npm family](#bundled-cli-npm-family). |
313
+ | `build` | string \| array | `"napi"` \| `"bundled-cli"` (single mode), or an array of entries (each: a bare mode string or `{ mode, name }` with a [name template](#multi-mode-npm-family)). Omitted = vanilla. See Recipes → [napi](#napi-npm-family) / [Bundled-CLI](#bundled-cli-npm-family) npm family. |
314
314
  | `targets` | (string \| object)[] | Required when `build` is set. |
315
315
  | `[package.bundle_cli]` | sub-table | Declarative cross-compile for `build = "bundled-cli"` rows. Fields: `bin` (required), `crate_path` (default `"."`), `features` (default `[]`), `no_default_features` (default `false`). See [Recipes → Bundled-CLI npm family](#bundled-cli-npm-family). |
316
316
 
@@ -747,6 +747,86 @@ registration (a policy on `my-cli` does not cover
747
747
  > No consumer-side change is required; you can keep the lockfile
748
748
  > committed and the `optionalDependencies` declared.
749
749
 
750
+ ### napi npm family
751
+
752
+ Ship a [napi-rs](https://napi.rs) Node addon (a `.node` native library) as
753
+ an npm per-platform family — consumers `import` the package and Node loads
754
+ the prebuilt binary for their platform. The `@node-rs/*` / `@swc/core`
755
+ distribution shape.
756
+
757
+ Config:
758
+
759
+ ```toml
760
+ [[package]]
761
+ name = "my-addon"
762
+ kind = "npm"
763
+ path = "packages/node"
764
+ build = "napi"
765
+ globs = ["packages/node/**", "crates/core/**"]
766
+ targets = [
767
+ "x86_64-unknown-linux-gnu",
768
+ "aarch64-unknown-linux-gnu",
769
+ "x86_64-apple-darwin",
770
+ "aarch64-apple-darwin",
771
+ "x86_64-pc-windows-msvc",
772
+ ]
773
+ ```
774
+
775
+ The engine publishes a per-platform sub-package per target
776
+ (`my-addon-<triple>`) plus a top-level package whose `optionalDependencies`
777
+ pin them at the published version; napi-rs's loader resolves the matching
778
+ one at runtime. The reusable workflow fans the build across your `targets`
779
+ — one native runner per triple — so you never wire per-target steps
780
+ yourself.
781
+
782
+ **You own the build script.** Unlike `bundled-cli` — where the engine runs
783
+ the cross-compile for you — the napi toolchain stays consumer-owned. For
784
+ each per-target row the workflow runs your `package.json` `build` script
785
+ with `TARGET` set to that triple (and `BUILD=napi`); your script runs
786
+ `napi build` for it and stages the resulting `.node` under
787
+ `build/<triple>/`, the directory the engine packages per-platform
788
+ artifacts from:
789
+
790
+ ```js
791
+ // scripts/build.cjs — invoked by your package.json "build" script
792
+ const target = process.env.TARGET;
793
+ // The noarch main row runs with TARGET=main (or unset) — nothing to build.
794
+ if (!target || target === 'main' || target === 'noarch') process.exit(0);
795
+
796
+ // napi-rs emits `<name>.<triple>.node`; stage it under build/<triple>/,
797
+ // e.g. napi build --release --target ${target} --output-dir build/${target}
798
+ ```
799
+
800
+ The `main` (noarch) row carries no per-target binary — its build run is a
801
+ no-op for the `.node` and compiles only your TypeScript / JS.
802
+
803
+ > [!NOTE]
804
+ > **Cross-compilation is yours to arrange.** Each target builds on a
805
+ > native runner where one exists (`x86_64-linux` on `ubuntu-latest`,
806
+ > `aarch64-linux` on `ubuntu-24.04-arm`, darwin on `macos-latest`,
807
+ > windows on `windows-2022`), so the common triples need no cross
808
+ > toolchain — `napi build --target <native triple>` just works. For a
809
+ > target that isn't native to its runner (a `*-musl` triple, or an
810
+ > x86_64 macOS build on the arm64 runner), your build script owns
811
+ > `rustup target add <triple>` and any linker / C-toolchain setup. This
812
+ > is the one place napi differs from `bundled-cli`, where the engine
813
+ > performs the gnu→musl mapping and installs the musl toolchain for you.
814
+
815
+ Each per-platform sub-package needs its own npm trusted-publisher
816
+ registration (a policy on `my-addon` does not cover
817
+ `my-addon-x86_64-unknown-linux-gnu`) — same as the bundled-cli family
818
+ above.
819
+
820
+ The **first-publish lockfile chicken-and-egg** note under
821
+ [Bundled-CLI npm family](#bundled-cli-npm-family) applies identically to
822
+ napi families: the reusable workflow's strict installs self-heal, so you
823
+ can keep the lockfile committed and the `optionalDependencies` declared.
824
+
825
+ > [!NOTE]
826
+ > **Both modes at once.** A package that is *both* a `.node` addon and a
827
+ > CLI declares `build` as an array — see
828
+ > [Multi-mode npm family](#multi-mode-npm-family) below.
829
+
750
830
  ### Multi-mode npm family
751
831
 
752
832
  For a package that is both a napi-rs Node addon (a `.node` library) **and**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putitoutthere",
3
- "version": "0.2.36",
3
+ "version": "0.2.37",
4
4
  "description": "Polyglot release orchestrator for crates.io, PyPI, and npm",
5
5
  "license": "MIT",
6
6
  "repository": {