Skip to content

envschema: ready to publish (README, Apache-2.0, docs.rs examples, a Laravel Rust example) - #142

Merged
ndbroadbent merged 1 commit into
mainfrom
envschema-publish-ready
Dec 3, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
envschema-publish-ready

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Makes crates/envschema and crates/envschema-derive (from #140, sc-9026) ready for crates.io. Nothing is published: both keep publish = false until the crate has run in production for a few days.

What changes

  • README for each crate. envschema's explains the conventions:

    • one prefix for the app's own settings, with framework variables kept under their names but described as external groups;
    • description, type, default, required, required_in_production and secret per setting;
    • every problem reported at once;
    • secrets masked in Debug, Summary and error messages;
    • unknown prefixed variables warned about, with the closest known name;
    • Markdown and .env.example generated and kept in step by a test.

    It also has a quick start, the attribute table, a Laravel Rust section, a Loco note, a "when to use it, and when not" section comparing it with confique, figment, envy and config-rs, and the MSRV. The derive crate's README is short and points to envschema.

  • docs.rs. envschema's crate docs are its README (#![doc = include_str!("../README.md")]), so every README example is a doc test: the derive, an env map, a custom Source (and a closure), every problem at once with secrets masked, the production check with an external group, unknown-variable warnings, and Markdown and .env.example generation. Value gained a doc test that implements it for an enum. Both crates have #![deny(missing_docs)], and every public field and builder method is now documented. No [package.metadata.docs.rs]: there are no features.

  • Laravel Rust example: an ignored block in the README that mirrors app/src/config.rs's install, check and report, cut to two groups. It isn't an examples/ file because laravel-rust as a dev-dependency would build the whole framework for cargo test -p envschema. It would also join the CI test job's feature set (--workspace --exclude visualci-app), which keeps the app's dependencies apart from the CLI's tests on purpose. app/'s own code is the compiled, tested version.

  • A plain std::env example: examples/std_env.rs (cargo run -p envschema --example std_env).

  • Cargo.toml metadata. Added rust-version = "1.88", homepage, documentation, readme, and keywords and categories for the derive crate. license (Apache-2.0) and repository come from the workspace. publish = false stays, with a comment that it flips when we publish. envschema's dependency on the derive already had version = "0.1.0" next to path.

  • LICENSE. Each crate has LICENSE, a symlink to the repository's. cargo package copies the file's contents into the .crate. This differs from snapshot-diff, which ships only the SPDX license field and no licence text. Apache-2.0 §4(a) asks redistributors to include the licence, so snapshot-diff could take the same symlink in its next release.

  • release.yml: an envschema job, inert for now. It publishes envschema-derive and then envschema through trusted publishing, once per version, like the snapshot-diff job. It skips any crate whose Cargo.toml still says publish = false, so it can't publish anything until that line goes.

Publishing, later

  1. After a few days in production, open a PR that removes publish = false from both Cargo.toml files.
  2. Before merging it, publish 0.1.0 by hand from that branch with a per-crate token. Create crates-io-envschema-token in 1Password's nathans-ai-agents vault, scoped to publish-new (and publish-update for these two crate names). Then run CARGO_REGISTRY_TOKEN=... cargo publish --locked -p envschema-derive -p envschema. Trusted publishing can only be configured for a crate that already exists.
  3. On crates.io, add a trusted publisher to each crate: DocSpring/visualci, workflow release.yml, no environment.
  4. Merge the PR. The job sees 0.1.0 on crates.io and skips it.
  5. The next version bump publishes through the job. Once that works, revoke the token (DELETE https://crates.io/api/v1/tokens/current with the token itself, or in the browser) and delete the 1Password item. The crates-token-revocation memory note tracks this pattern.

Checks (agents-build-1)

  • cargo fmt --all --check: clean.
  • cargo clippy --locked -p envschema -p envschema-derive --all-targets -- -D warnings: clean.
  • cargo test --locked -p envschema -p envschema-derive: 4 unit tests, 9 integration tests and 9 doc tests passed. The Laravel block is the 1 ignored.
  • RUSTDOCFLAGS="-D warnings" cargo doc -p envschema -p envschema-derive --no-deps: clean.
  • MSRV: cargo +1.88 check --all-targets and cargo +1.88 test passed (let-chains need 1.88).
  • examples/std_env: it stops when a required setting is missing, warns MYAPP_PROT is set, but nothing reads it (did you mean MYAPP_PORT?), and stops in production without MYAPP_POSTMARK_TOKEN.
  • Packaging.
    • cargo package --list: envschema ships Cargo.lock, Cargo.toml, LICENSE, README.md, examples/std_env.rs, src/lib.rs and tests/settings.rs. envschema-derive ships Cargo.lock, Cargo.toml, LICENSE, README.md and src/lib.rs.
    • With publish = false, cargo package -p envschema fails with "no matching package named envschema-derive". Cargo only builds its local registry overlay for an unpublished workspace dependency when the packages are publishable.
    • So on the build box's copy only, I set publish = true and ran cargo package --locked -p envschema-derive -p envschema with verification: both packaged and built from their .crate files. cargo publish --dry-run for the same two crates also passed and aborted before uploading. The packaged Cargo.toml has envschema-derive = { version = "0.1.0" } and license = "Apache-2.0".
  • actionlint on release.yml (rhysd/actionlint:1.7.7): the new job is clean. It still reports one existing SC2015 note in the build job's Package step (cp ... || true), which this PR doesn't touch.

No CLI crate changes, so no version bump.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@ndbroadbent
ndbroadbent force-pushed the envschema-publish-ready branch from faf23e9 to 5e207f4 Compare December 3, 2026 17:25
@ndbroadbent
ndbroadbent merged commit d64bb35 into main Dec 3, 2026
14 checks passed
@ndbroadbent
ndbroadbent deleted the envschema-publish-ready branch December 3, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant