diff --git a/.agents/skills/release/SKILL.md b/.agents/skills/release/SKILL.md new file mode 100644 index 00000000..86985673 --- /dev/null +++ b/.agents/skills/release/SKILL.md @@ -0,0 +1,132 @@ +--- +name: release +description: Prepare, verify, publish, and tag a Logforth partial or workspace-wide multi-crate release on crates.io, keeping manifests, documentation links, changelogs, and signed Git tags aligned on a single release commit. +--- + +# Release + +Use this skill when planning, preparing, verifying, or publishing a Logforth release. + +## Core Invariants + +- **Four-tier publishable DAG**: Logforth publishes 18 crates across four dependency tiers (`libs/*` -> `logforth-core` -> peripheral `0.x` crates -> `logforth` facade; workspace-only `examples`, `tests-integration`, and `xtask` are never published). +- **Partial releases by default**: Bump and publish only crates with user-observable changes or SemVer-propagated dependency updates rather than bumping the entire workspace in lockstep, unless `logforth-core` itself introduces a breaking change. +- **Single frozen `RELEASE_COMMIT`**: Prepare all version bumps, documentation updates, `Cargo.lock` refreshes, and undated changelog sections in one reviewed pull request merged to `main`; never generate per-crate version-bump commits directly on `main`. +- **Three-component caret bounds without `=`**: Keep `version = "X.Y.Z"` caret requirements in `[workspace.dependencies]` (never exact `=X.Y.Z` pins on stable releases), and raise external library dependency floors in `[workspace.dependencies]` only when Logforth requires a newly added upstream API or bug fix. +- **Explicit authorization for irreversible steps**: Preparing branches, running checks, and drafting pull requests are safe, whereas `cargo publish` and pushing Git tags are irreversible and require explicit maintainer authorization. + +## 1. Scope the Release and Choose Target Versions + +Sync `origin/main` and existing tags before inspecting diffs: + +```shell +git fetch origin main --tags +git status --short --branch +``` + +Compare each publishable crate against its own latest `-v` tag (`git log -v..origin/main -- `) alongside `## Unreleased` in `CHANGELOG.md`, then propagate versions up the DAG using pre-`1.0` SemVer (`0.x` minor for breaking changes, patch for compatible features or fixes) and Rust [RFC 1105](https://rust-lang.github.io/rfcs/1105-api-evolution.html) public-dependency rules: + +| Tier | Crates | Versioning and Propagation Rule | +| :----------------------- | :-------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1. Standalone libraries | `logforth-logfmt`, `logforth-syslog` | Independent `0.x` tracks with no `logforth-core` dependency. A breaking `0.x` bump in `logforth-logfmt` (private dependency of `logforth-layout-logfmt`) requires only a patch bump in `logforth-layout-logfmt`, whereas a breaking `0.x` bump in `logforth-syslog` (publicly re-exported by `logforth-append-syslog`) propagates breaking `0.x` bumps to `logforth-append-syslog` and `logforth`. | +| 2. Core | `logforth-core` | Compatible fixes or additions bump patch (`0.5.x`). A breaking `0.x` bump propagates breaking bumps across all 14 peripheral crates and `logforth`. | +| 3. Peripheral extensions | `appenders/*`, `layouts/*`, `filters/*`, `diagnostics/*`, `bridges/*` | Independent `0.x` tracks. A breaking `0.x` bump in any peripheral crate requires a breaking `0.x` minor bump in `logforth` (which publicly re-exports it behind a feature flag) while leaving `logforth-core` and unaffected peripheral crates untouched. | +| 4. Umbrella facade | `logforth` | Bumps `0.x` minor on facade API breaks, MSRV increases, or breaking updates to any re-exported crate; bumps patch on compatible facade changes or when raising `[workspace.dependencies]` floors for underlying fixes and additions so each release train has a canonical `## vX.Y.Z` changelog anchor (unless releasing a standalone `libs/*` crate out-of-band). | + +For every crate receiving a patch bump (or left unbumped despite source changes), verify SemVer compatibility against the published crates.io baseline: + +```shell +cargo semver-checks check-release --package +``` + +## 2. Prepare the Release Pull Request + +Create a single release-preparation branch and pull request (`chore: prepare for releasing `) updating: + +1. **Manifests and lockfile**: Update `version` in each bumped `/Cargo.toml` and the matching `version` entries under `[workspace.dependencies]` in root `Cargo.toml` (leaving unchanged crates at their existing versions), then refresh `Cargo.lock` with `cargo check --workspace --all-targets --all-features`. +2. **Versioned `docs.rs` links and badges**: Update hardcoded `https://docs.rs///...` URLs (and the MSRV badge in `README.md` if `rust-version` changed) for every crate whose version changed: + - Root `README.md` (`logforth` links when `logforth` bumps, plus component reference links at the bottom of `README.md` for bumped crates). + - `bridges/log/src/lib.rs` (`https://docs.rs/logforth//...` rustdoc links when `logforth` bumps). + - Affected `/README.md` files (each bumped crate's own `docs.rs` links, plus cross-crate `docs.rs` links pointing at bumped crates). +3. **`CHANGELOG.md`**: Insert `## vX.Y.Z` **without a date** immediately below `## Unreleased` (keeping `## Unreleased` empty at the top), add the aligned 18-crate version matrix table recording the snapshot version of every publishable crate, and finalize user-visible entries against each crate's latest release tag per `AGENTS.md`. + +Run the full repository validation suite locally before opening or updating the pull request: + +```shell +cargo x lint +cargo x check +cargo x test +``` + +Wait for required CI checks (`stable`, `nightly`, and MSRV across Linux, macOS, and Windows) to pass and merge the pull request into `main` once authorized. + +## 3. Verify the Frozen `RELEASE_COMMIT` + +Record the merged commit SHA on `origin/main` as `RELEASE_COMMIT` and inspect it from a clean detached worktree outside the repository: + +```shell +RELEASE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/logforth-release.XXXXXX")" +git fetch origin main --tags +git worktree add --detach "${RELEASE_DIR}/checkout" "${RELEASE_COMMIT}" +cd "${RELEASE_DIR}/checkout" +test -z "$(git status --porcelain)" +``` + +Verify the frozen snapshot end-to-end (substituting the workspace `rust-version` from root `Cargo.toml` for ``): + +```shell +cargo x lint +cargo x check +cargo x test +RUSTUP_TOOLCHAIN= cargo x check +RUSTUP_TOOLCHAIN= cargo x test +``` + +For each crate scheduled for publication, inspect its packaged file manifest to confirm `LICENSE`, `README.md`, and expected source files are present with no stray files: + +```shell +cargo package --list --locked --package +``` + +When a release bumps only leaf crates whose workspace dependencies are already published on crates.io, also run `cargo publish --dry-run --locked --package `. When both an upstream workspace crate (such as `logforth-core`) and a downstream crate (such as `logforth`) bump in the same release, live-registry `--dry-run` on the downstream crate cannot resolve the unpublished upstream version until the upstream tier is uploaded; run `--dry-run` per tier right after its upstream tier finishes publishing (or validate against a local static registry index). + +If any check fails, land the fix through a new reviewed pull request on `main` and advance `RELEASE_COMMIT` before publishing or tagging. + +## 4. Publish Updated Crates in Topological Order + +Once authorized to publish, upload **only** crates whose `(name, version)` in `Cargo.toml` is not yet published on crates.io, proceeding strictly tier by tier from the detached `RELEASE_COMMIT` checkout: + +1. **Tier 1 (Standalone libraries)**: `logforth-logfmt`, `logforth-syslog` +2. **Tier 2 (Core)**: `logforth-core` +3. **Tier 3 (Peripheral extensions)**: `logforth-append-async`, `logforth-append-fastrace`, `logforth-append-file`, `logforth-append-journald`, `logforth-append-opentelemetry`, `logforth-append-syslog`, `logforth-bridge-log`, `logforth-diagnostic-fastrace`, `logforth-diagnostic-task-local`, `logforth-filter-rustlog`, `logforth-layout-google-cloud-logging`, `logforth-layout-json`, `logforth-layout-logfmt`, `logforth-layout-text` +4. **Tier 4 (Umbrella facade)**: `logforth` + +For each crate in tier order, check crates.io before publishing so reruns after rate limits or transient network errors remain idempotent: + +```shell +if cargo info "@" --registry crates-io >/dev/null 2>&1; then + printf 'skipping %s@%s (already published)\n' "" "" +else + cargo publish --locked --package "" +fi +``` + +## 5. Tag Published Crates and Record the Release Date + +Create GPG-signed annotated Git tags on `RELEASE_COMMIT` **strictly for the crates published in this release**, matching the `-v` naming and message format in `[workspace.metadata.release]`: + +```shell +test "$(git rev-parse HEAD)" = "${RELEASE_COMMIT}" +git tag --sign "-v" --message "chore: Release version " "${RELEASE_COMMIT}" +git verify-tag "-v" +``` + +Never re-tag or move tags for crates whose versions did not change in this release; each crate's latest `-v` tag must continue pointing to the commit that shipped that version. + +After verifying every new tag signature and target commit (`test "$(git rev-parse "^{commit}")" = "${RELEASE_COMMIT}"`), push the new tags to `origin`: + +```shell +git push origin ... +``` + +Confirm crates.io availability (`cargo info @ --registry crates-io`) and docs.rs builds for the published crates, remove the temporary detached worktree (`git worktree remove "${RELEASE_DIR}/checkout" && rm -rf "${RELEASE_DIR}"`), and open a follow-up pull request adding the actual UTC publication date (`## vX.Y.Z (YYYY-MM-DD)`) to `CHANGELOG.md`. diff --git a/AGENTS.md b/AGENTS.md index 215071da..fb445214 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,6 +36,8 @@ cargo x lint --fix # Automatically apply clippy, rustfmt, taplo, and haw Use the shared [deslopify skill](.agents/skills/deslopify/SKILL.md) to survey Logforth for simplifications or implement findings a maintainer has selected. During ordinary feature, refactor, and test work, apply a single self-cleanup pass before committing so defensive glue, premature helpers, restating comments, and literal-mirroring tests never enter commit history. +Use the shared [release skill](.agents/skills/release/SKILL.md) to prepare, verify, publish, and tag partial or workspace-wide crate releases. + ## Rust Style - **Modules and imports**: Order module headers as `//!` docs, `use` imports (`group_imports = "StdExternalCrate"`, `imports_granularity = "Item"`), out-of-line `mod` declarations, and items. Use `/mod.rs` for multi-file modules, and do not split cohesive files prematurely. Group `mod` declarations with blank lines between `pub mod`, private `mod` with immediate `pub use self::...;` re-exports, and implementation-only private `mod` (`#[cfg(test)]` last), sorted alphabetically within each group; re-export subsystem interfaces from `mod.rs` and attach `#[cfg]` gates at module boundaries when possible. Place shared `use` imports at the top of the enclosing module, while keeping a `use` local to a function, block, or `match` arm when scoping avoids trait method ambiguity, isolates heavy helper-only namespaces, or keeps imports inside a `#[cfg(...)]` or `#[test]` item without `#[cfg]`-gating header imports or adding artificial test modules. Never spell `crate::...`, `super::...`, or `self::...` inline in expressions or type signatures: import intra-crate items via `use crate::...`, avoid `use super::...` and private `use self::...`, and reserve `use super::*;` for `#[cfg(test)]` and colocated benchmark modules. Inline `std::...`, `core::...`, or `::...` paths are welcome whenever simpler (one-off calls, avoiding `#[cfg]`-gated imports, or disambiguating collisions such as `core::error::Error` or `jiff::Timestamp` vs. `proto::Timestamp`). Preserve original names with meaningful module or crate qualification (`io::Error`, `fs::read`, `process::Command`, `atomic::Ordering`), and avoid `use ... as ...` aliases except `use ...::Trait as _;`.