Publish from CI
Give a pipeline a team API key, point updater-cli at your app, and create and publish a release with its artifacts.
The Updater hosts your app's releases and tells installed copies when a newer
one is on their channel. A release is published by updater-cli, a command-line
tool that creates the release, uploads its artifacts and publishes it to the
app's targets. In CI it authenticates with a team API key, so no person has to
sign in.
The CLI needs three things, each a flag or an environment variable:
| Variable | Flag | What it is |
|---|---|---|
UPDATER_TOKEN | --token | A team API key (xk_…) |
UPDATER_API_URL | --api-url | https://updater.xeonr.io |
UPDATER_BUCKET_ID | --bucket-id | Your app's bucket id |
UPDATER_TOKEN can also be a person's Xeonr Auth access token for the
Updater, for running the CLI by hand. A flag wins over its variable. Every command except upgrade stops with
--token or UPDATER_TOKEN is required (and the same for the other two) when
one is missing.
1. Create an API key
Keys belong to a team and are managed on the team's API keys page in the console:
https://updater.xeonr.io/<team>/api-keysChoose Create key, name the key after the pipeline that will use it, and pick what it reaches:
- App-wide publishes to every app the team owns, including apps created later.
- Bound publishes only to the apps you choose under Resources. Prefer this for a pipeline that releases one app.
Optionally set an expiry. The key's secret, xk_…, is shown once, when you
create it. Copy it straight into your CI settings; nothing shows it again.
Creating and revoking keys needs the admin role in the team. Anyone in the team can see the list. API keys covers what a key may do.
2. Store it in CI
In GitLab, add it under Settings → CI/CD → Variables as UPDATER_TOKEN,
masked. Make it protected too if only protected branches and tags
publish, which is what you usually want.
Never commit the key or echo it in a job.
3. Find the bucket id
An app's id, its bucket id, is the first path segment of everything the Updater serves for it. Any of these shows it:
- the app's address in the console,
https://updater.xeonr.io/<team>/apps/<bucket-id>; - the install one-liner on the app's Overview, for a CLI app;
- any of the app's feed URLs,
https://updater.xeonr.io/<bucket-id>/….
The bucket id is not secret, so it can live in the CI file.
4. Check the setup
updater-cli config reads the app with the key and prints its name, branches
and targets. Run it once, locally or in a job, before the first publish:
export UPDATER_API_URL=https://updater.xeonr.io
export UPDATER_BUCKET_ID=<bucket-id>
export UPDATER_TOKEN=xk_…
updater-cli configName: Example App
Branches:
stable id=… semver
prerelease id=… semver
Targets:
production id=… branch=stable public
canary id=… branch=stable private--branch and --targets on publish take these names. If you see
app … not found, the key's team does not own that bucket id. If you see
this API key is not bound to app …, the key is bound to other apps.
5. Publish
updater-cli publish does the whole release in one command:
- reads the app's config and resolves
--branchand--targets; - scans
--dirfor artifacts and works out each one's platform from its filename; - creates the release as a draft, with your notes, the git commit and the repository URL;
- uploads each artifact and confirms it;
- publishes the release to its targets, unless you pass
--draft.
With no --targets, the release goes to every target on the branch.
A CLI or other plain binary
Build one executable per platform, plus an archive of each, named as the
Updater expects. Distribute a CLI
describes the files. For an app whose name slugifies to mytool:
dist/
mytool-linux-amd64
mytool_1.4.0_linux_amd64.tar.gz
mytool-darwin-arm64
mytool_1.4.0_darwin_arm64.tar.gz
mytool-windows-amd64.exe
mytool_1.4.0_windows_amd64.zipA GitLab pipeline that builds those on a version tag and publishes them to the
stable branch:
stages: [build, publish]
variables:
APP: mytool
UPDATER_API_URL: https://updater.xeonr.io
UPDATER_BUCKET_ID: "<bucket-id>"
.on-release-tag:
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
build:
extends: .on-release-tag
stage: build
image: golang:1.26
script:
- apt-get update -qq && apt-get install -y -qq zip > /dev/null
- VERSION="${CI_COMMIT_TAG#v}"
- mkdir -p dist stage
- |
for platform in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64; do
os="${platform%/*}"; arch="${platform#*/}"
exe=""; [ "$os" = windows ] && exe=".exe"
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath \
-ldflags "-s -w -X main.version=${VERSION}" \
-o "dist/${APP}-${os}-${arch}${exe}" "./cmd/${APP}"
# The archive holds the executable at its root, named <app>[.exe].
rm -rf stage/* && cp "dist/${APP}-${os}-${arch}${exe}" "stage/${APP}${exe}"
if [ "$os" = windows ]; then
(cd stage && zip -q "../dist/${APP}_${VERSION}_${os}_${arch}.zip" "${APP}${exe}")
else
tar -czf "dist/${APP}_${VERSION}_${os}_${arch}.tar.gz" -C stage "${APP}"
fi
done
artifacts:
paths: [dist/]
publish:
extends: .on-release-tag
stage: publish
image: alpine:3.22
needs: [build]
variables:
GIT_DEPTH: 0 # --auto-notes reads the history since the last release
script:
- apk add --no-cache curl git
- curl -fsSL https://updater.xeonr.io/77/install.sh | UPDATER_CLI_VERSION=1.2.6 sh
- >
updater-cli publish
--kind binary
--dir dist
--app "$APP"
--version "${CI_COMMIT_TAG#v}"
--branch stable
--auto-notesUPDATER_TOKEN comes from the CI/CD variable, so it never appears in the file.
The job prints each file it found with its platform, the SHA-256 of every
binary, and Release v1.4.0 published (6 artifacts) at the end.
--app matters when the binary's name differs from the app's name slugified
(lower case, with anything but letters and digits turned into hyphens). Files
named for a different app are skipped and listed as skipped. An archive for a
version other than --version fails the publish, so a stale build left in
dist/ cannot ship by mistake.
An Electron app
Point --dir at electron-builder's output. --kind electron is the default:
publish:
stage: publish
image: alpine:3.22
needs: [build-mac, build-win, build-linux]
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
variables:
UPDATER_API_URL: https://updater.xeonr.io
UPDATER_BUCKET_ID: "<bucket-id>"
script:
- apk add --no-cache curl git
- curl -fsSL https://updater.xeonr.io/77/install.sh | UPDATER_CLI_VERSION=1.2.6 sh
- updater-cli publish --dir dist --version "${CI_COMMIT_TAG#v}" --branch stable --notes-file RELEASE_NOTES.mdThe CLI files .dmg and mac .zip under darwin, NSIS .exe under win32,
.nupkg and RELEASES under win32-squirrel, and .AppImage, .deb,
.rpm and .snap under linux. It keeps .blockmap files beside their
artifact for differential downloads, and skips latest*.yml and
builder-* files.
A release holds one kind of artifact. A directory that mixes Electron output with plain binaries is refused, so publish each from its own directory.
When a publish fails partway
The release is created as a draft before anything is uploaded. If an upload fails, the draft stays. Retry the job: the same publish resumes the draft, skips the files it already holds, uploads the rest and publishes. A retry of a job that did publish says the release is already published and succeeds.
A draft from a different commit is not resumed; the run stops and names both commits. Then delete the draft in the console, signed in as yourself, or publish a new version. An API key cannot delete or rescind a release. The CLI has the details.
To have a person check a release before installs see it, pass --draft, and
publish it from the console.
Xeonr's shared CI
A Go CLI built with Xeonr's shared CI templates uses type: cli. It versions,
builds, archives and publishes with updater-cli publish --kind binary, so the
pipeline above is not needed. It reads the bucket id and API URL from the
app's updater: block for each environment, and the key from the same
UPDATER_TOKEN CI/CD variable.
On branchd: publish without a stored key
Not switched on yet, and not usable yet either: a job token publishes only from
a push of a protected tag, and Xeonr's shared CI still publishes from a branch
push. Until publishing moves to tags (PLAT-375), no repository can publish with
its job token, so filling in Publishing from CI does nothing yet: keep
UPDATER_TOKEN in CI. The step below uses it and says so in its log.
On branchd, a pipeline can publish with the job's own identity, so no API key needs to be stored in CI. Xeonr Auth exchanges the job's identity for a short-lived Updater token, and the Updater accepts that token only when all of these hold:
- the app's team owns the repository the pipeline runs in;
- the app's Settings → Publishing from CI lists that repository (the very
repository the forge had at that path when an admin saved it) and the step
that is publishing (by default
updater/publish); - the run is for a push of a protected release tag that starts with the
app's tag prefix (by default
v).
The token publishes exactly the version its tag names: the tag without the
prefix, so v1.4.0 publishes 1.4.0, and with the prefix tool-v,
tool-v1.4.0 does the same. The version is plain semver: a tag with build
metadata (v1.4.0+rebuild) is refused. It publishes only above every release
the branch already holds, drafts and rescinded ones included, so a version is
never made twice or below another. It publishes only to the branches the
settings choose (by default the branch named stable), and a pre-release
(1.5.0-rc.1) only to a branch the settings list for pre-releases; a
pre-release branch takes nothing else unless it is also chosen as a branch to
release to. The Updater checks every file again when the release is published,
against what it recorded when the file was uploaded. The release records the run's commit, and
only the same repository, tag and commit can finish it, so re-running a
failed tag's job completes the release. The token can do nothing else: no
branches, targets, keys, settings or signing secret.
To set it up:
- In the console, open the app's Settings → Publishing from CI (an admin
of the app's team; API keys and pipelines never can). Add the repository's
path, such as
acme/tool, and set the tag prefix your release tags use, the steps that publish, the branches to release to and the branches that take pre-releases. Saving looks the repository up in the forge as you, so it must be one you can see, and records which repository it is: if the repository is deleted and the path reused, save the path again to trust the new one. If someone else saved the settings after you opened them, your save is refused and the card shows theirs. - Protect the repository's release tags with a branch rule, and let only the release job create them.
- Publish with the Updater's own step:
- uses: xeonr/updater/cli/steps/publish@v1
with:
bucket_id: "77"
binary: tool
version: 1.4.0
branch: stable
platforms: [linux/amd64, darwin/arm64, windows/amd64]If people run what you publish, pin the step to an exact version
(@1.4.2) rather than @v1: @v1 runs the newest v1.x the step's
repository has tagged, with your job's identity and secrets.
dist/ must hold each platform's binary and archive, named as
a CLI or other plain binary describes.
mode: dry-run checks dist/ and prints the command without publishing.