Publish a Package
Build a small library from scratch — palette, a color type that parses and formats hex colors — then publish it to the registry so anyone can depend on it. Along the way you'll pick up the things that make a package good to use: a tight public API, doc comments, and semantic versioning.
Before you start
You should have installed Kestrel, worked through a tour, and built something with Flock (flock build/run). This guide assumes you're comfortable with structs, match, and Optional. To publish, you'll also need a GitHub account — that's how the registry signs you in.
What you'll build
A tiny library, palette, with one public type:
let blue = Color(red: 58, green: 123, blue: 213);
blue.toHex(); // "#3a7bd5"
match Color(hex: "#3a7bd5") {
.Some(c) => c.red, // 58
.None => 0
}
By the end it's published as your-name/palette and a second project depends on it.
Pages
- Build the Library — write
palette: aColortype with hex parsing and formatting, documented as you go. - Publish Your Package — sign in, get a token, set your org, and
flock publish. - Depend on It — pull
paletteinto another project and use it. - Ship a New Version — add a feature, release
0.2.0, and how semver flows to dependents. - Organizations & Teams (optional) — publish under a shared org with members and roles.
- Publishing from CI (optional) — automate releases from a tag with
FLOCK_TOKEN. - Reference — manifest fields, env vars, commands, and troubleshooting.
Pages 1–4 are the complete first-publish path; each one leaves you with something that works.