Skip to content

Publish a Package

A package is a git repository, and publishing it is pushing it to GitHub. There is no registry and no publish command: gh:user/repo is https://github.com/user/repo.git.

Terminal window
resonon new my-lib --lib

Write what you want to share into src/lib.non. Every top-level fn, let and class is exported; mark one private to keep it inside. /// comments are shown by resonon pkg inspect, and the file’s //! comment is the package’s description:

//! my-lib — helpers for generative rhythms.
private let lib_name = "my-lib";
/// Scale a value and round it to a whole number.
fn scaled(value, factor) {
round(value * factor)
}
/// Default tempo for performance templates.
let default_bpm = 120;
Terminal window
resonon new my-drums --kit

Put each kit in its own folder under kits/:

my-drums/
kits/
808/
bd.wav
sd.wav
hh.wav

Files named like General MIDI drums (bd, sd, hh, …) get their notes without any setup. To set notes, velocity layers or root notes yourself, add a kit.toml and move the samples into a samples/ folder next to it — every key is in kit.toml.

A package can have code and kits: resonon new my-pkg --lib --kit.

Terminal window
resonon new my-ext --native

This adds a Rust crate in native/. Installing the package builds it from source. For machines without a Rust toolchain, also commit a prebuilt binary for each platform you support:

Terminal window
resonon build --dist

Ship a Native Extension covers writing, building and publishing the extension.

Terminal window
cd my-lib
git add .
git commit -m "First version"
gh repo create my-lib --public --source=. --push

resonon new already made the git repository. Anyone can now install the package:

Terminal window
resonon install gh:yourname/my-lib

Tag a commit and push the tag:

Terminal window
git tag v1.0
git push origin v1.0

Others pin it with resonon install gh:yourname/my-lib@v1.0, or with version = "v1.0" in their resonon.toml.