axodotdev / axodotdev/cargo-dist
config 1.0
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 149
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 32
Description
Our config has matured enough that we now have a pretty good sense of how it should be shaped.
To be clear, if we do this:
* `cargo dist init` would automate the migration to this format
* it would all still be nestable in a Cargo.toml, so `[build]` would be `[workspace.metadata.dist.build]`
Here are some goals:
* prioritize [the dist.toml](https://opensource.axo.dev/cargo-dist/book/generic-builds.html) format, as it will become more central the more we support not-cargo
* explicit hierarchy of config
* replaces messy adhoc namespacing of config ("npm-scope" vs "tap")
* makes it natural to express "publish preleases to crates.io but not npm"
* can have further levels of inheritance (`[installers.shell]` inherits config from `[installer]`)
* emphasize the "build, host, publish" phases
Note that the following examples assume we're still reading your Cargo.toml for the values that "belong" there like package name, version, etc.
## Example: typical init
Here we have the typical minimal cargo-dist config:
* cargo-dist-version
* some targets
* github ci with plan prs
* shell and powershell installers
show example
```toml
[workspace]
cargo-dist-version = "0.11.0"
# build settings
[build]
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
# what ci to run builds on
[ci.github]
pr-run-mode = "plan"
# what installers to make
[installers.shell]
[installers.powershell]
# the above can potentially be sugarred to
# installers = ["shell", "powershell"]
# as before, but i won't use that in these examples
```
## Example: oranda
Here is a translation of oranda's fairly power-user config:
show example
```toml
[workspace]
cargo-dist-version = "0.11.0"
# build settings
[build]
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
[build.cargo]
features = ["build-with-tailwind"]
[[build.extra]]
artifacts = ["oranda-config-schema.json"]
build = ["cargo", "run", "--", "config-schema", "--output=oranda-config-schema.json"]
[[build.extra]]
artifacts = ["oranda.css"]
build = ["cargo", "run", "--", "generate-css", "--out-dir=./"]
[build.archives]
windows = ".tar.gz"
unix = ".tar.gz"
# where to host builds
[host.github]
[host.axodotdev]
# where to publish releases
[publish.homebrew]
# what ci to run builds on
[ci.github]
pr-run-mode = "plan"
# what installers to make
[installers.shell]
[installers.powershell]
[installers.npm]
scope = "@axodotdev"
[installers.homebrew]
tap = "axodotdev/homebrew-tap"
```
## Example: maximalist nightmare
Here's me just trying to show [every single config](https://opensource.axo.dev/cargo-dist/book/reference/config.html)
show example
```toml
# Sketch of the v1.0.0 dist.toml / dist-workspace.toml format
[workspace]
# usual suspects
cargo-dist-version = "1.0.0"
checksum = "sha256"
dist = true
# build settings
[build]
targets = ["x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu"]
# cargo build settings
[build.cargo]
all-features = false
default-features = true
features = ["a", "b", "c"]
precise-builds = false
msvc-crt-static = true
[build.archives]
auto-includes = true
include = ["a.txt", "b.txt"]
unix = ".tar.gz"
windows = ".zip"
# extra builds
[[build.extra]]
artifacts = ["dist-manifest-schema.json"]
build = ["cargo", "dist", "manifest-schema", "--output=dist-manifest-schema.json"]
# sysdeps
[dependencies.homebrew]
cmake = '*'
libcue = { stage = ["build", "run"] }
[dependencies.apt]
cmake = '*'
libcue-dev = { version = "2.2.1-2" }
[dependencies.chocolatey]
lftp = '*'
cmake = { version = '3.27.6', targets = ["aarch64-pc-windows-msvc"] }
# host settings
[host]
# enabling a host is done by adding its [host.xyz] entry
[host.github]
create-release = true
[host.axodotdev]
# enabling a publish is done by adding its [publish.xyz] entry
[publish]
prereleases = false
[publish.cargo]
prereleases = false
[publish.homebrew]
prereleases = false
[publish.npm]
prereleases = false
[ci]
# enabling a ci is done by adding its [ci.xyz] entry
[ci.github]
pr-run-mode = "plan"
tag-namespace = ""
allow-dirty = false
dispatch-releases = true
fail-fast = true
# custom jobs
[ci.github.jobs]
plan = []
build-local = []
build-global = []
host = []
publish = []
# add pre and post for everything?
pre-announce = []
announce = []
post-announce = []
# custom runners
[ci.github.runners]
aarch64-unknown-linux-gnu = "buildjet-8vcpu-ubuntu-2204-arm"
aarch64-unknown-linux-musl = "buildjet-8vcpu-ubuntu-2204-arm"
# enabling an installer is done by adding its [installer.xyz] entry
[installers]
install-path = "~/CARGO_HOME"
[installers.shell]
install-path = "~/CARGO_HOME"
[installers.powershell]
install-path = "~/CARGO_HOME"
[installers.homebrew]
tap = "axodotdev/homebrew-tap"
formula = ""
[installers.npm]
scope = "@axodotdev"
[installers.msi]
allow-dirty = false
```
Contributor guide
Assessment
This issue has not been assessed yet.