Build and publish a packageThe short path from a recipe or a pixi package to a published artifact on prefix.dev, with rattler-build or pixi publish, plus how conda-forge and recipe collections fit in.
This page is the short path from a recipe to a published package on prefix.dev. The complete references live at rattler.build and pixi.sh; everything below is the subset you need to get a package into a channel.
Publishing is two operations: build an artifact from a manifest, then upload it to a channel. rattler-build gives you one command for each. pixi publish does both in a single step. Which you reach for depends on which manifest describes your package — a recipe.yaml or a pixi.toml with a [package] section. Both are shown below.
If you already have a built .conda file and only need the upload half, see Publish packages.
Prerequisites
The Owner or Contributor role on a channel — see Create and configure a channel.
Either
pixiorrattler-buildinstalled. Both read the same credential store, so one login covers both.
pixi auth login prefix.dev
# or, equivalently
rattler-build auth login prefix.dev --oauth
A recipe: recipe.yaml
A recipe is a single recipe.yaml and needs no surrounding project. This one builds zoxide, a Rust command-line tool, and is taken verbatim from the rust-forge collection:
context:
version: "0.9.4"
package:
name: zoxide
version: ${{ version }}
source:
url: https://github.com/ajeetdsouza/zoxide/archive/refs/tags/v${{ version }}.tar.gz
sha256: ec002bdca37917130ae34e733eb29d4baa03b130c4b11456d630a01a938e0187
build:
script: cargo install --locked --root ${{ PREFIX }} --path . --no-track
requirements:
build:
- ${{ compiler("rust") }}
tests:
- script:
- zoxide --help
The parts that carry the weight:
contextholds values you reuse. The version is written once and referenced as${{ version }}, so a bump is a one-line change.source.urlplussha256pin the exact upstream tarball. The build fails rather than silently using different sources if upstream retags a release.build.scriptis the actual build. Whatever it installs into${{ PREFIX }}becomes the package.requirements.buildpulls in the toolchain.${{ compiler("rust") }}expands to the right compiler package for the platform you are building for.testsrun against the finished package in a fresh environment. This is the cheapest way to catch a broken build before it reaches a channel, where filenames are effectively permanent.
Build, then upload, with rattler-build
Two commands, one per operation. First build:
rattler-build build --recipe recipe.yaml -c conda-forge
Artifacts land in output/<subdir>/. Then upload, using the channel's canonical reference — <namespace> or <namespace>/<channel>, never the @ form that appears in website URLs:
rattler-build upload prefix -c rust-forge output/osx-arm64/zoxide-0.9.4-*.conda
Two flags are worth knowing early: --skip-existing makes a repeated upload a no-op instead of an error, and --generate-attestation produces a sigstore attestation alongside the package.
A pixi package: pixi.toml
pixi publish builds from a pixi workspace rather than from a bare recipe, so the package is described by a [package] section in pixi.toml. A complete minimal example for a Python package:
[workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["osx-arm64", "linux-64"]
preview = ["pixi-build"]
[package]
name = "greeter"
version = "0.1.0"
publish = true
[package.build]
backend = { name = "pixi-build-python", version = "*" }
[package.host-dependencies]
python = ">=3.11"
hatchling = "*"
[package.run-dependencies]
python = ">=3.11"
Three things to note:
preview = ["pixi-build"]is required. Without it pixi rejects the manifest outright with[package] section is only allowed when the `pixi-build` feature is enabled.publish = trueis the opt-in.pixi publishbuilds every package in the workspace that sets it and leaves the rest out of the publish set.[package.build].backendselects how the package is built. Alongsidepixi-build-pythonthere arepixi-build-cmake,pixi-build-rust,pixi-build-ros, andpixi-build-rattler-buildfor driving an existing recipe.
Build and upload in one step with pixi publish
pixi publish is build plus upload in a single command. It builds every opted-in package in the workspace — in dependency order, so packages that depend on other workspace packages build after them — and uploads the artifacts:
pixi publish --to https://prefix.dev/<namespace>/<channel>
Check the plan before you build anything. --dry-run resolves the publish set and prints it, without building or uploading:
$ pixi publish --dry-run --to https://prefix.dev/acme/research
📋 Would build 1 package(s):
- greeter v0.1.0 [pyh4616a5c_0] (noarch)
ℹ️ Dry run: nothing was built or uploaded
The variations you will reach for:
--path <manifest>builds and publishes a single package, whether or not it setspublish = true.--target-platformand--variant python=3.12control what gets built.--target-dir <dir>copies the artifacts into a local directory instead of uploading them — the build half without the upload half.
The two manifest styles are not mutually exclusive. --path also accepts a recipe.yaml, provided the enclosing directory is a pixi workspace with the pixi-build preview enabled. So a recipe collection with a pixi.toml at its root can be published either way:
pixi publish --path zoxide/recipe.yaml --to https://prefix.dev/rust-forge
And for a file you built some other way, pixi upload prefix --channel <channel> <file> is the upload half on its own — the direct equivalent of the rattler-build upload above.
Publish from CI
In CI, prefer trusted publishing over a long-lived API key: the job exchanges a short-lived OIDC identity for upload rights, so there is no secret to store, leak, or rotate. Grant the workflow id-token: write and the uploader needs no credential configuration at all. Condensed from rust-forge's workflow:
# this is important for trusted publishing
permissions:
id-token: write
jobs:
build:
strategy:
matrix:
include:
- { target: linux-64, os: ubuntu-latest }
- { target: win-64, os: windows-latest }
- { target: osx-64, os: macos-13 }
- { target: osx-arm64, os: macos-14 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/setup-pixi@v0.8.1
- name: Build
run: |
rattler-build build --recipe-dir . \
--skip-existing=all --target-platform=${{ matrix.target }} \
-c conda-forge -c https://prefix.dev/rust-forge
- name: Upload
if: github.event_name == 'push' # never publish from a PR
run: |
for file in output/**/*.conda; do
rattler-build upload prefix -c rust-forge "$file"
done
Note the if: guard on the upload step. Pull requests should build and test, but only a push to the default branch should publish.
Prior art: conda-forge and your own channel
Your own channel is not the only place a package can live, and for open-source work it is often not the best one.
conda-forge is the community channel that most conda users already have configured. Each package gets its own feedstock repository with generated CI, new packages enter through staged-recipes, and bots handle version bumps and ecosystem-wide dependency migrations. If a package is broadly useful and open source, this gives it the widest reach at no cost — in exchange for review turnaround and conda-forge's policies.
A prefix.dev channel is the right home for internal or proprietary packages, for anything that does not fit conda-forge's policies, for iterating without waiting on review, and for custom variants — different compilers, CUDA versions, or optimization levels — that upstream would not carry.
The two are not exclusive. A common arrangement is to depend on conda-forge for the ecosystem and publish only your own packages to your own channel, which is exactly what the -c conda-forge -c https://prefix.dev/<channel> pairing above expresses.
Recipe collections
Once you maintain more than two or three packages, keep the recipes together in one repository rather than one repository per package. rust-forge is a small, complete example of the pattern: eighteen Rust command-line tools, one directory each.
rust-forge/
├── pixi.toml
├── .github/workflows/build.yml
├── watchexec/recipe.yaml
├── yazi/recipe.yaml
├── zoxide/recipe.yaml
└── ...
That flat layout is all rattler-build needs. --recipe-dir . walks the directory and builds every recipe it finds, and --skip-existing=all skips anything already present in the target channel — so a push rebuilds only what actually changed, and one platform matrix serves every package in the repository.
The shape scales a long way up: conda-forge's staged-recipes and bioconda-recipes are both single repositories holding thousands of recipes, and it works equally well for an internal repository of company packages. Shared CI, a single channel, and one obvious place to look for a recipe pay for themselves quickly.
Next steps
Publish packages — upload an existing artifact from the browser, a terminal, or CI.