Release and publish
This page is for maintainers. A release creates git tags and GitHub releases. It publishes nothing
to crates.io or npm. A second step, the workflow publish.yml, publishes a release to the
registries by hand (see “Publish to crates.io and npm”).
How a release happens
- Every push to
mainruns.github/workflows/release.yml. The jobrelease-plz-propens or updates the release pull request (chore: release vX.Y.Z). The pull request changes the versions and the changelogs of the crates that changed. - Merge the release pull request after the checks pass.
- The push to
mainruns the jobrelease-plz-release. release-plz runs in git-only mode (git_only = trueinrelease-plz.toml). It creates two tags and two GitHub releases:vX.Y.Zfor the librarynanoflash;nanoflash-cli-vX.Y.Zfor the commandnanoflash-cli. This release is marked as the latest release.
- The crate
nanoflash-webis not released (release = false). Itspublish = falsesetting does not exclude it in git-only mode. - The job
release-plz-releaseoutputs the list of releases (releases, a JSON array ofpackage_name,prs,tagandversion). - The job
planreads that list. When it containsnanoflash-cli, the jobbinariescalls.github/workflows/binaries.ymlwith the tag of that release. Otherwisebinariesdoes not run. - To publish the release to crates.io, start
publish.ymlby hand (see “Publish to crates.io and npm”).
The lockfile of the example firmware (examples/nano33ble/Cargo.lock) records the version of
the path dependency nanoflash. release-plz does not update it. mise run example builds the
example without --locked, so Cargo updates that entry. Commit the changed lockfile with the
next change of the example.
A tag and a release created with GITHUB_TOKEN start no other workflow. A workflow that must
run for a release is called by release.yml itself.
Assets of the release of the command
The release nanoflash-cli-vX.Y.Z has no assets for the minutes that binaries.yml needs to
build and upload them. binaries.yml builds the command for six targets on native runners.
Release archives lists the targets and the three assets of
each target: the archive, its checksum and its software bill of materials.
The job build attests the build provenance of each archive. Verify an archive with:
gh attestation verify nanoflash-<target>.tar.gz --repo AlixANNERAUD/nanoflash
gh attestation verify nanoflash-<target>.zip --repo AlixANNERAUD/nanoflash
The job sbom runs after every build job succeeds. It runs mise run release-sbom, which
writes the six SBOMs into target/sbom/, and uploads them to the release.
The archive names have no version, so the URL of the latest release does not change. The metadata
[package.metadata.binstall] in crates/nanoflash-cli/Cargo.toml names these archives: its
pkg-url and bin-dir must follow every change of their names or of their directory.
When the assets are missing
When a job of binaries.yml fails, the release keeps the assets that were uploaded before the
failure. A run on the tag uses the workflow and the sources of the tag, so it cannot use a fix
made after the tag.
-
When the cause is outside the repository (a runner, the network, an outage of GitHub), use “Re-run failed jobs” on the run of
release.yml, or start the workflow again on the tag:gh workflow run binaries.yml --ref <tag> -f tag=<tag><tag>is the tag of the release, for examplenanoflash-cli-v0.1.0. The command must name the tag in--ref. The provenance names the commit of the run, and the jobs fail when the tag is not that commit. Uploads replace the assets that exist. -
When the cause is in the workflow or in the sources, fix it on
mainand release the next version.
Dry run
To build the archives without a release, start the workflow by hand without a tag:
gh workflow run binaries.yml
A dry run builds, tests and packs the six targets. It uploads nothing to a release, writes no SBOM and attests nothing. It keeps each archive and its checksum as a workflow artifact for 7 days.
Site on GitHub Pages
.github/workflows/pages.yml deploys the site to https://alixanneraud.github.io/nanoflash/.
The guide (docs/, built with mdBook) is the root of the site. The flasher page (web/flasher)
is at https://alixanneraud.github.io/nanoflash/flasher/. The site has a sitemap.xml and a
robots.txt at its root (see “Make the sitemap known to search engines”). The workflow runs:
- after each push to
mainthat changesdocs/,web/,crates/nanoflash/,crates/nanoflash-web/,Cargo.toml,Cargo.lock,mise.tomlor the workflow; - when you start it by hand (
gh workflow run pages.yml --ref main).
The job build runs mise run pages. That task builds the four WebAssembly modules and runs
mise run web-size: the job fails when a module is over 256000 bytes with gzip -9. The task
then builds the guide (mise run docs) and assembles the site in target/pages, and the job
uploads it with
actions/upload-pages-artifact. The job deploy publishes it with actions/deploy-pages in the
environment github-pages. Runs of the workflow do not overlap, and a running deployment is not
cancelled. Both jobs run only in the repository of the owner.
The flasher page shows the version of web/package.json and the short hash of the commit that the
site was built from (flasher/site.json). The site hosts no firmware and no manifest. The version of the page does not
change the npm package: this workflow publishes nothing to npm.
Enable GitHub Pages once, before the first push that runs the workflow. Without it, the job
deploy fails with a 404 error.
-
Open Settings, Pages, and set “Source” to “GitHub Actions”. Or run:
gh api -X POST repos/AlixANNERAUD/nanoflash/pages -f build_type=workflow -
Start the workflow:
gh workflow run pages.yml --ref main. -
Open the URL that the run page shows for the job
deploy, then open itsflasher/page in Chrome or Edge. The footer of the flasher page shows the version and the commit.
To check the site on the computer, run mise run pages-serve. It serves the guide at
http://localhost:8000/ and the flasher page at http://localhost:8000/flasher/.
Make the sitemap known to search engines
Crawlers read robots.txt only at the root of the host, here
https://alixanneraud.github.io/robots.txt. That address belongs to another repository, which
does not exist. The file robots.txt of this site is at /nanoflash/robots.txt, so crawlers do
not read it, and its Sitemap: line does not make the sitemap known. Do one of these steps:
- Add the property
https://alixanneraud.github.io/nanoflash/(a URL prefix) in Google Search Console and in Bing Webmaster Tools, and submithttps://alixanneraud.github.io/nanoflash/sitemap.xmlin each tool. - Or create the repository
AlixANNERAUD.github.ioand put arobots.txtat its root with the lineSitemap: https://alixanneraud.github.io/nanoflash/sitemap.xml.
Search Console checks the ownership of the property with an HTML file or a meta tag. Neither is
in the site yet.
Publish to crates.io and npm
release-plz runs in git-only mode, so it never publishes. The workflow
.github/workflows/publish.yml publishes a release to the registries. It starts by hand only
(workflow_dispatch). The crates nanoflash and nanoflash-cli have been on crates.io since
version 0.1.0, and the npm package nanoflash since version 0.1.0.
Before you publish
A published version cannot be replaced. Crates.io and npm accept a yank or a deprecation, but not a change of the files. Before you publish a version:
- Run the hardware checks of Run the hardware tests with the boards of the loop, including the monitor and run check and the browser check.
- Fix every failure on
mainand let release-plz propose the next version. - Check that
web/package.jsonin the release pull request has the new version of the library. release-plz does not changeweb/package.json. After release-plz writes the branch,release.ymlsets the version ofcrates/nanoflashinweb/package.jsonandweb/package-lock.jsonand pushes a commit when the version changes. When the repository has no secretRELEASE_PLZ_TOKEN, a push with the defaultGITHUB_TOKENstarts no other workflow, sorelease.ymlalso starts the CI on the head of the branch. - Merge the release pull request only after the checks pass.
- Wait for
release.ymlto create the release and forbinaries.ymlto upload the archives. The commandcargo binstall nanoflash-clineeds the archives of the release.
Start the workflow
Start the workflow on the branch main and name the tag of the library release:
gh workflow run publish.yml --ref main -f tag=v0.1.1 -f npm=true
The workflow has three inputs:
| Input | Default | Meaning |
|---|---|---|
tag | none | The tag of the library release, vX.Y.Z. The jobs check out this tag and publish its sources. |
crates | true | Run the job crates: publish nanoflash and nanoflash-cli to crates.io. |
npm | false | Run the job npm: stage the npm package nanoflash. |
Both jobs run only in the repository of the owner, and only when the run starts on main. A run
on another branch publishes nothing, so that the secret and the trust of npm never reach the
workflow file of another branch. Runs of the workflow do not overlap, and a running publication is not cancelled.
The job crates
- Checks that the tag has the form
vX.Y.Zand thatversionincrates/nanoflash/Cargo.tomlis the version of the tag. The job fails otherwise. - Runs
mise run package, the same package check asrelease.yml: every crate is packed and built from its package. - Runs
cargo publish --workspace --lockedwith the secretCARGO_REGISTRY_TOKEN. Cargo publishesnanoflashbeforenanoflash-cli, because the command depends on the library. It skipsnanoflash-web(publish = false).
The repository secret CARGO_REGISTRY_TOKEN must exist. A version that is already on crates.io
makes the publication fail. Start the next release instead.
The job npm
The job has no token. npm trusted publishing lets the workflow file publish.yml of this
repository stage a version of the package nanoflash, and nothing else. The trusted publisher is
set in the settings of the package on npmjs.com:
| Field | Value |
|---|---|
| Publisher | GitHub Actions |
| Organization or user | AlixANNERAUD |
| Repository | nanoflash |
| Workflow filename | publish.yml |
| Environment name | none |
| Allowed actions | npm stage publish only. npm publish and npm dist-tag are not allowed. |
The publishing access of the package requires two-factor authentication and refuses tokens that bypass it. A staged version is not public: a maintainer approves it with two-factor authentication.
The job:
- Checks that
versioninweb/package.jsonis the version of the tag. - Runs
mise run web: builds the WebAssembly modules, checks their size, builds the package and runs its tests. - Runs
npm stage publish --access public --provenance --ignore-scriptsinweb/, with npm 11.21.3: Node 22 comes with npm 10, andnpm stageneeds npm 11.15.0 or later. npm exchanges the OpenID Connect token of the run for a short-lived credential and signs the provenance statement with it, so the job has the permissionid-token: write.
Then approve the version. On npmjs.com, open Staged Packages, check the version and its files, and
approve it. The command npm stage approve <stage-id> (npm 11.15.0 or later) does the same. The
version gets the dist-tag that npm stage publish names, latest by default.