Repository navigation
ci: add a release workflow - #9
Merged
Merged
Conversation
Currently, whoever wants the C library has to build libuapi16 with
build.sh and install.sh, and so needs a Rust toolchain. Let's ship it
prebuilt with every release instead.
A push of a v* tag builds the library for x86_64 and aarch64 Linux, each
on GitHub's native runner, with rustc 1.85, the oldest one we support.
The build is build.sh and install.sh as they are. The linker binds every
glibc symbol the library uses to the newest version of that symbol in
the glibc it links against, and a glibc without that version can't load
the library. So the build runs in a container with AlmaLinux 9.8, pinned
by its digest, whose glibc is 2.34, and not on the runner, whose glibc
is newer. That covers RHEL 9, CentOS Stream 9, Amazon Linux 2023 and
every distribution with a newer glibc.
Each architecture gets uapi16-<version>-<arch>-linux-gnu.tar.gz, with a
directory of that name at its top, laid out as the prefix install.sh
installs to:
lib/libuapi16.so.<version>, with the links .so.0 and .so
lib/libuapi16.a
lib/pkgconfig/uapi16.pc
include/uapi16.h
share/licenses/uapi16/
install.sh writes the prefix into uapi16.pc. The tarball's uapi16.pc
has prefix=${pcfiledir}/../.. instead, so the tarball can be unpacked
anywhere.
The library links Rust's standard library and the crates it depends on,
so the tarball carries their license texts next to its own. The texts
of the standard library come from the toolchain. For every crate of
Cargo.lock that is linked into the library, as cargo tree lists them,
they are the license files of its source. A crate without a license
file fails the job.
Before anything is uploaded the job checks the layout of the tarball,
that the shared library exports its functions at LIBUAPI16_0.1.0 and
nothing else, that it needs no glibc symbol newer than GLIBC_2.34, and
that the examples build against the unpacked tarball with pkg-config and
run. The full C tests stay in the CI of every pull request.
Each tarball gets a build provenance attestation from actions/attest,
which says what workflow run built it from which commit:
gh attestation verify <tarball> -R systemd/uapi16 \
--source-ref refs/tags/<tag> \
--signer-workflow systemd/uapi16/.github/workflows/release.yml
For a tag the version has to be the version of src/uapi16/Cargo.toml.
A job of its own writes SHA256SUMS over the tarballs, and the workflow
then makes a draft release with the tarballs and SHA256SUMS, with the
message of the tag as its notes. Nothing is signed in CI. SHA256SUMS
gets signed by hand, and SHA256SUMS.asc is uploaded to the draft before
it is published.
Every pull request runs the build job as well, on each architecture and
with all of its checks. So a change that breaks the tarballs shows up in
its pull request and not only once a tag is pushed. A pull request gets
no attestation, no artifact and no release. One from a fork gets a token
that can only read, which is all the build needs. A new push to a pull
request cancels the run for the push before it.
A run by hand, with workflow_dispatch, builds, checks and attests the
tarballs of a branch, writes SHA256SUMS and keeps all of it as artifacts
of the run. So it does everything a tag does except for the draft
release itself, which first runs with the first tag.
The README now says how to install the prebuilt library and how to
check a release.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a release workflow that ships the C library, libuapi16,
prebuilt with every release. It's stacked on #7, which adds the library.
A v* tag builds libuapi16 for x86_64 and aarch64 Linux, each on GitHub's
native runner, with rustc 1.85, the oldest one we support. The build is
build.sh and install.sh as they are. The linker binds every glibc symbol
the library uses to the newest version of it in the glibc it links
against, and a glibc without that version can't load the library. So
the build doesn't run on the runner, whose glibc is newer, but in a
container with AlmaLinux 9.8, pinned by its digest, and the library is
linked against glibc 2.34. That covers RHEL 9, CentOS Stream 9, Amazon
Linux 2023 and every distribution with a newer glibc. RHEL 8, with glibc
2.28, is left out.
Each architecture gets a tarball, with a directory of the same name at
its top, laid out as the prefix install.sh installs to:
The uapi16.pc in it has prefix=${pcfiledir}/../.. instead of the
directory install.sh installed to, so the tarball works wherever it is
unpacked:
The library links Rust's standard library and the crates it depends on,
so share/licenses/uapi16 has their license texts next to its own
LICENSE. For the standard library they're the toolchain's COPYRIGHT,
LICENSE-APACHE and LICENSE-MIT. For every crate of Cargo.lock that is
linked into the library, as cargo tree lists them, they're the license
files of its source. A crate without a license file fails the job. As
far as I can tell that's what these licenses ask for, but it isn't a
legal opinion.
Before anything is uploaded the job checks:
and nothing else
and run
The full C tests stay in the CI of every pull request.
Each tarball gets a build provenance attestation from actions/attest. It
says which run of this workflow built the tarball, from which commit.
systemd/uapi16 is public, so the attestation is signed through
Sigstore's public-good instance and recorded in its transparency log.
GitHub keeps it as well. It isn't part of the release.
For a tag, the tag has to name the version in src/uapi16/Cargo.toml. A
job of its own writes SHA256SUMS over the tarballs. The workflow then
makes a draft release of the tag with the tarballs and SHA256SUMS, and
takes its notes from the message of the tag. Nothing is signed in CI. I
sign SHA256SUMS with my Nitrokey, upload SHA256SUMS.asc to the draft and
publish it by hand. So a release has both: the attestation says where a
tarball was built, and the signature says that I released it.
The README now says how to install the prebuilt library, and how to
check a release with SHA256SUMS.asc and with the attestation:
Every pull request runs the build job too, on each architecture and
with all of its checks, so a change that breaks the tarballs shows up in
its pull request. That includes this one. A pull request gets no
attestation, no artifact and no release, and one from a fork gets a
token that can only read, which is all the build needs. A new push to a
pull request cancels the run for the push before it.
A run by hand, with workflow_dispatch, does everything but the release.
It builds, checks and attests the tarballs of a branch, writes
SHA256SUMS and keeps all of it as artifacts of the run. So after a run
by hand on main, only the draft release itself runs for the first time
with the first tag.
A release then goes like this:
(1) Check that the Nitrokey is unlocked, without letting gpg prompt:
If that fails, unlock it first, for example with the same command
without --pinentry-mode error, which asks for the PIN. That way gpg
doesn't prompt in the middle of the steps below.
(2) Tag main and push the tag. Its message becomes the notes of the
release:
(3) Wait for the workflow to make the draft. Fetch it and check the
sums:
(4) Verify the attestations:
(5) Sign SHA256SUMS:
(6) Upload SHA256SUMS.asc to the draft:
(7) Publish the draft with the button on its page.
The build job ran on x86_64 in the same AlmaLinux 9.8 container, step by
step from release.yml, as a pull request, a run by hand and a tag run
it, and so did the SHA256SUMS job and, with a stand-in for gh, the draft
release. On Rocky Linux 9, Debian 12, Ubuntu 22.04 and Amazon Linux
2023 the examples build against the unpacked tarball with pkg-config and
run, and tests/capi.sh passes against it. The aarch64 build first runs
on this pull request, and the attestation with the first run by hand on
main.