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:

<!-- sample: skip --> 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

  1. Build the Library — write palette: a Color type with hex parsing and formatting, documented as you go.
  2. Publish Your Package — sign in, get a token, set your org, and flock publish.
  3. Depend on It — pull palette into another project and use it.
  4. Ship a New Version — add a feature, release 0.2.0, and how semver flows to dependents.
  5. Organizations & Teams (optional) — publish under a shared org with members and roles.
  6. Publishing from CI (optional) — automate releases from a tag with FLOCK_TOKEN.
  7. 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.