Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
29 changes: 12 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ on:
types: [completed]
workflow_dispatch:

permissions:
contents: write
permissions: {}

jobs:
release:
Expand All @@ -19,13 +18,16 @@ 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 }}
steps:
- 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
Expand All @@ -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/*
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions RELEASE-NOTES/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<version>.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/<version>.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<version>` 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<version>` 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.
42 changes: 41 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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/<name>.
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; };
Expand All @@ -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
Expand Down
Loading