#11

feat: publish stable releases to crates.io

MergedxlabMembermerged intofrom

Summary

  • publish stable trylle-cli releases to crates.io after package builds complete
  • retrieve the crates.io token from Phase and use the protected crates environment
  • skip crates.io publishing for prerelease tags

Validation

  • cargo test --locked --test release_metadata
  • cargo package --locked

Activity

4
trylle-botreviewed4mo ago
trylle-bot4mo ago

What changed

.github/workflows/publish-packages.yaml (+54/-0, single file) adds a publish-crates job that runs cargo publish --locked for trylle-cli after prepare and publishing-ready complete. It's gated on a new publish_crates job output computed in prepare, pulls CRATES_CI_PUBLISHER from Phase (/publishing path) via docker run phasehq/cli, and runs under the protected crates GitHub Environment.

Risk areas

  1. Stable/prerelease gate is an indirect proxy. publish_crates is derived from if [[ "$npm_version" == "$manifest_version" ]] rather than testing the tag/version string for a prerelease marker directly. The PR description frames this as "skip crates.io publishing for prerelease tags," but the equality check only captures that intent if npm_version and manifest_version are guaranteed to diverge exactly when (and only when) the release is a prerelease. Since a crates.io publish can't be undone (only yanked, which doesn't remove the version), it's worth confirming this equality holds for all the tag shapes this pipeline can produce, not just the common case.

  2. eval "$phase_values" on docker-sourced output. The new "Publish source package" step captures phasehq/cli secrets export ... stdout and evals it verbatim to populate CRATES_CI_PUBLISHER. If the Phase CLI's export format changes, or the secret value contains characters the shell reparses (quotes, $(...), backticks), eval either fails loudly or executes unintended shell content. Low likelihood given Phase is an internal trusted store, but this is the one place in the diff where secrets-manager output is fed straight into eval to gate a real, irreversible publish.

  3. PHASE_HOST / PHASE_ENV aren't in this job's own env: block. Only PHASE_APP_ID and PHASE_SERVICE_TOKEN are set as step env vars, but the docker run --env PHASE_HOST ... and --env "$PHASE_ENV" in the same step reference both. They must be coming from a workflow- or job-level env: defined elsewhere in the file (not visible in this diff). Worth a quick confirm that publish-crates actually inherits them — an empty PHASE_ENV/unset PHASE_HOST would either fail the job or point phasehq/cli at the wrong Phase environment.

  4. needs: [prepare, publishing-ready] doesn't list the build/package jobs directly. The PR description says this should publish "after package builds complete." That's presumably satisfied transitively if publishing-ready itself depends on the relevant build jobs, but that dependency isn't part of this diff, so it can't be verified here — worth confirming publishing-ready actually gates on the binary/package build before this can be trusted to run in the right order.

Suggested follow-ups

  • Add a short comment next to the npm_version == manifest_version check explaining why that equality implies "stable, not prerelease" — the intent isn't obvious from the code alone.
  • Consider a cargo publish --locked --dry-run (or similar) step before the real publish, given there's no way to walk back a bad one.
  • Confirm the crates environment has required-reviewer protection configured in repo settings — that's the actual safety net if publish_crates ever evaluates incorrectly, and it isn't visible in this diff.

Overall the guardrails here (protected environment, scoped token retrieval, explicit prerelease skip) show the right instincts for a one-way action like this. The points above are things I'd want confirmed before this runs against the real registry, not necessarily blockers.

xlab merged commit 3dff418 into master3mo ago

Branch feat/publishing-crates has been merged.

Checking branch