# Releasing

> Automated OIDC Trusted Publishing workflow for @zwire/* npm packages and zwire* crates.io releases.

Releases are driven by a single semantic version tag (`vX.Y.Z`) matching every `ts/packages/{core,adapters/*}/package.json` (including adapter `peerDependencies["@zwire/core"] = "^X.Y.Z"`), [`rust/Cargo.toml`](https://github.com/kjmin-dev/zwire/blob/main/rust/Cargo.toml) (`[workspace.package].version`), and every internal crate dependency version under `rust/crates/zwire*/Cargo.toml`.

Both **npm** and **crates.io** publish exclusively through **OIDC Trusted Publishing** in [`.github/workflows/release.yml`](https://github.com/kjmin-dev/zwire/blob/main/.github/workflows/release.yml): every release uses short-lived tokens issued per run, and the repository holds **zero long-lived registry API tokens** (no `NPM_TOKEN` / `CARGO_REGISTRY_TOKEN` secrets, and no static-token fallback in the publish scripts).

---

## 1. Registry Trusted Publishers

Configure Trusted Publishing on each package with the same GitHub Actions identity:

- **Owner:** `kjmin-dev`
- **Repository:** `zwire`
- **Workflow filename:** `release.yml`
- **Environment:** *(none)*

| Registry | Package | Settings |
| :------- | :------ | :------- |
| npm | `@zwire/core` | https://www.npmjs.com/package/@zwire/core/access |
| npm | `@zwire/react` | https://www.npmjs.com/package/@zwire/react/access |
| npm | `@zwire/vue` | https://www.npmjs.com/package/@zwire/vue/access |
| npm | `@zwire/solid` | https://www.npmjs.com/package/@zwire/solid/access |
| npm | `@zwire/svelte` | https://www.npmjs.com/package/@zwire/svelte/access |
| crates.io | `zwire-wasm` | https://crates.io/crates/zwire-wasm/settings |
| crates.io | `zwire-serde` | https://crates.io/crates/zwire-serde/settings |
| crates.io | `zwire-derive` | https://crates.io/crates/zwire-derive/settings |
| crates.io | `zwire-core` | https://crates.io/crates/zwire-core/settings |
| crates.io | `zwire-collections` | https://crates.io/crates/zwire-collections/settings |
| crates.io | `zwire-tx` | https://crates.io/crates/zwire-tx/settings |
| crates.io | `zwire-protocol` | https://crates.io/crates/zwire-protocol/settings |
| crates.io | `zwire` | https://crates.io/crates/zwire/settings |

A **new** crate or package must be published once manually by an owner before a Trusted Publisher can be linked to it.

### Verifying OIDC Readiness

Run a dry-run rehearsal on `main`:

```bash
gh workflow run release.yml --ref main
```

The publish jobs must log both lines below (for every `@zwire/*` package); a refused OIDC exchange fails the run instead of falling back to a static token:

- `npm OIDC Trusted Publishing active for @zwire/<pkg> (ephemeral token issued).`
- `crates.io OIDC Trusted Publishing active (ephemeral token issued).`

---

## 2. Cutting a New Release (`vX.Y.Z`)

1. Synchronize the version across all TS packages and Rust crates in one step:
   ```bash
   mise run release:bump -- X.Y.Z
   (cd ts && npm install --package-lock-only --ignore-scripts)
   ```
2. Promote pending fragments under [`changes/`](https://github.com/kjmin-dev/zwire/blob/main/changes/README.md) into [`CHANGELOG.md`](https://github.com/kjmin-dev/zwire/blob/main/CHANGELOG.md):
   ```bash
   mise run release:changelog
   ```
3. Run full verification (`mise run check && mise run build:ts && mise run test`), commit, push `main`, and push the tag:
   ```bash
   git add -A
   git commit -m "chore(release): prepare vX.Y.Z"
   git push origin main
   git tag -a vX.Y.Z -m "Release vX.Y.Z"
   git push origin vX.Y.Z
   ```
4. [`.github/workflows/release.yml`](https://github.com/kjmin-dev/zwire/blob/main/.github/workflows/release.yml) automatically verifies Spec + TS + Rust + cross-language examples, publishes all 5 `@zwire/*` packages in topological order with provenance via OIDC, publishes the workspace crates followed by the optional bridge crates (`zwire-wasm` and `zwire-serde`) via `rust-lang/crates-io-auth-action@v1` (auto-revoked on job exit), and creates the GitHub Release.
