diff --git a/.github/actions/nix/action.yaml b/.github/actions/nix/action.yaml index 0e80a8d3..022d1fcd 100644 --- a/.github/actions/nix/action.yaml +++ b/.github/actions/nix/action.yaml @@ -42,10 +42,11 @@ runs: # The key is flake.lock, so a job that builds against another nixpkgs (the canary) turns the # cache off: what it restored would be of no use to it, and what it saved would replace the - # store of the jobs that do use this lock. + # store of the jobs that do use this lock. The architecture is part of the key, because the + # x86_64 and arm64 runners build different store paths. - if: inputs.cache == 'true' uses: nix-community/cache-nix-action@v7 with: - primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock', '**/Cargo.lock') }} - restore-prefixes-first-match: nix-${{ runner.os }}- + primary-key: nix-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('flake.lock', '**/Cargo.lock') }} + restore-prefixes-first-match: nix-${{ runner.os }}-${{ runner.arch }}- gc-max-store-size-linux: 8G diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b35cd2a..cad956b7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -206,3 +206,119 @@ jobs: gh issue create --repo "$GITHUB_REPOSITORY" --title "$title" \ --body-file "$RUNNER_TEMP/canary.md" fi + + # komorebi and komorebic for each architecture, kept for 14 days, and what the publish job + # releases. nix points a binary at the dynamic loader and the libraries of its store, which only a + # machine with those store paths has, so each binary is pointed at the system's loader instead, + # at the path every glibc system has it, and run on this Ubuntu runner to show that it works. + # The arm64 job may fail without failing the run. + build: + if: github.repository == 'LGUG2Z/komorebi-for-kde' + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + runs-on: ubuntu-24.04 + loader: /lib64/ld-linux-x86-64.so.2 + optional: false + - target: aarch64-unknown-linux-gnu + runs-on: ubuntu-24.04-arm + loader: /lib/ld-linux-aarch64.so.1 + optional: true + runs-on: ${{ matrix.runs-on }} + continue-on-error: ${{ matrix.optional }} + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/nix + - name: Build komorebi and komorebic + env: + LOADER: ${{ matrix.loader }} + run: | + mkdir bin + for name in komorebi komorebic; do + cp "$(nix build -L --no-link --print-out-paths ".#$name")/bin/$name" bin/ + done + chmod u+w bin/* + nix run --inputs-from . nixpkgs#patchelf -- --set-interpreter "$LOADER" --remove-rpath bin/* + echo "the newest glibc symbol version they need:" \ + "$(objdump -T bin/* | grep -o 'GLIBC_[0-9.]*' | sort -uV | tail -n 1)" + bin/komorebi --version + bin/komorebic --version + - uses: actions/upload-artifact@v7 + with: + name: komorebi-${{ matrix.target }}-${{ github.sha }} + path: bin/ + retention-days: 14 + + # A push of a `v*` tag makes a release of what the build job made, and a scheduled or manual run + # on master replaces the rolling `nightly` prerelease, once the lint and the fast VM tier have + # passed. The release notes are the commit messages since the previous version tag, by kokai. + publish: + needs: [lint, vm-fast, build] + if: >- + github.repository == 'LGUG2Z/komorebi-for-kde' && (startsWith(github.ref, 'refs/tags/v') || + (github.ref == 'refs/heads/master' && + (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'))) + runs-on: ubuntu-24.04 + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - name: Decide what is published + run: | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + echo "TAG=$GITHUB_REF_NAME" >>"$GITHUB_ENV" + echo "VERSION=${GITHUB_REF_NAME#v}" >>"$GITHUB_ENV" + else + echo "TAG=nightly" >>"$GITHUB_ENV" + echo "VERSION=nightly" >>"$GITHUB_ENV" + fi + - uses: actions/download-artifact@v8 + with: + pattern: komorebi-*-${{ github.sha }} + path: artifacts + - name: Package + run: | + mkdir dist + for target in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do + build="artifacts/komorebi-$target-$GITHUB_SHA" + if [ ! -d "$build" ]; then + echo "::warning::there is no build for $target, so it is not published" + continue + fi + # an artifact does not keep the executable bit + chmod +x "$build/komorebi" "$build/komorebic" + zip -j "dist/komorebi-$VERSION-$target.zip" "$build/komorebi" "$build/komorebic" + done + - name: Add the schema of komorebi.json + if: hashFiles('schema.json') != '' + run: cp schema.json dist/ + - name: Write the checksums + working-directory: dist + run: sha256sum -- * >checksums.txt + - name: Write the release notes + run: | + cargo install --locked kokai@0.3.1 + # kokai lists the commits between the tag before the one it is given and that one. The + # nightly tag of the last run moves to this commit, so that the range starts at the + # last version. + if [ "$TAG" = nightly ]; then git tag --force nightly; fi + kokai release --no-emoji --add-links github:commits,issues --ref "$TAG" \ + >"$RUNNER_TEMP/release-notes.md" + - name: Publish + run: | + if [ "$TAG" = nightly ]; then + gh release delete nightly --cleanup-tag --yes || true + gh release create nightly --target "$GITHUB_SHA" --prerelease \ + --title "komorebi for KDE nightly ($GITHUB_SHA)" \ + --notes-file "$RUNNER_TEMP/release-notes.md" dist/* + else + gh release create "$TAG" --verify-tag --title "komorebi for KDE $TAG" \ + --notes-file "$RUNNER_TEMP/release-notes.md" dist/* + fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f6cf7c5f..0980d073 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -173,6 +173,35 @@ run `nix flake update nixpkgs` in a checkout and build the check the issue names (`just vm NAME` for a VM suite). The fix goes in a commit of its own; nixpkgs is not pinned back. +## Releases + +A release is a tag. Set `version` under `[workspace.package]` in +[`Cargo.toml`](Cargo.toml) to the new version, commit it, and push the tag +`vVERSION` on that commit. For every run, the `build` job of `ci.yaml` builds +`komorebi` and `komorebic` with nix on an x86_64 and an arm64 runner, and keeps +them as an artifact of the run for 14 days. On a tag, once `lint`, `vm-fast` and +`build` have passed, the `publish` job makes the GitHub release of that tag +with: + +- `komorebi-VERSION-x86_64-unknown-linux-gnu.zip` and + `komorebi-VERSION-aarch64-unknown-linux-gnu.zip`, each with the two binaries; +- `checksums.txt`, the SHA-256 sum of every other file of the release; +- `schema.json`, the schema of `komorebi.json`, when the repository has one; +- release notes that [kokai](https://github.com/Joxit/kokai) writes from the + commit messages since the previous version tag. + +The scheduled run on `master` every week, and a run of the workflow started by +hand on `master`, replace the `nightly` prerelease the same way: `nightly` +takes the place of the version in the file names, and the notes list the +commits since the last version tag. The arm64 job may fail without failing the +run; the release then has no arm64 zip. + +nix builds a binary that loads glibc from the nix store, so the build job +points each binary at the system's dynamic loader, at the standard path for its +architecture, with no library path, and runs it on the Ubuntu runner to check +that it starts. A release binary therefore uses the glibc of the system it runs +on. + ## Commits Commit messages follow the diff --git a/README.md b/README.md index 95a20355..05eaed74 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,10 @@ moving and the drawing. On NixOS, the flake's module, `services.komorebi`, installs `komorebi` and `komorebic` and starts komorebi with every Plasma session: one flake input, one module line and `services.komorebi.enable = true`. Elsewhere, both are -built from source. [`docs/installation.md`](docs/installation.md) has both -ways. There are no prebuilt binaries: the Komorebi license does not allow third -parties to redistribute them. +built from source, or taken from a release of this repository +([Binaries](#binaries)). [`docs/installation.md`](docs/installation.md) has the +module and the build from source. The Komorebi license does not allow anyone +else to redistribute binaries. ## Running it locally @@ -62,6 +63,23 @@ use. With [direnv](https://direnv.net), the [`.envrc`](.envrc) does it on `cd`. On Linux, `nix run .#komorebi -- --version` builds and runs the daemon without a checkout of the toolchain. +## Binaries + +The [releases](https://github.com/LGUG2Z/komorebi-for-kde/releases) of this +repository have `komorebi` and `komorebic` for x86_64 and aarch64 Linux, one zip +per architecture, with a `checksums.txt` of SHA-256 sums. The `nightly` +prerelease is built from `master` every week. CI builds the binaries; +[`CONTRIBUTING.md`](CONTRIBUTING.md#releases) says how. They use the glibc of +the system they run on, which has to be 2.39 or newer at time of writing +(2026-10-27). NixOS cannot run them without +[nix-ld](https://github.com/nix-community/nix-ld); on NixOS, build komorebi +from this flake instead. + +The [Komorebi License](LICENSE.md) allows anyone to distribute the source code, +but not binaries built from it. The releases of this repository are the only +binaries, and there is no public binary cache for the flake: nix builds +komorebi from source. + ## Crates - [`komorebi`](komorebi): the daemon, and the library behind it. The library has diff --git a/docs/dev/DESIGN.md b/docs/dev/DESIGN.md index 50f94065..26dd240c 100644 --- a/docs/dev/DESIGN.md +++ b/docs/dev/DESIGN.md @@ -203,7 +203,9 @@ again. ## Why is there no binary cache? The Komorebi license does not allow third parties to redistribute binaries. There is no public -binary cache for komorebi, and every installation builds it from source. +binary cache for komorebi, so the flake builds it from source on each machine that installs it. +The releases of this repository are the only binaries +([why](#why-are-binaries-published-only-by-this-repository)). ## Why do the VM tests run on machines built with the module? @@ -829,3 +831,14 @@ builders: those boot a virtual machine as part of the build, so they need a buil a Linux builder that is itself a virtual machine on the Mac, as `darwin.linux-builder` is, has no nested KVM. `nixos-install` is a plain program, in a guest that runs at the speed of the Mac's own virtualization. + +## Why are binaries published only by this repository? + +The Komorebi License allows anyone to distribute the source code, with changes, but not +binaries built from it. So the releases of this repository, which CI builds, are the only +binaries, and the flake has no public binary cache: nix builds komorebi from source. + +The release binaries are built by nix like every other output of the flake, then pointed at +the system's dynamic loader with no library path. As nix builds it, a binary loads glibc from +the store paths of the nixpkgs revision it was built with, which a machine without that +revision in its store does not have. diff --git a/docs/installation.md b/docs/installation.md index 575218ef..9156dcb4 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -5,11 +5,13 @@ command line that controls it. The daemon runs in a KDE Plasma Wayland session w newer ([PLATFORM.md](dev/PLATFORM.md) has what it needs from the session). On NixOS, the repository's flake has a module that installs both programs and starts komorebi -with every Plasma session. On any other distribution, build them from source. +with every Plasma session. On any other distribution, build them from source, or take the +binaries of a release ([Binaries](../README.md#binaries) says which and what they need). -There is no binary cache and there are no prebuilt binaries: the Komorebi license does not allow -third parties to redistribute binaries, so every installation builds komorebi from source. On -NixOS, Nix does that for you, the first time you switch to a configuration that has it. +There is no binary cache: the Komorebi license does not allow third parties to redistribute +binaries, so the flake builds komorebi from source on each machine that installs it. On NixOS, +Nix does that for you, the first time you switch to a configuration that has it. The releases of +this repository are the only binaries. ## NixOS