From c8cfa60c5506283d8a771f9f7ec4f7d791263c1c Mon Sep 17 00:00:00 2001 From: Graeme Foster <80714+GraemeF@users.noreply.github.com> Date: Fri, 6 Nov 2026 09:50:50 +0000 Subject: [PATCH] feat: attach an installable package for every desktop to each release A release now carries the Quickshell build as a tarball, which Dux Modular Shell, Quickshell alone and KDE Plasma all install, the KWin effect as a kpackage archive that `kpackagetool6 --install` and the KDE Store take as is, the GNOME extension zip straight from `gnome-extensions pack`, and a SHA256SUMS file. The names carry no version, so the README's install steps link to the latest release and never need editing. The flake builds them all as `.#release`, so `nix flake check` builds every package on each pull request, and CI uploads them as a workflow artifact. The release workflow uploads the same output. A version in `kwin/metadata.json` that differs from `plugin.json` fails the build. Both workflows now hold no permissions at the top, give the job only what it needs, and drop the checkout's credentials. The release tags through the GitHub API instead of a git push, so no step needs a token in git. The GNOME zip installs with `gnome-extensions install` and the effect archive with `kpackagetool6`, both checked against the real tools in a throwaway home. --- .github/workflows/ci.yml | 15 +++++++++++-- .github/workflows/release.yml | 29 ++++++++++-------------- README.md | 26 +++++++++++++++------- RELEASE-NOTES/README.md | 4 ++-- flake.nix | 42 ++++++++++++++++++++++++++++++++++- 5 files changed, 86 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86c9b22..4752499 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,14 +5,25 @@ on: branches: [main] pull_request: -permissions: - contents: read +permissions: {} jobs: check: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + persist-credentials: false - uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23 - run: nix flake check - run: nix shell nixpkgs#nodejs -c node --test + - name: Build the release packages + run: | + nix build .#release + ls -l result/ + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: release-packages + path: result/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 001efd3..8ff5651 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,8 +7,7 @@ on: types: [completed] workflow_dispatch: -permissions: - contents: write +permissions: {} jobs: release: @@ -19,6 +18,8 @@ jobs: (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success') runs-on: ubuntu-latest + permissions: + contents: write env: GH_TOKEN: ${{ github.token }} SHA: ${{ github.event.workflow_run.head_sha || github.sha }} @@ -26,6 +27,7 @@ jobs: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: ${{ env.SHA }} + persist-credentials: false - uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23 - name: Decide whether this merge is a release @@ -37,33 +39,26 @@ jobs: echo "release=false" >> "$GITHUB_OUTPUT" elif [ -f "RELEASE-NOTES/$version.md" ]; then echo "release=true" >> "$GITHUB_OUTPUT" - elif git ls-remote --exit-code --tags origin "v$version" >/dev/null 2>&1; then + elif gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/v$version" >/dev/null 2>&1; then echo "release=true" >> "$GITHUB_OUTPUT" else echo "::error::version $version has no tag, no release and no RELEASE-NOTES/$version.md" exit 1 fi - - name: Build the package + - name: Build the packages if: steps.plan.outputs.release == 'true' - env: - VERSION: ${{ steps.plan.outputs.version }} run: | - nix build .#default - tar -C result/share --dereference -czf "cvesmic-$VERSION.tar.gz" cvesmic - sha256sum "cvesmic-$VERSION.tar.gz" > "cvesmic-$VERSION.tar.gz.sha256" + nix build .#release + ls -l result/ + # GitHub creates the tag at $SHA if it does not exist, and ignores + # --target if it does. - name: Tag and announce if: steps.plan.outputs.release == 'true' env: VERSION: ${{ steps.plan.outputs.version }} run: | - v="v$VERSION" - git ls-remote --exit-code --tags origin "$v" >/dev/null 2>&1 || { - git tag "$v" "$SHA" - git push origin "$v" - } - gh release create "$v" --verify-tag --title "$v" \ + gh release create "v$VERSION" --target "$SHA" --title "v$VERSION" \ --notes-file "RELEASE-NOTES/$VERSION.md" \ - "cvesmic-$VERSION.tar.gz" \ - "cvesmic-$VERSION.tar.gz.sha256" + result/* diff --git a/README.md b/README.md index 6ae7923..5687fd1 100644 --- a/README.md +++ b/README.md @@ -19,34 +19,44 @@ It is an alarm bell, not an encyclopaedia. It follows one feed, pwn.watch's "Pat ## Installing -On GNOME, pack the extension together with the code it shares with the Quickshell build, and install the pack. Then log out and back in, because GNOME Shell reads new extensions at login, and switch it on: +Every release carries one package per desktop and a `SHA256SUMS` file to check them against. The links below fetch the latest release. + +On GNOME, install the extension zip, log out and back in, because GNOME Shell reads new extensions at login, and switch it on: ```sh -gnome-extensions pack gnome/cvesmic@codeforbreakfast.co --extra-source=../../plugin/cvesmic/Feed.mjs --extra-source=../../plugin/cvesmic/Shake.mjs +curl -LO https://github.com/CodeForBreakfast/cvesmic/releases/latest/download/cvesmic@codeforbreakfast.co.shell-extension.zip gnome-extensions install cvesmic@codeforbreakfast.co.shell-extension.zip gnome-extensions enable cvesmic@codeforbreakfast.co ``` -With Dux Modular Shell, copy `plugin/cvesmic` into the shell's plugins folder, then switch it on: +With Dux Modular Shell, unpack the Quickshell build into the shell's plugins folder, then switch it on: ```sh -cp -r plugin/cvesmic ~/.config/dms/plugins/cvesmic +curl -LO https://github.com/CodeForBreakfast/cvesmic/releases/latest/download/cvesmic-quickshell.tar.gz +mkdir -p ~/.config/dms/plugins +tar -xzf cvesmic-quickshell.tar.gz -C ~/.config/dms/plugins dms ipc call plugins enable cvesmic ``` -On Quickshell alone, copy the same folder into Quickshell's config folder and start it: +On Quickshell alone, unpack the same file into Quickshell's config folder and start it: ```sh -cp -r plugin/cvesmic ~/.config/quickshell/cvesmic +curl -LO https://github.com/CodeForBreakfast/cvesmic/releases/latest/download/cvesmic-quickshell.tar.gz +mkdir -p ~/.config/quickshell +tar -xzf cvesmic-quickshell.tar.gz -C ~/.config/quickshell qs -c cvesmic ``` To start it with your session, have your compositor run `qs -c cvesmic` at startup. -On KDE Plasma, copy the folder the same way, install the KWin effect as well, and let Plasma start `qs` with your session: +On KDE Plasma, you need two files. The Quickshell build watches the feed, and the KWin effect does the shaking. Unpack the Quickshell build into Quickshell's config folder, install the effect, and let Plasma start `qs` with your session: ```sh -kpackagetool6 --type KWin/Effect --install plugin/cvesmic/kwin +curl -LO https://github.com/CodeForBreakfast/cvesmic/releases/latest/download/cvesmic-quickshell.tar.gz +curl -LO https://github.com/CodeForBreakfast/cvesmic/releases/latest/download/cvesmic-kwin.tar.gz +mkdir -p ~/.config/quickshell +tar -xzf cvesmic-quickshell.tar.gz -C ~/.config/quickshell +kpackagetool6 --type KWin/Effect --install cvesmic-kwin.tar.gz cat > ~/.config/autostart/cvesmic.desktop <<'EOF' [Desktop Entry] Type=Application diff --git a/RELEASE-NOTES/README.md b/RELEASE-NOTES/README.md index c25ce1f..009717a 100644 --- a/RELEASE-NOTES/README.md +++ b/RELEASE-NOTES/README.md @@ -2,10 +2,10 @@ A release is one pull request. Merging it releases, because the Release workflow does everything after the merge. Nobody pushes a tag by hand. -The pull request raises `version` in `plugin/cvesmic/plugin.json` and adds `RELEASE-NOTES/.md`. The notes become the GitHub Release body word for word. +The pull request raises `version` in `plugin/cvesmic/plugin.json` and `Version` in `plugin/cvesmic/kwin/metadata.json`, and adds `RELEASE-NOTES/.md`. The notes become the GitHub Release body word for word. Write each paragraph of the notes on one line. GitHub renders a release body with hard line breaks, and `nix flake check` refuses a wrapped file. -The Release workflow runs when CI succeeds on a push to `main`. If `v` has no GitHub Release and the notes file exists, it builds the package, tags the commit and creates the release with a tarball and its checksum. If the version has neither a release nor a notes file, the run fails until the notes file lands. Version `0.0.0` is the unreleased placeholder and never releases. +The Release workflow runs when CI succeeds on a push to `main`. If `v` has no GitHub Release and the notes file exists, it builds the packages, tags the commit and creates the release with a package for each desktop and their checksums. `nix build .#release` builds the same packages, and CI attaches them to every run as the `release-packages` artifact. If the version has neither a release nor a notes file, the run fails until the notes file lands. Version `0.0.0` is the unreleased placeholder and never releases. A release that died part-way is repaired by running the Release workflow by hand on `main`. Every step is safe to run twice. diff --git a/flake.nix b/flake.nix index 300b399..2bef575 100644 --- a/flake.nix +++ b/flake.nix @@ -6,13 +6,17 @@ outputs = { self, nixpkgs }: let + lib = nixpkgs.lib; pluginDir = ./plugin/cvesmic; + gnomeDir = ./gnome + "/cvesmic@codeforbreakfast.co"; version = (builtins.fromJSON (builtins.readFile (pluginDir + "/plugin.json"))).version; + kwinVersion = + (builtins.fromJSON (builtins.readFile (pluginDir + "/kwin/metadata.json"))).KPlugin.Version; systems = [ "x86_64-linux" "aarch64-linux" ]; - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + forAllSystems = f: lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); cvesmic = pkgs: pkgs.stdenvNoCC.mkDerivation { @@ -26,11 +30,46 @@ ''; meta.description = "Shakes the screen when a new vulnerability appears"; }; + # The files a release attaches. Their names carry no version, so the + # README can link to releases/latest/download/. + releaseFiles = + pkgs: + if version != kwinVersion then + throw "plugin.json says version ${version} but kwin/metadata.json says ${kwinVersion}" + else + pkgs.stdenvNoCC.mkDerivation { + pname = "cvesmic-release"; + inherit version; + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + pluginDir + gnomeDir + ]; + }; + nativeBuildInputs = [ pkgs.gnome-shell ]; + buildPhase = '' + pack() { + tar --sort=name --mtime=@1 --owner=0 --group=0 --numeric-owner -I 'gzip -n' "$@" + } + pack -C plugin -cf cvesmic-quickshell.tar.gz cvesmic + pack -C plugin/cvesmic/kwin -cf cvesmic-kwin.tar.gz metadata.json contents + gnome-extensions pack gnome/cvesmic@codeforbreakfast.co \ + --extra-source=../../plugin/cvesmic/Feed.mjs \ + --extra-source=../../plugin/cvesmic/Shake.mjs + sha256sum cvesmic-quickshell.tar.gz cvesmic-kwin.tar.gz cvesmic@codeforbreakfast.co.shell-extension.zip > SHA256SUMS + ''; + installPhase = '' + mkdir $out + cp cvesmic-quickshell.tar.gz cvesmic-kwin.tar.gz cvesmic@codeforbreakfast.co.shell-extension.zip SHA256SUMS $out/ + ''; + }; in { packages = forAllSystems (pkgs: rec { cvesmic = self.lib.cvesmic pkgs; default = cvesmic; + release = releaseFiles pkgs; }); overlays.default = final: _prev: { cvesmic = self.lib.cvesmic final; }; @@ -39,6 +78,7 @@ checks = forAllSystems (pkgs: { package = self.packages.${pkgs.stdenv.hostPlatform.system}.default; + release = self.packages.${pkgs.stdenv.hostPlatform.system}.release; release-notes-wrap = pkgs.runCommand "release-notes-wrap" { src = ./RELEASE-NOTES; } '' for f in "$src"/*.md; do if awk 'prev != "" && $0 != "" {bad=1} {prev=$0} END {exit !bad}' "$f"; then