Skip to main content

Crate xtask_kit

Crate xtask_kit 

Source
Expand description

§xtask-kit

Reusable building blocks for Rust xtask crates.

This crate is deliberately not a framework for defining one universal xtask CLI. Each repository should keep its own clap command tree and product-specific build flow. xtask-kit provides the small, reusable primitives that tend to be copied between repositories: repository paths, file checks, process helpers, artifact hashing, Apple signing, DMG packaging, Sparkle appcasts, and GitHub Actions outputs.

§Feature flags

FeatureDefaultPurpose
processyesxshell setup and command lookup helpers.
hashyesSHA-256 and human-readable artifact sizes.
github-actionsnoAppend values to GITHUB_OUTPUT.
latest-jsonnoUpdate simple channel-based latest.json manifests.
sparklenoGenerate and merge Sparkle RSS appcasts.
applenomacOS-only Xcode, plist, codesign, provisioning profile, and notarization helpers.
dmgnomacOS-only create-dmg wrapper. Implies apple and hash.

Apple modules are compiled on target_os = "macos" only. This keeps Linux CI and non-Apple xtask crates from accidentally depending on platform-specific APIs.

§Repository root discovery

Library crates cannot use their own env!("CARGO_MANIFEST_DIR") to discover a downstream repository. Pass the manifest directory from your repository’s xtask crate instead:

let root = xtask_kit::repo::root_from_xtask_manifest(env!("CARGO_MANIFEST_DIR"))?;

§Basic usage

use xtask_kit::{fs, hash, repo};

let root = repo::root_from_xtask_manifest(env!("CARGO_MANIFEST_DIR"))?;
let app = root.join("target/release/MyApp.app");

fs::ensure_dir(&app)?;
let sha = hash::sha256_file(root.join("dist/MyApp.dmg"))?;
println!("sha256={sha}");

§macOS signing example

#[cfg(target_os = "macos")]
fn sign_app(app: &std::path::Path) -> anyhow::Result<()> {
    let options = xtask_kit::apple::CodesignOptions::runtime("Developer ID Application", app);
    xtask_kit::apple::codesign(&options)?;
    xtask_kit::apple::verify_signature(app)
}

§DMG example

#[cfg(target_os = "macos")]
fn package(app: std::path::PathBuf, output: std::path::PathBuf) -> anyhow::Result<()> {
    let options = xtask_kit::dmg::CreateDmgOptions::new("MyApp", app, output);
    xtask_kit::dmg::create(&options)
}

§Publishing

Before publishing, run:

cargo publish --dry-run --all-features

Then publish with a crates.io token from an account that should own the crate.

Modules§

applemacOS and apple
Apple platform automation: Xcode, codesign, and provisioning profiles.
arch
CPU architecture names used by release tooling.
dmgmacOS and dmg
macOS DMG packaging helpers.
fs
Filesystem helpers for repository automation.
github_actionsgithub-actions
GitHub Actions output helpers.
hashhash
Hashing helpers for release artifacts.
latest_jsonlatest-json
Small channel-based latest.json manifests.
processprocess
Process and shell helpers.
repo
Repository root helpers for xtask crates.
sparklesparkle
Sparkle appcast generation and merge helpers.