# astral-sh/cargo-dist architecture

> Architecture diagram of the GitHub repository astral-sh/cargo-dist, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/astral-sh/cargo-dist
- Repository: https://github.com/astral-sh/cargo-dist

## Overview

1. `cargo-dist` is a Rust workspace centered on a release-distribution toolchain for binaries. The top-level crate is a CLI/library that inspects a repo, plans releases, generates CI, and emits packaging/install artifacts.

2. The architecture is split into three main crates:
   - `cargo-dist`: the core product logic and CLI.
   - `cargo-dist-schema`: a schema/serialization crate for the machine-readable manifest format.
   - `axoproject`: a helper crate for repository/project introspection, especially Rust and JS project metadata and changelog/repo utilities.

3. The primary runtime flow is: user runs `dist init` or `dist` commands → the tool reads workspace config and project layout → it computes a release/build plan → it generates CI/workflow files, manifests, installers, and release metadata. The README’s “Plan, Build, Host, Publish, Announce” split is the clearest boundary in the system.

4. Configuration is versioned and centralized under `cargo-dist/src/config`. There are v0 and v1 formats, plus migration code from v0 to v1. Within v1, config is decomposed by concern: builds, artifacts, CI, hosts, installers, and publishers. This strongly suggests the tool treats configuration as the source of truth for the generated pipeline.

5. Build planning is implemented in `cargo-dist/src/build`, with separate paths for Cargo-based builds and generic builds. That boundary matters: Cargo workspaces are first-class, but the tool also supports non-Rust or manually built projects by switching to generic build definitions.

6. CI generation is a backend concern under `cargo-dist/src/backend/ci`, with GitHub Actions being the concrete provider. The backend layer is also responsible for composing templates for release workflows and publish jobs, so CI generation is not hand-authored but synthesized from the computed plan.

7. Installer generation is another backend boundary under `cargo-dist/src/backend/installer` and corresponding templates. The repo supports multiple installer types, including Homebrew, MSI, npm, PowerShell, shell scripts, and macpkg. These installers are generated artifacts rather than separate maintained projects.

8. The tool also models hosting, publishing, signing, and announcement as distinct subsystems:
   - `host.rs` and `config/v1/hosts` for release hosting destinations.
   - `publishers/*` for package-manager publication.
   - `sign/*` for signing workflows on macOS and Windows/SSL.com.
   - `announce.rs` for release-note and release-announcement generation.

9. `manifest.rs`, `cargo-dist-schema`, and `tests/snapshots` indicate a strong machine-readable contract. The generated manifest is a key integration point: it captures release inputs/outputs so other tools and the generated CI jobs can consume the same plan consistently.

10. `cargo-dist/src/platform` and `cargo-dist/src/linkage.rs` show that platform targeting and binary compatibility are treated explicitly. This suggests the build planner reasons about target triples, runners, and platform-specific packaging, not just “build once, ship everywhere.”

11. `cargo-dist/src/init.rs` and the `templates/` directory are the bootstrap path. They generate repo-local files such as workflow YAML, installer assets, and npm wrapper files, which means the tool is both an analyzer and a scaffold generator.

12. The `book/` directory is a substantial documentation subsystem, not just ancillary docs. It documents architecture-relevant concepts such as artifacts, installers, CI, workspaces, and supply-chain security, reinforcing that the repo’s outputs are meant to be understood as a generated release system.

13. Testing is heavily fixture- and snapshot-driven. The `cargo-dist/tests/gallery` and `cargo-dist/tests/snapshots` directories validate rendered outputs against many example projects: Rust crates, Cargo workspaces, generic C projects, npm apps, and workspace variants. This indicates the core risk area is output correctness, not long-running services.

14. The sample projects under `axoproject/tests/projects` and `cargo-dist/tests/gallery/dist` form the architecture’s integration boundary with real repositories. They exercise discovery of workspace structure, changelogs, licenses, package metadata, and build layouts across multiple ecosystems.

15. Operationally, the repo is self-hosting and CI-driven. GitHub Actions workflows in `.github/workflows` handle CI, publishing crates, and releases, while the README notes releases are produced by tagging and pushing, with cargo-release helping maintain versioning and changelog hygiene.

16. For an architecture diagram, the most important nodes are: user/CLI input, repo introspection/config parsing, release planning, schema/manifest emission, build artifact generation, CI template generation, installer/publisher/signing backends, and the test/docs surfaces that validate and explain those outputs.

Main entry points: [`cargo-dist/src/backend/mod.rs`](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/backend/mod.rs) (Backend), [`axoproject/src/lib.rs`](https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/lib.rs) (Repo introspection), [`cargo-dist/src/build/mod.rs`](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/build/mod.rs) (Planner), [`cargo-dist/src/config/mod.rs`](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/config/mod.rs) (Config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_core["cargo-dist"]
  node_cargo_dist_cli["CLI<br/>command entry<br/>[cli.rs]"]
  node_cargo_dist_init["Init<br/>bootstrap<br/>[init.rs]"]
  node_cargo_dist_config["Config<br/>[mod.rs]"]
  node_cargo_dist_build["Planner<br/>release planning<br/>[mod.rs]"]
  node_cargo_dist_manifest["Manifest<br/>output contract<br/>[manifest.rs]"]
  node_cargo_dist_backend["Backend<br/>[mod.rs]"]
  node_cargo_dist_ci["CI<br/>workflow backend<br/>[mod.rs]"]
  node_cargo_dist_installer["Installers<br/>artifact backend<br/>[mod.rs]"]
  node_cargo_dist_publishers["Publishers<br/>publish backend<br/>[mod.rs]"]
  node_cargo_dist_sign["Signing<br/>security backend<br/>[mod.rs]"]
  node_cargo_dist_host["Hosts<br/>release host<br/>[host.rs]"]
  node_cargo_dist_platform["Platform<br/>target model"]
  node_cargo_dist_announce["Announce<br/>release notes<br/>[announce.rs]"]
end

subgraph group_grp_schema["Schema"]
  node_cargo_dist_schema["Schema crate<br/>schema library<br/>[lib.rs]"]
end

subgraph group_grp_helper["axoproject"]
  node_axoproject["Repo introspection<br/>helper library<br/>[lib.rs]"]
  node_axoproject_rust["Rust<br/>workspace detector<br/>[rust.rs]"]
  node_axoproject_js["JavaScript<br/>package detector<br/>[javascript.rs]"]
  node_axoproject_repo["Repo utils<br/>repo helpers<br/>[repo.rs]"]
end

subgraph group_grp_validation["Validation"]
  node_book["Book<br/>documentation<br/>[index.md]"]
  node_tests["Snapshots<br/>integration tests<br/>[manifest.snap]"]
end

node_cargo_dist_cli -->|"loads"| node_cargo_dist_config
node_cargo_dist_cli -->|"inspects"| node_axoproject
node_cargo_dist_cli -->|"boots"| node_cargo_dist_init
node_cargo_dist_cli -->|"plans"| node_cargo_dist_build
node_cargo_dist_init -->|"scaffolds"| node_cargo_dist_backend
node_cargo_dist_config -->|"drives"| node_cargo_dist_build
node_cargo_dist_config -->|"parameterizes"| node_cargo_dist_backend
node_cargo_dist_build -->|"emits"| node_cargo_dist_manifest
node_cargo_dist_build -->|"feeds"| node_cargo_dist_backend
node_cargo_dist_build -->|"targets"| node_cargo_dist_platform
node_cargo_dist_backend -->|"generates"| node_cargo_dist_ci
node_cargo_dist_backend -->|"generates"| node_cargo_dist_installer
node_cargo_dist_backend -->|"coordinates"| node_cargo_dist_publishers
node_cargo_dist_backend -->|"coordinates"| node_cargo_dist_sign
node_cargo_dist_backend -->|"uploads to"| node_cargo_dist_host
node_cargo_dist_backend -->|"produces"| node_cargo_dist_announce
node_cargo_dist_schema -->|"defines"| node_cargo_dist_manifest
node_axoproject -->|"detects"| node_axoproject_rust
node_axoproject -->|"detects"| node_axoproject_js
node_axoproject -->|"supports"| node_axoproject_repo
node_axoproject -->|"supplies inputs"| node_cargo_dist_config
node_book -.->|"documents"| node_cargo_dist_ci
node_book -.->|"documents"| node_cargo_dist_installer
node_book -.->|"documents"| node_cargo_dist_config
node_tests -.->|"validates"| node_cargo_dist_build
node_tests -.->|"validates"| node_cargo_dist_backend
node_tests -.->|"exercises"| node_axoproject
node_tests -.->|"validates"| node_cargo_dist_manifest

click node_cargo_dist_cli "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/cli.rs"
click node_cargo_dist_init "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/init.rs"
click node_cargo_dist_config "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/config/mod.rs"
click node_cargo_dist_build "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/build/mod.rs"
click node_cargo_dist_manifest "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/manifest.rs"
click node_cargo_dist_backend "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/backend/mod.rs"
click node_cargo_dist_ci "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/backend/ci/mod.rs"
click node_cargo_dist_installer "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/backend/installer/mod.rs"
click node_cargo_dist_publishers "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/config/v1/publishers/mod.rs"
click node_cargo_dist_sign "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/sign/mod.rs"
click node_cargo_dist_host "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/host.rs"
click node_cargo_dist_platform "https://github.com/astral-sh/cargo-dist/tree/main/cargo-dist/src/platform"
click node_cargo_dist_announce "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/announce.rs"
click node_cargo_dist_schema "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist-schema/src/lib.rs"
click node_axoproject "https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/lib.rs"
click node_axoproject_rust "https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/rust.rs"
click node_axoproject_js "https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/javascript.rs"
click node_axoproject_repo "https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/repo.rs"
click node_book "https://github.com/astral-sh/cargo-dist/blob/main/book/src/reference/index.md"
click node_tests "https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/tests/snapshots/manifest.snap"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cargo_dist_cli,node_cargo_dist_init,node_cargo_dist_config,node_cargo_dist_build,node_cargo_dist_manifest,node_cargo_dist_backend,node_cargo_dist_ci,node_cargo_dist_installer,node_cargo_dist_publishers,node_cargo_dist_sign,node_cargo_dist_host,node_cargo_dist_platform,node_cargo_dist_announce toneBlue
class node_cargo_dist_schema toneAmber
class node_axoproject,node_axoproject_rust,node_axoproject_js,node_axoproject_repo toneMint
class node_book,node_tests toneRose
```

## Components

### cargo-dist

Main release-distribution CLI and orchestration crate.

- [CLI](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/cli.rs): command entry · User-facing dist commands and startup flow. · `cargo-dist/src/cli.rs`
- [Init](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/init.rs): bootstrap · Scaffolds repo-local dist files and templates. · `cargo-dist/src/init.rs`
- [Config](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/config/mod.rs): versioned config · Central config model and v0/v1 migration boundary. · `cargo-dist/src/config/mod.rs`
- [Planner](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/build/mod.rs): release planning · Computes build and release plans from repo layout and config. · `cargo-dist/src/build/mod.rs`
- [Manifest](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/manifest.rs): output contract · Emits the machine-readable release manifest consumed by CI and tools. · `cargo-dist/src/manifest.rs`
- [Backend](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/backend/mod.rs): generation backend · Synthesizes workflows, installers, and publish jobs from the plan. · `cargo-dist/src/backend/mod.rs`
- [CI](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/backend/ci/mod.rs): workflow backend · Generates GitHub Actions release and publish workflows. · `cargo-dist/src/backend/ci/mod.rs`
- [Installers](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/backend/installer/mod.rs): artifact backend · Generates installer artifacts and wrapper assets. · `cargo-dist/src/backend/installer/mod.rs`
- [Publishers](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/config/v1/publishers/mod.rs): publish backend · Models package-manager publication targets and steps. · `cargo-dist/src/config/v1/publishers/mod.rs`
- [Signing](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/sign/mod.rs): security backend · Handles macOS and Windows/SSL.com signing workflows. · `cargo-dist/src/sign/mod.rs`
- [Hosts](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/host.rs): release host · Represents release hosting destinations and upload targets. · `cargo-dist/src/host.rs`
- [Platform](https://github.com/astral-sh/cargo-dist/tree/main/cargo-dist/src/platform): target model · Encodes target triples, runners, and platform-specific packaging. · `cargo-dist/src/platform`
- [Announce](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/src/announce.rs): release notes · Builds release-note and announcement payloads. · `cargo-dist/src/announce.rs`

### Schema

Machine-readable manifest contract.

- [Schema crate](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist-schema/src/lib.rs): schema library · Shared serialization schema for generated manifest data. · `cargo-dist-schema/src/lib.rs`

### axoproject

Repository and project introspection helpers.

- [Repo introspection](https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/lib.rs): helper library · Detects repo structure, metadata, and changelog information. · `axoproject/src/lib.rs`
- [Rust](https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/rust.rs): workspace detector · Inspects Cargo workspaces and crate metadata. · `axoproject/src/rust.rs`
- [JavaScript](https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/javascript.rs): package detector · Inspects npm and JS project metadata. · `axoproject/src/javascript.rs`
- [Repo utils](https://github.com/astral-sh/cargo-dist/blob/main/axoproject/src/repo.rs): repo helpers · Local repository, generic project, and changelog utilities. · `axoproject/src/repo.rs`

### Validation

Docs, fixtures, and snapshots that validate generated outputs.

- [Book](https://github.com/astral-sh/cargo-dist/blob/main/book/src/reference/index.md): documentation · Architecture and usage documentation for generated release systems. · `book/src/reference/index.md`
- [Snapshots](https://github.com/astral-sh/cargo-dist/blob/main/cargo-dist/tests/snapshots/manifest.snap): integration tests · Fixture-driven output verification across sample projects. · `cargo-dist/tests/snapshots/manifest.snap`

## Connections

- CLI → Config: loads · Reads versioned config and command settings.
- CLI → Repo introspection: inspects · Discovers repository shape and metadata.
- CLI → Init: boots · Initializes dist files and templates.
- CLI → Planner: plans · Produces the release/build plan.
- Init → Backend: scaffolds · Writes generated workflow and installer files.
- Config → Planner: drives · Config is the source of truth for planning.
- Config → Backend: parameterizes · Backend generation follows config-derived plan data.
- Planner → Manifest: emits · Serializes the planned release graph.
- Planner → Backend: feeds · Provides inputs for workflow and artifact generation.
- Planner → Platform: targets · Resolves platform and runner-specific decisions.
- Backend → CI: generates · Synthesizes CI workflows and publish jobs.
- Backend → Installers: generates · Synthesizes installer outputs and wrapper assets.
- Backend → Publishers: coordinates · Composes publish steps for package registries.
- Backend → Signing: coordinates · Adds signing steps where required.
- Backend → Hosts: uploads to · Uses hosting destinations for release assets.
- Backend → Announce: produces · Creates release announcement content.
- Schema crate → Manifest: defines · Shared schema underpins the emitted manifest.
- Repo introspection → Rust: detects · Rust workspace and crate discovery.
- Repo introspection → JavaScript: detects · JavaScript package discovery.
- Repo introspection → Repo utils: supports · Generic repo and changelog helpers.
- Repo introspection → Config: supplies inputs · Feeds project metadata into config and planning.
- Book → CI: documents · Explains CI generation concepts and customization.
- Book → Installers: documents · Explains installer families and usage.
- Book → Config: documents · Documents config and concepts.
- Snapshots → Planner: validates · Checks release planning against fixtures and snapshots.
- Snapshots → Backend: validates · Checks rendered workflows and installers.
- Snapshots → Repo introspection: exercises · Runs against sample projects across ecosystems.
- Snapshots → Manifest: validates · Ensures manifest output stays stable.
