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
34 changes: 31 additions & 3 deletions .github/actions/package/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Package
description: >-
The packages of the release build already in target/release (NSIS on Windows; deb, AppImage and
rpm on Linux), signed, each checked to hold the application alone, gathered with the standalone
rpm on Linux; a .dmg and the updater's archive on macOS), signed, each checked to hold the application alone, gathered with the standalone
executable into a folder.

inputs:
Expand Down Expand Up @@ -43,6 +43,25 @@ runs:
rm -rf "$packages"
if [ "$RUNNER_OS" = Windows ]; then
cargo packager -p app --release -f nsis -o "$packages"
elif [ "$RUNNER_OS" = macOS ]; then
# The runner's scanners can still hold the image when it is ejected: busy, free later.
for attempt in 1 2 3; do
cargo packager -p app --release -f app,dmg -o "$packages" && break
[ "$attempt" = 3 ] && exit 1
hdiutil detach /Volumes/DevNotes -force > /dev/null 2>&1 || true
rm -rf "$packages"
sleep 15
done
# One archive an architecture in a release: the packager names it after the application alone.
version=$(cargo metadata --format-version 1 --no-deps \
| jq -r '.packages[] | select(.name == "app") | .version')
arch=$([ "$RUNNER_ARCH" = ARM64 ] && echo aarch64 || echo x64)
for ending in dmg dmg.sig; do
mv "$packages/DevNotes_${version}_$arch.$ending" "$packages/devnotes_${version}_$arch.$ending"
done
for ending in app.tar.gz app.tar.gz.sig; do
mv "$packages/DevNotes.$ending" "$packages/devnotes_${version}_$arch.$ending"
done
else
cargo packager -p app --release -f deb,appimage -o "$packages"
version=$(cargo metadata --format-version 1 --no-deps \
Expand Down Expand Up @@ -75,6 +94,15 @@ runs:
pwsh -NoProfile -Command "Start-Process '$(cygpath -w "$scratch/uninstall.exe")' -ArgumentList '/S' -Wait"
# The uninstaller leaves the remembered folder behind; a later install would reuse it.
reg delete 'HKCU\Software\vmillet-dev\DevNotes' //f > /dev/null 2>&1 || true
elif [ "$RUNNER_OS" = macOS ]; then
codesign --verify --deep --strict "$packages/DevNotes.app"
archive=$(ls "$packages"/*.app.tar.gz)
check archive "$(tar -tzf "$archive" | grep '/Contents/MacOS/[^/]' | xargs -n1 basename)" devnotes
mounted="$RUNNER_TEMP/dmg-check"
# The image shows the licence first; `yes` ends on a closed pipe.
{ yes 2> /dev/null || true; } | PAGER=cat hdiutil attach -nobrowse -readonly -mountpoint "$mounted" "$(ls "$packages"/*.dmg)" > /dev/null
check dmg "$(ls "$mounted/DevNotes.app/Contents/MacOS")" devnotes
hdiutil detach "$mounted" > /dev/null
else
deb=$(ls "$packages"/*.deb)
check deb "$(dpkg-deb -c "$deb" | awk '$6 ~ /^\.?\/?usr\/bin\/[^\/]+$/ { n = split($6, p, "/"); print p[n] }')" devnotes
Expand All @@ -97,11 +125,11 @@ runs:
| jq -r '.packages[] | select(.name == "app") | .version')
mkdir -p "$OUT"
find "$packages" -maxdepth 1 -type f \
\( -name '*-setup.exe' -o -name '*.deb' -o -name '*.rpm' -o -name '*.AppImage' -o -name '*.sig' \) \
\( -name '*-setup.exe' -o -name '*.deb' -o -name '*.rpm' -o -name '*.AppImage' -o -name '*.dmg' -o -name '*.app.tar.gz' -o -name '*.sig' \) \
-exec cp {} "$OUT/" \;
if [ "$RUNNER_OS" = Windows ]; then
cp target/release/devnotes.exe "$OUT/devnotes-$version-windows.exe"
else
elif [ "$RUNNER_OS" = Linux ]; then
cp target/release/devnotes "$OUT/devnotes-$version-linux"
fi
ls -l "$OUT"
16 changes: 14 additions & 2 deletions .github/scripts/installed.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# Whether version $1 is the one installed by `packages.yml`: the AppImage in place is that
# version's file (Linux), or the per-user install says that version (Windows). An update under
# Windows finishes in an installer of its own: waited for, two minutes at most.
# version's file (Linux), the application says that version and is whole (macOS), or the per-user
# install says it (Windows). An update under Windows finishes in an installer of its own: waited for,
# two minutes at most.
set -euo pipefail
expected=$1
case "$expected" in
Expand All @@ -22,6 +23,17 @@ if [ "$RUNNER_OS" = Linux ]; then
exit 0
fi

if [ "$RUNNER_OS" = macOS ]; then
app="$RUNNER_TEMP/installed/DevNotes.app"
found=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$app/Contents/Info.plist")
if [ "$found" != "$expected" ] || [ ! -x "$app/Contents/MacOS/devnotes" ]; then
echo "::error::the application in place is '$found', expected $expected"
exit 1
fi
echo "installed: $expected"
exit 0
fi

# The uninstall entry the NSIS installer writes under HKCU, a field of it.
entry() {
pwsh -NoProfile -Command "(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' -ErrorAction SilentlyContinue | Where-Object DisplayName -eq 'DevNotes').$1" | tr -d '\r"'
Expand Down
23 changes: 23 additions & 0 deletions .github/scripts/largest-screen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// A macOS runner's screen is smaller than the window the scenarios resize, and AppKit keeps a
// window inside its screen: the largest mode the display offers, for the session.
import CoreGraphics

let display = CGMainDisplayID()
let options = [kCGDisplayShowDuplicateLowResolutionModes: kCFBooleanTrue] as CFDictionary
let modes = CGDisplayCopyAllDisplayModes(display, options) as? [CGDisplayMode] ?? []
for mode in modes {
print("\(mode.width)x\(mode.height), drawn at \(mode.pixelWidth)x\(mode.pixelHeight)")
}

func area(_ mode: CGDisplayMode) -> Int { mode.width * mode.height }
guard let largest = modes.max(by: { area($0) < area($1) }) else {
fatalError("the display names no mode")
}

// `CGDisplaySetDisplayMode` would last as long as this script.
var configuration: CGDisplayConfigRef?
CGBeginDisplayConfiguration(&configuration)
CGConfigureDisplayWithDisplayMode(configuration, display, largest, nil)
let result = CGCompleteDisplayConfiguration(configuration, .forSession)
print("taken: \(largest.width)x\(largest.height), \(result == .success ? "done" : "refused")")
print("now: \(CGDisplayBounds(display).size)")
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, windows-latest]
os: [ubuntu-22.04, windows-latest, macos-latest]

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:
echo "\`test-rust\` (${{ matrix.os }}) — $(($(date +%s) - start)) s" >> "$GITHUB_STEP_SUMMARY"

- name: Test
if: runner.os == 'Windows'
if: runner.os != 'Linux'
run: |
start=$(date +%s)

Expand Down Expand Up @@ -313,7 +313,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, windows-latest]
os: [ubuntu-22.04, windows-latest, macos-latest]

# The flavour in `target/debug`, where the cache is: nothing else builds `app` in this job.
env:
Expand All @@ -333,6 +333,10 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get install -y --no-install-recommends xvfb

- name: A screen larger than the window
if: runner.os == 'macOS'
run: swift .github/scripts/largest-screen.swift

- name: Build the flavour
run: cargo build -p app --features e2e --locked

Expand All @@ -354,7 +358,8 @@ jobs:
{
echo "\`e2e\` (${{ matrix.os }}) — $(($(date +%s) - start)) s"
echo
sed 's/\x1b\[[0-9;]*m//g' "$output" | awk '
# perl: macOS's sed knows no \x1b.
perl -pe 's/\x1b\[[0-9;]*m//g' "$output" | awk '
match($0, /tests.[0-9a-z_]+\.rs/) { name = substr($0, RSTART + 6, RLENGTH - 9); order[++n] = name; next }
/Doc-tests/ { name = "" }
/^▶ / { steps[name]++ }
Expand All @@ -365,7 +370,7 @@ jobs:
for (i = 1; i <= n; i++) {
k = order[i]
sub(/\.$/, "", result[k])
printf "| `%s` | %d | %s | %s |\n", k, steps[k], result[k] == "" ? "not run" : result[k], time[k]
printf "| `%s` | %d | %s | %s |\n", k, steps[k], (result[k] == "" ? "not run" : result[k]), time[k]
}
}'
} >> "$GITHUB_STEP_SUMMARY"
Expand Down
30 changes: 24 additions & 6 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest]
os: [ubuntu-22.04, windows-latest, macos-latest, macos-15-intel]
env:
SERVED: ${{ github.workspace }}/served
ORIGIN: http://127.0.0.1:8765
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:

# The one line of `[workspace.package]` that starts with `version`; Cargo.lock follows.
- name: Version 1.0.0
run: sed -i 's/^version = ".*"/version = "1.0.0"/' Cargo.toml && cargo metadata --format-version 1 > /dev/null
run: perl -pi -e 's/^version = ".*"/version = "1.0.0"/' Cargo.toml && cargo metadata --format-version 1 > /dev/null

- uses: ./.github/actions/package
with:
Expand All @@ -86,7 +86,7 @@ jobs:
out: old

- name: Version 1.0.1
run: sed -i 's/^version = ".*"/version = "1.0.1"/' Cargo.toml && cargo metadata --format-version 1 > /dev/null
run: perl -pi -e 's/^version = ".*"/version = "1.0.1"/' Cargo.toml && cargo metadata --format-version 1 > /dev/null

- uses: ./.github/actions/package
with:
Expand All @@ -103,7 +103,7 @@ jobs:
mkdir -p "$SERVED/$kind"
cp new/* "$SERVED/$kind/"
# The manifest script refuses a release without Windows: a stand-in, never fetched.
if [ "$RUNNER_OS" = Linux ]; then
if [ "$RUNNER_OS" != Windows ]; then
echo stand-in > "$SERVED/$kind/devnotes_1.0.1_x64-setup.exe"
echo stand-in > "$SERVED/$kind/devnotes_1.0.1_x64-setup.exe.sig"
fi
Expand All @@ -112,6 +112,8 @@ jobs:
done
if [ "$RUNNER_OS" = Windows ]; then
package=$(ls "$SERVED/altered" | grep -- '-setup\.exe$')
elif [ "$RUNNER_OS" = macOS ]; then
package=$(ls "$SERVED/altered" | grep '\.app\.tar\.gz$')
else
package=$(ls "$SERVED/altered" | grep '\.AppImage$')
fi
Expand All @@ -126,17 +128,33 @@ jobs:
run: |
if [ "$RUNNER_OS" = Windows ]; then
pwsh -NoProfile -Command "Start-Process '$(cygpath -w "$(ls old/*-setup.exe)")' -ArgumentList '/S' -Wait"
elif [ "$RUNNER_OS" = macOS ]; then
# Copied from the image, as a person drags it.
mkdir -p "$RUNNER_TEMP/installed"
{ yes 2> /dev/null || true; } | PAGER=cat hdiutil attach -nobrowse -readonly -mountpoint "$RUNNER_TEMP/image" "$(ls old/*.dmg)" > /dev/null
ditto "$RUNNER_TEMP/image/DevNotes.app" "$RUNNER_TEMP/installed/DevNotes.app"
hdiutil detach "$RUNNER_TEMP/image" > /dev/null
else
mkdir -p "$RUNNER_TEMP/installed"
cp old/*.AppImage "$RUNNER_TEMP/installed/DevNotes.AppImage"
chmod +x "$RUNNER_TEMP/installed/DevNotes.AppImage"
fi
.github/scripts/installed.sh 1.0.0

# What replaces a macOS application is found beside the executable that runs.
- name: The updater, where it runs from
run: |
updater=target/release/examples/update
if [ "$RUNNER_OS" = macOS ]; then
cp "$updater" "$RUNNER_TEMP/installed/DevNotes.app/Contents/MacOS/update"
updater="$RUNNER_TEMP/installed/DevNotes.app/Contents/MacOS/update"
fi
echo "UPDATER=$updater" >> "$GITHUB_ENV"

- name: The altered 1.0.1 is refused, 1.0.0 stays
run: |
set +e
APPIMAGE="$RUNNER_TEMP/installed/DevNotes.AppImage" target/release/examples/update 1.0.0 \
APPIMAGE="$RUNNER_TEMP/installed/DevNotes.AppImage" "$UPDATER" 1.0.0 \
"$ORIGIN/altered/latest.json" '${{ steps.key.outputs.public }}'
status=$?
set -e
Expand All @@ -148,7 +166,7 @@ jobs:

- name: The whole 1.0.1 is installed
run: |
APPIMAGE="$RUNNER_TEMP/installed/DevNotes.AppImage" target/release/examples/update 1.0.0 \
APPIMAGE="$RUNNER_TEMP/installed/DevNotes.AppImage" "$UPDATER" 1.0.0 \
"$ORIGIN/whole/latest.json" '${{ steps.key.outputs.public }}'
.github/scripts/installed.sh 1.0.1

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ jobs:
environment: release
runs-on: ${{ matrix.os }}
timeout-minutes: 60
# ⚠️ The tag is out by now: a macOS leg that fails must not leave it without a release.
continue-on-error: ${{ startsWith(matrix.target, 'macos') }}
defaults:
run:
shell: bash
Expand All @@ -228,6 +230,10 @@ jobs:
target: linux
- os: windows-latest
target: windows
- os: macos-latest
target: macos-aarch64
- os: macos-15-intel
target: macos-x64
steps:
# The SHA rather than the tag name: the tag was just created by `prepare`, and a SHA
# cannot come to mean something else in between.
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Principles:
- Node is only a build tool: `npm install` · `npm run lint` (Prettier over Markdown, JSON, YAML; `format` writes) · `npm run test:scripts` (⚠️ test files are named one by one in `package.json`; add new ones there) · `cargo run -p app --example icons` (writes `crates/app/icons/`; ⚠️ small `.ico` sizes come from `icons/source/`) · `npm run prettier` (copies the pinned Prettier into `crates/text/prettier/`, the formatter compiled in). The request-script libraries are bundled by `crates/engine/sandbox/build.mjs`, from that folder's own `package.json`.
- Website (`website/`, Angular, devnotes.fr; its own `package.json`, outside the Cargo workspace): from `website/`, `npm ci` · `npm start` (port 4300) · `npm run build` (fetches the latest release, prerenders to `website/dist/`, checks every page and its download links) · `npm test` · `npm run lint` · `npm run test:scripts`. `website.yml` publishes it when `website/` or `docs/content/` changes on `main`, and after each release. → "The website".
- E2E: `cargo build -p app --features e2e --target-dir target/e2e`, then `cargo test -p e2e` (the driver is `e2e/` at the root; all scenarios, one after the other; `--test 01_first_launch` for one; `cargo test --workspace --exclude e2e` otherwise). `01`–`35` are the WebdriverIO scenarios ported, the rest are this application's own. → "The scenarios, on the assembled window".
- Release is a `workflow_dispatch` after a version bump; the version is `[workspace.package] version` in `Cargo.toml` alone (D27), so a bump touches `Cargo.toml` and `Cargo.lock` (`cargo update --workspace`); `scripts/version.mjs` refuses a release where they disagree. `release.yml` builds, packages (`cargo-packager`: NSIS, AppImage, deb; rpm by `cargo-generate-rpm`) and signs; `packages.yml` installs and updates them. ⚠️ A version branch (`dev/x.y.z`) reaches `main` by a merge commit, never a squash: the release notes read what the merge brings. → "Releasing", `docs/releasing.md`.
- Release is a `workflow_dispatch` after a version bump; the version is `[workspace.package] version` in `Cargo.toml` alone (D27), so a bump touches `Cargo.toml` and `Cargo.lock` (`cargo update --workspace`); `scripts/version.mjs` refuses a release where they disagree. `release.yml` builds, packages (`cargo-packager`: NSIS, AppImage, deb, dmg; rpm by `cargo-generate-rpm`) and signs; `packages.yml` installs and updates them. ⚠️ A version branch (`dev/x.y.z`) reaches `main` by a merge commit, never a squash: the release notes read what the merge brings. → "Releasing", `docs/releasing.md`.

## Things that will bite you

Expand Down
Loading
Loading