Skip to Content
Xeonr Developer Docs
Pipelines

Writing a step

Publish a composite step or a typed step for other repositories to use.

Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its .forge-ci.yaml or .xeonr-ci.yaml. See What is available.

A composite step for others

A composite step needs no build. Put it in a directory of a repository, list the directory in .branchd/packages.yaml, and tag a version.

xeonr/forge/steps: .branchd/packages.yaml
# xeonr/forge/steps: .branchd/packages.yaml
# What other repositories may use from xeonr/forge/steps. It is read at the head
# of the default branch, never at the commit being used.
packages:
  - setup-buf
  - .branchd/pipelines/deploy.yaml
xeonr/forge/steps: setup-buf/step.yaml
# xeonr/forge/steps: setup-buf/step.yaml
# Used from another repository as xeonr/forge/steps/setup-buf@v1.
name: Set up buf
description: Installs buf.
inputs:
  version: {type: string, default: '1.56.0'}
outputs:
  path: ${{ steps.install.outputs.path }}
steps:
  - id: install
    run: |
      curl -fsSLo /usr/local/bin/buf \
        "https://github.com/bufbuild/buf/releases/download/v${{ inputs.version }}/buf-$(uname -s)-$(uname -m)"
      chmod +x /usr/local/bin/buf
      echo "path=/usr/local/bin/buf" >> "$BRANCHD_OUTPUT"
  1. Lay it out. One directory per step, holding step.yaml (setup-buf/step.yaml). The directory's path is the step's name in a reference: xeonr/forge/steps/setup-buf@v1. Its keys are those of a composite step.
  2. List it in .branchd/packages.yaml on the default branch. Pipeline files declaring on: call are listed by their path the same way.
  3. Tag it vX.Y.Z. Consumers write @v1 and get your newest v1.x.y when their next run is compiled, so a new tag reaches them without their changing anything. Break compatibility only in a new major.
  4. Set the repository's visibility to who should use it: company or organisation for a shared step repository. A private repository's steps are usable by that repository alone.
  5. Test it from a second repository with branchd ci plan, which reads a sibling checkout's tags and commits (never its working tree): commit and tag in the step repository's clone first.

Keep a published step honest about what it touches: it runs with the caller's secrets and token, and callers read it before they use it.

A typed step

Not yet available (publishing): a repository on branchd cannot publish its own typed steps yet; it is rolling out (the step manifest below is final).

A typed step is one program that branchd runs in its own image. It reads typed inputs, writes typed outputs, can ask for a token for one Xeonr product, and fails with an error or an exit code. Its directory holds the Go main package and a manifest version 2 step.yaml:

steps/hello/step.yaml
# steps/hello/step.yaml
# A typed step (manifest v2): one program, built from the Go main package in
# this directory, run in its own image. Its registry name comes from the
# repository and directory, so the file names none.
manifest: 2
name: Hello
description: Greets someone and says how long the greeting was.
runs:
  main: .
  platforms: [linux/amd64, linux/arm64]
source: true
inputs:
  who:
    type: string
    default: world
    description: Who to greet.
outputs:
  length:
    type: int
    description: The greeting's length in bytes.
secrets:
  GREETING_TOKEN:
    optional: true
    description: Not needed to greet; shown here to declare a secret.

Step and package files lists every key.

  1. Lay it out as for a composite step: one directory per step, listed in .branchd/packages.yaml. The file names no registry package: branchd names it from your repository and the directory.
  2. Ask for a step grant if it needs network, privileged or host_runtime, or takes secrets it does not declare (accepts_any_secret). An administrator of your repository's company grants network and any_secret; privileged and host_runtime are an instance administrator's. Publishing refuses a step that declares more than its repository's grant.
  3. Publish from a version tag. A job of the tag's run, with permissions: {packages: write}, asks branchd to prepare the publish (RunService.PrepareStepPublish), pushes the step's image with the credential it is given, and records the version (RunService.PublishStep). branchd reads step.yaml itself, at the tag, and records your repository and commit as the version's source. Only a protected vX.Y.Z tag at the run's commit publishes, once per version.
  4. Use it from another repository as <team>/<repo>/<dir>@v1, like a composite step: @v1 takes your newest v1.x.y.

A step's grant and its secrets are its caller's to see: a job that lists secrets: narrows what the step gets, and a required secret it leaves out is refused at compile, naming it.

On this page