From 9a74687ce96fd93eb67b14fca2079844c1b35269 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 22:30:33 +0000 Subject: [PATCH] App name: the packages and the CI named from the values `scripts/names.mjs` reads `[workspace.metadata]` for the CI, as `scripts/version.mjs` reads the version. `package.yml` reads the display name and the slug once and hands them to each package action; the release's files are named from the slug, and each action checks the binary, the icon, the desktop entry and the doc paths under it. `packages.yml`, `installed.sh` and `close-and-quit.sh` find the installed application, its window and its uninstall entry by the names. The fixtures of `scripts/*.test.mjs` take the slug from the same script. Part of #1896 (step 7) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BbVs5tCyTr9AasGra3Zzg3 --- .github/actions/package/appimage/action.yml | 7 +++- .github/actions/package/deb/action.yml | 20 +++++++--- .github/actions/package/dmg/action.yml | 32 +++++++++++---- .github/actions/package/nsis/action.yml | 7 +++- .github/actions/package/rpm/action.yml | 22 ++++++++--- .github/scripts/close-and-quit.sh | 16 ++++---- .github/scripts/installed.sh | 12 +++--- .github/workflows/package.yml | 18 ++++++++- .github/workflows/packages.yml | 27 +++++++------ docs/architecture/releasing.md | 7 ++++ scripts/architecture-links.test.mjs | 2 +- scripts/latest-json.test.mjs | 43 ++++++++++++--------- scripts/names.mjs | 43 +++++++++++++++++++++ scripts/names.test.mjs | 36 +++++++++++++++++ scripts/release-preview.test.mjs | 15 ++++--- 15 files changed, 235 insertions(+), 72 deletions(-) create mode 100755 scripts/names.mjs create mode 100644 scripts/names.test.mjs diff --git a/.github/actions/package/appimage/action.yml b/.github/actions/package/appimage/action.yml index f4eeb18de..2d3f030ae 100644 --- a/.github/actions/package/appimage/action.yml +++ b/.github/actions/package/appimage/action.yml @@ -5,6 +5,9 @@ description: >- `out`. inputs: + slug: + description: The application's slug (`scripts/names.mjs`), which names its binary and its files. + required: true private-key: description: The minisign key that signs the package. required: true @@ -43,10 +46,12 @@ runs: - name: It holds the application alone shell: bash + env: + SLUG: ${{ inputs.slug }} run: | binaries=$(ls target/packages/appimage/squashfs-root/usr/bin) echo "$binaries" - test "$binaries" = devnotes + test "$binaries" = "$SLUG" - name: It carries the icon shell: bash diff --git a/.github/actions/package/deb/action.yml b/.github/actions/package/deb/action.yml index e0b5136e2..c29b41a75 100644 --- a/.github/actions/package/deb/action.yml +++ b/.github/actions/package/deb/action.yml @@ -4,6 +4,9 @@ description: >- its icon, its licence and this version's notes, no GTK. Gathered with its signature into `out`. inputs: + slug: + description: The application's slug (`scripts/names.mjs`), which names its binary and its files. + required: true version: description: The version the package carries. required: true @@ -29,27 +32,32 @@ runs: - name: It holds the application alone shell: bash + env: + SLUG: ${{ inputs.slug }} run: | binaries=$(dpkg-deb -c target/packages/deb/*.deb | awk '$6 ~ /^usr\/bin\/./ { print $6 }') echo "$binaries" - test "$binaries" = usr/bin/devnotes + test "$binaries" = "usr/bin/$SLUG" - name: It carries the icon shell: bash + env: + SLUG: ${{ inputs.slug }} run: | files=$(dpkg-deb -c target/packages/deb/*.deb | awk '{ print $6 }') - grep -qx usr/share/icons/hicolor/512x512/apps/devnotes.png <<< "$files" - entry=$(dpkg-deb --fsys-tarfile target/packages/deb/*.deb | tar -xO usr/share/applications/devnotes.desktop) - grep -qx Icon=devnotes <<< "$entry" + grep -qx "usr/share/icons/hicolor/512x512/apps/$SLUG.png" <<< "$files" + entry=$(dpkg-deb --fsys-tarfile target/packages/deb/*.deb | tar -xO "usr/share/applications/$SLUG.desktop") + grep -qx "Icon=$SLUG" <<< "$entry" - name: It carries the licence and this version's notes shell: bash env: VERSION: ${{ inputs.version }} + SLUG: ${{ inputs.slug }} run: | files=$(dpkg-deb -c target/packages/deb/*.deb | awk '{ print $6 }') - grep -qx usr/share/doc/devnotes/copyright <<< "$files" - shipped=$(dpkg-deb --fsys-tarfile target/packages/deb/*.deb | tar -xO usr/share/doc/devnotes/changelog.gz | gunzip) + grep -qx "usr/share/doc/$SLUG/copyright" <<< "$files" + shipped=$(dpkg-deb --fsys-tarfile target/packages/deb/*.deb | tar -xO "usr/share/doc/$SLUG/changelog.gz" | gunzip) test "$shipped" = "$(node scripts/release-notes.mjs extract --version "$VERSION")" - name: It depends on no GTK diff --git a/.github/actions/package/dmg/action.yml b/.github/actions/package/dmg/action.yml index ae9f4df17..163fd592f 100644 --- a/.github/actions/package/dmg/action.yml +++ b/.github/actions/package/dmg/action.yml @@ -5,6 +5,12 @@ description: >- into `out`. inputs: + name: + description: The application's display name (`scripts/names.mjs`), which names the bundle. + required: true + slug: + description: The application's slug (`scripts/names.mjs`), which names its binary and its files. + required: true version: description: The version the packages carry. required: true @@ -26,11 +32,12 @@ runs: env: CARGO_PACKAGER_SIGN_PRIVATE_KEY: ${{ inputs.private-key }} CARGO_PACKAGER_SIGN_PRIVATE_KEY_PASSWORD: ${{ inputs.password }} + NAME: ${{ inputs.name }} run: | for attempt in 1 2 3; do cargo packager -p app --release -f app,dmg -o "$GITHUB_WORKSPACE/target/packages/dmg" && exit 0 echo "attempt $attempt failed" - hdiutil detach /Volumes/DevNotes -force > /dev/null 2>&1 || true + hdiutil detach "/Volumes/$NAME" -force > /dev/null 2>&1 || true rm -rf target/packages/dmg sleep 15 done @@ -41,36 +48,45 @@ runs: working-directory: target/packages/dmg env: VERSION: ${{ inputs.version }} + NAME: ${{ inputs.name }} + SLUG: ${{ inputs.slug }} run: | arch=$([ "$RUNNER_ARCH" = ARM64 ] && echo aarch64 || echo x64) for ending in dmg dmg.sig; do - mv "DevNotes_${VERSION}_$arch.$ending" "devnotes_${VERSION}_$arch.$ending" + mv "${NAME}_${VERSION}_$arch.$ending" "${SLUG}_${VERSION}_$arch.$ending" done for ending in app.tar.gz app.tar.gz.sig; do - mv "DevNotes.$ending" "devnotes_${VERSION}_$arch.$ending" + mv "$NAME.$ending" "${SLUG}_${VERSION}_$arch.$ending" done - name: It is signed ad hoc shell: bash - run: codesign --verify --deep --strict target/packages/dmg/DevNotes.app + env: + NAME: ${{ inputs.name }} + run: codesign --verify --deep --strict "target/packages/dmg/$NAME.app" - name: It holds the application alone shell: bash + env: + NAME: ${{ inputs.name }} + SLUG: ${{ inputs.slug }} run: | archived=$(tar -tzf target/packages/dmg/*.app.tar.gz | grep '/Contents/MacOS/.' | xargs -n1 basename) echo "archive: $archived" - test "$archived" = devnotes + test "$archived" = "$SLUG" mounted="$RUNNER_TEMP/image" { yes 2> /dev/null || true; } | PAGER='cat' hdiutil attach -nobrowse -readonly -mountpoint "$mounted" target/packages/dmg/*.dmg > /dev/null - imaged=$(ls "$mounted/DevNotes.app/Contents/MacOS") + imaged=$(ls "$mounted/$NAME.app/Contents/MacOS") hdiutil detach "$mounted" > /dev/null echo "image: $imaged" - test "$imaged" = devnotes + test "$imaged" = "$SLUG" - name: It carries the icon shell: bash + env: + NAME: ${{ inputs.name }} run: | - app=target/packages/dmg/DevNotes.app/Contents + app="target/packages/dmg/$NAME.app/Contents" icon=$(plutil -extract CFBundleIconFile raw "$app/Info.plist") test -e "$app/Resources/$icon" grep -q "/Contents/Resources/$icon$" <<< "$(tar -tzf target/packages/dmg/*.app.tar.gz)" diff --git a/.github/actions/package/nsis/action.yml b/.github/actions/package/nsis/action.yml index 4ede494a6..9cf904f75 100644 --- a/.github/actions/package/nsis/action.yml +++ b/.github/actions/package/nsis/action.yml @@ -4,6 +4,9 @@ description: >- install the application alone. Gathered with its signature into `out`. inputs: + slug: + description: The application's slug (`scripts/names.mjs`), which names its binary and its files. + required: true private-key: description: The minisign key that signs the installer. required: true @@ -26,13 +29,15 @@ runs: - name: It installs the application alone shell: bash + env: + SLUG: ${{ inputs.slug }} run: | installer=$(cygpath -w target/packages/nsis/*-setup.exe) folder=$(cygpath -w "$RUNNER_TEMP/installed") pwsh -NoProfile -Command "Start-Process '$installer' -ArgumentList '/S','/D=$folder' -Wait" executables=$(find "$RUNNER_TEMP/installed" -maxdepth 1 -name '*.exe' -printf '%f\n' | sort | xargs) echo "$executables" - test "$executables" = 'devnotes.exe uninstall.exe' + test "$executables" = "$SLUG.exe uninstall.exe" - name: Gather shell: bash diff --git a/.github/actions/package/rpm/action.yml b/.github/actions/package/rpm/action.yml index 417794b3b..7a2b9d195 100644 --- a/.github/actions/package/rpm/action.yml +++ b/.github/actions/package/rpm/action.yml @@ -4,6 +4,9 @@ description: >- icon, its licence and this version's notes. Gathered with its signature into `out`. inputs: + slug: + description: The application's slug (`scripts/names.mjs`), which names its binary and its files. + required: true version: description: The version the package carries. required: true @@ -30,7 +33,8 @@ runs: shell: bash env: VERSION: ${{ inputs.version }} - run: cargo generate-rpm -p crates/app -o "target/packages/rpm/devnotes-$VERSION.x86_64.rpm" + SLUG: ${{ inputs.slug }} + run: cargo generate-rpm -p crates/app -o "target/packages/rpm/$SLUG-$VERSION.x86_64.rpm" - name: Sign shell: bash @@ -41,23 +45,29 @@ runs: - name: It holds the application alone shell: bash + env: + SLUG: ${{ inputs.slug }} run: | binaries=$(rpm -qlp target/packages/rpm/*.rpm | grep '^/usr/bin/') echo "$binaries" - test "$binaries" = /usr/bin/devnotes + test "$binaries" = "/usr/bin/$SLUG" - name: It carries the icon shell: bash + env: + SLUG: ${{ inputs.slug }} run: | files=$(rpm -qlp target/packages/rpm/*.rpm) - grep -qx /usr/share/icons/hicolor/512x512/apps/devnotes.png <<< "$files" - grep -qx /usr/share/applications/devnotes.desktop <<< "$files" + grep -qx "/usr/share/icons/hicolor/512x512/apps/$SLUG.png" <<< "$files" + grep -qx "/usr/share/applications/$SLUG.desktop" <<< "$files" - name: It carries the licence and this version's notes shell: bash + env: + SLUG: ${{ inputs.slug }} run: | - grep -qx /usr/share/licenses/devnotes/LICENSE <<< "$(rpm -qlp target/packages/rpm/*.rpm)" - grep -qx /usr/share/doc/devnotes/changelog.gz <<< "$(rpm -qdp target/packages/rpm/*.rpm)" + grep -qx "/usr/share/licenses/$SLUG/LICENSE" <<< "$(rpm -qlp target/packages/rpm/*.rpm)" + grep -qx "/usr/share/doc/$SLUG/changelog.gz" <<< "$(rpm -qdp target/packages/rpm/*.rpm)" - name: Gather shell: bash diff --git a/.github/scripts/close-and-quit.sh b/.github/scripts/close-and-quit.sh index 17fd5f2f9..0939662ce 100755 --- a/.github/scripts/close-and-quit.sh +++ b/.github/scripts/close-and-quit.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash -# Each command given launches DevNotes as a person would, under the X server and the session bus -# the caller opened: its window opens, its close button hides it and leaves the process running -# (« Close to tray » is on by default, tray icon or not), `--action quit` from a second launch ends -# it with 0, and its terminal shows nothing but Xvfb's own pair about DRI3. +# Each command given launches the application as a person would, under the X server and the +# session bus the caller opened: its window opens, its close button hides it and leaves the process +# running (« Close to tray » is on by default, tray icon or not), `--action quit` from a second +# launch ends it with 0, and its terminal shows nothing but Xvfb's own pair about DRI3. The window +# is found by the application's name (`scripts/names.mjs`). set -euo pipefail +name=$(node scripts/names.mjs display-name) openbox > /dev/null 2>&1 & @@ -23,9 +25,9 @@ for launch in "$@"; do echo "== $launch" $launch --profile "$profile" > /dev/null 2> "$terminal" & pid=$! - until_true "wmctrl -l 2> /dev/null | grep -q DevNotes" "$launch opened no window" - wmctrl -c DevNotes - until_true "! wmctrl -l 2> /dev/null | grep -q DevNotes" "$launch kept its window after the close button" + until_true "wmctrl -l 2> /dev/null | grep -qF '$name'" "$launch opened no window" + wmctrl -c "$name" + until_true "! wmctrl -l 2> /dev/null | grep -qF '$name'" "$launch kept its window after the close button" if ! kill -0 "$pid" 2> /dev/null; then echo "::error::$launch ended at the close button" exit 1 diff --git a/.github/scripts/installed.sh b/.github/scripts/installed.sh index 9f253b6a4..622b704d2 100755 --- a/.github/scripts/installed.sh +++ b/.github/scripts/installed.sh @@ -5,6 +5,8 @@ # two minutes at most. set -euo pipefail expected=$1 +name=$(node scripts/names.mjs display-name) +slug=$(node scripts/names.mjs slug) case "$expected" in 1.0.0) packages=old ;; 1.0.1) packages=new ;; @@ -12,7 +14,7 @@ case "$expected" in esac if [ "$RUNNER_OS" = Linux ]; then - installed="$RUNNER_TEMP/installed/DevNotes.AppImage" + installed="$RUNNER_TEMP/installed/$name.AppImage" want=$(sha256sum "$packages"/*.AppImage | cut -d' ' -f1) have=$(sha256sum "$installed" | cut -d' ' -f1) if [ "$want" != "$have" ] || [ ! -x "$installed" ]; then @@ -24,9 +26,9 @@ if [ "$RUNNER_OS" = Linux ]; then fi if [ "$RUNNER_OS" = macOS ]; then - app="$RUNNER_TEMP/installed/DevNotes.app" + app="$RUNNER_TEMP/installed/$name.app" found=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$app/Contents/Info.plist") - if [ "$found" != "$expected" ] || [ ! -x "$app/Contents/MacOS/devnotes" ]; then + if [ "$found" != "$expected" ] || [ ! -x "$app/Contents/MacOS/$slug" ]; then echo "::error::the application in place is '$found', expected $expected" exit 1 fi @@ -36,12 +38,12 @@ 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"' + pwsh -NoProfile -Command "(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' -ErrorAction SilentlyContinue | Where-Object DisplayName -eq '$name').$1" | tr -d '\r"' } for _ in $(seq 1 120); do found=$(entry DisplayVersion) folder=$(entry InstallLocation) - if [ "$found" = "$expected" ] && [ -f "$folder/devnotes.exe" ]; then + if [ "$found" = "$expected" ] && [ -f "$folder/$slug.exe" ]; then echo "installed: $expected in $folder" exit 0 fi diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a70ec9626..56e00babb 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -87,6 +87,12 @@ jobs: version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "app") | .version') echo "version=$version" >> "$GITHUB_OUTPUT" + - name: Read the names + id: names + run: | + echo "name=$(node scripts/names.mjs display-name)" >> "$GITHUB_OUTPUT" + echo "slug=$(node scripts/names.mjs slug)" >> "$GITHUB_OUTPUT" + - name: The run's signing key if: inputs.environment == '' uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8 @@ -125,6 +131,7 @@ jobs: if: matrix.system == 'linux' uses: ./.github/actions/package/deb with: + slug: ${{ steps.names.outputs.slug }} version: ${{ steps.version.outputs.version }} private-key: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY || env.RUN_KEY }} password: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} @@ -134,6 +141,7 @@ jobs: if: matrix.system == 'linux' uses: ./.github/actions/package/rpm with: + slug: ${{ steps.names.outputs.slug }} version: ${{ steps.version.outputs.version }} private-key: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY || env.RUN_KEY }} password: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} @@ -143,6 +151,7 @@ jobs: if: matrix.system == 'linux' uses: ./.github/actions/package/appimage with: + slug: ${{ steps.names.outputs.slug }} private-key: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY || env.RUN_KEY }} password: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} out: dist @@ -151,6 +160,7 @@ jobs: if: matrix.system == 'windows' uses: ./.github/actions/package/nsis with: + slug: ${{ steps.names.outputs.slug }} private-key: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY || env.RUN_KEY }} password: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} out: dist @@ -159,6 +169,8 @@ jobs: if: startsWith(matrix.system, 'macos') uses: ./.github/actions/package/dmg with: + name: ${{ steps.names.outputs.name }} + slug: ${{ steps.names.outputs.slug }} version: ${{ steps.version.outputs.version }} private-key: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY || env.RUN_KEY }} password: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} @@ -168,13 +180,15 @@ jobs: if: matrix.system == 'linux' env: VERSION: ${{ steps.version.outputs.version }} - run: cp target/release/devnotes "dist/devnotes-$VERSION-linux" + SLUG: ${{ steps.names.outputs.slug }} + run: cp "target/release/$SLUG" "dist/$SLUG-$VERSION-linux" - name: Standalone executable if: matrix.system == 'windows' env: VERSION: ${{ steps.version.outputs.version }} - run: cp target/release/devnotes.exe "dist/devnotes-$VERSION-windows.exe" + SLUG: ${{ steps.names.outputs.slug }} + run: cp "target/release/$SLUG.exe" "dist/$SLUG-$VERSION-windows.exe" - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 634aa9901..5256608a5 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -94,6 +94,11 @@ jobs: with: node-version-file: website/.nvmrc + - name: Read the names + run: | + echo "APP_NAME=$(node scripts/names.mjs display-name)" >> "$GITHUB_ENV" + echo "APP_SLUG=$(node scripts/names.mjs slug)" >> "$GITHUB_ENV" + - name: The updater run: cargo build -p platform --example update --release --locked @@ -121,8 +126,8 @@ jobs: mkdir -p "$SERVED/$kind" cp new/* "$SERVED/$kind/" 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" + echo stand-in > "$SERVED/$kind/${APP_SLUG}_1.0.1_x64-setup.exe" + echo stand-in > "$SERVED/$kind/${APP_SLUG}_1.0.1_x64-setup.exe.sig" fi node scripts/latest-json.mjs --dir "$SERVED/$kind" --version 1.0.1 \ --base "$ORIGIN/$kind" --notes "$RUNNER_TEMP/notes.md" @@ -146,17 +151,17 @@ jobs: run: | mkdir -p "$RUNNER_TEMP/installed" { yes 2> /dev/null || true; } | PAGER='cat' hdiutil attach -nobrowse -readonly -mountpoint "$RUNNER_TEMP/image" old/*.dmg > /dev/null - ditto "$RUNNER_TEMP/image/DevNotes.app" "$RUNNER_TEMP/installed/DevNotes.app" + ditto "$RUNNER_TEMP/image/$APP_NAME.app" "$RUNNER_TEMP/installed/$APP_NAME.app" hdiutil detach "$RUNNER_TEMP/image" > /dev/null .github/scripts/installed.sh 1.0.0 - name: A clean install of 1.0.0 if: runner.os == 'Linux' run: | - echo "APPIMAGE=$RUNNER_TEMP/installed/DevNotes.AppImage" >> "$GITHUB_ENV" + echo "APPIMAGE=$RUNNER_TEMP/installed/$APP_NAME.AppImage" >> "$GITHUB_ENV" mkdir -p "$RUNNER_TEMP/installed" - cp old/*.AppImage "$RUNNER_TEMP/installed/DevNotes.AppImage" - chmod +x "$RUNNER_TEMP/installed/DevNotes.AppImage" + cp old/*.AppImage "$RUNNER_TEMP/installed/$APP_NAME.AppImage" + chmod +x "$RUNNER_TEMP/installed/$APP_NAME.AppImage" .github/scripts/installed.sh 1.0.0 - name: The Linux packages open, close to the tray and quit cleanly @@ -166,7 +171,7 @@ jobs: run: | sudo apt-get install -y --no-install-recommends dbus xvfb openbox wmctrl sudo apt-get install -y "$GITHUB_WORKSPACE/$(echo old/*.deb)" - dbus-run-session -- xvfb-run -a .github/scripts/close-and-quit.sh devnotes "$APPIMAGE" + dbus-run-session -- xvfb-run -a .github/scripts/close-and-quit.sh "$APP_SLUG" "$APPIMAGE" - name: Without a renderer the AppImage says so and ends cleanly if: runner.os == 'Linux' @@ -186,8 +191,8 @@ jobs: 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" + cp "$updater" "$RUNNER_TEMP/installed/$APP_NAME.app/Contents/MacOS/update" + updater="$RUNNER_TEMP/installed/$APP_NAME.app/Contents/MacOS/update" fi echo "UPDATER=$updater" >> "$GITHUB_ENV" echo "PUBLIC_KEY=$(cat "$RUNNER_TEMP/signing-key/key.pub")" >> "$GITHUB_ENV" @@ -209,8 +214,8 @@ jobs: - name: Uninstall if: always() && runner.os == 'Windows' run: | - taskkill //IM devnotes.exe //F 2> /dev/null || true - folder=$(pwsh -NoProfile -Command "(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' -ErrorAction SilentlyContinue | Where-Object DisplayName -eq 'DevNotes').InstallLocation" | tr -d '\r"') + taskkill //IM "$APP_SLUG.exe" //F 2> /dev/null || true + folder=$(pwsh -NoProfile -Command "(Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' -ErrorAction SilentlyContinue | Where-Object DisplayName -eq '$APP_NAME').InstallLocation" | tr -d '\r"') if [ -f "$folder/uninstall.exe" ]; then pwsh -NoProfile -Command "Start-Process '$(cygpath -w "$folder/uninstall.exe")' -ArgumentList '/S' -Wait" fi diff --git a/docs/architecture/releasing.md b/docs/architecture/releasing.md index 4ea575e12..6aebc9470 100644 --- a/docs/architecture/releasing.md +++ b/docs/architecture/releasing.md @@ -101,6 +101,13 @@ by one byte and installs the whole one through the application's own updater cli **One version** (D27): `[workspace.package] version`, which every crate inherits; `scripts/version.mjs` refuses a release where `Cargo.lock` says otherwise. +**The names the CI uses** (D36) are read the same way, by `scripts/names.mjs` (`node +scripts/names.mjs slug`): `package.yml` reads the display name and the slug once and hands them to +each action as inputs, and the files of a release are named from the slug +(`__…`, `--linux`); `packages.yml`, `installed.sh` and +`close-and-quit.sh` find the installed application, its window and its uninstall entry by them. The +fixtures of `scripts/*.test.mjs` take the slug from the same script. + What `prepare` does **not** do is rerun the suites. It checks that `ci.yml` concluded `success` on the very commit being released and stops if it did not; the work was already done, and a release that replayed it would pay for it twice. diff --git a/scripts/architecture-links.test.mjs b/scripts/architecture-links.test.mjs index e219c5877..decf6b778 100644 --- a/scripts/architecture-links.test.mjs +++ b/scripts/architecture-links.test.mjs @@ -119,7 +119,7 @@ describe('architecture links', () => { }); it('refuses a link into the wiki from elsewhere that leads nowhere, and leaves other links alone', () => { - const readme = '[Architecture](docs/architecture.md) · [Code](crates/) · [Site](https://devnotes.fr)\n'; + const readme = '[Architecture](docs/architecture.md) · [Code](crates/) · [Site](https://example.org)\n'; assert.deepEqual(check(files({ 'README.md': readme })), [ 'README.md:1: the link docs/architecture.md leads nowhere', diff --git a/scripts/latest-json.test.mjs b/scripts/latest-json.test.mjs index 54facc195..cb516cf97 100644 --- a/scripts/latest-json.test.mjs +++ b/scripts/latest-json.test.mjs @@ -1,24 +1,29 @@ import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; import { describe, it } from 'node:test'; import { manifest } from './latest-json.mjs'; +import { name } from './names.mjs'; + +/** The names of the release's files begin with the application's slug. */ +const SLUG = name(readFileSync('Cargo.toml', 'utf8'), 'slug'); const SIGNATURES = { - 'devnotes_1.0.1_x64-setup.exe.sig': 'sig-nsis\n', - 'devnotes_1.0.1_x86_64.AppImage.sig': 'sig-appimage\n', - 'devnotes_1.0.1_amd64.deb.sig': 'sig-deb\n', - 'devnotes_1.0.1_aarch64.app.tar.gz.sig': 'sig-arm\n', - 'devnotes_1.0.1_aarch64.dmg.sig': 'sig-dmg\n', - 'devnotes_1.0.1_x64.app.tar.gz.sig': 'sig-intel\n', + [`${SLUG}_1.0.1_x64-setup.exe.sig`]: 'sig-nsis\n', + [`${SLUG}_1.0.1_x86_64.AppImage.sig`]: 'sig-appimage\n', + [`${SLUG}_1.0.1_amd64.deb.sig`]: 'sig-deb\n', + [`${SLUG}_1.0.1_aarch64.app.tar.gz.sig`]: 'sig-arm\n', + [`${SLUG}_1.0.1_aarch64.dmg.sig`]: 'sig-dmg\n', + [`${SLUG}_1.0.1_x64.app.tar.gz.sig`]: 'sig-intel\n', }; const RELEASE = [ - 'devnotes_1.0.1_x64-setup.exe', - 'devnotes_1.0.1_x86_64.AppImage', - 'devnotes_1.0.1_amd64.deb', - 'devnotes_1.0.1_aarch64.app.tar.gz', - 'devnotes_1.0.1_aarch64.dmg', - 'devnotes_1.0.1_x64.app.tar.gz', - 'devnotes-1.0.1-windows.exe', + `${SLUG}_1.0.1_x64-setup.exe`, + `${SLUG}_1.0.1_x86_64.AppImage`, + `${SLUG}_1.0.1_amd64.deb`, + `${SLUG}_1.0.1_aarch64.app.tar.gz`, + `${SLUG}_1.0.1_aarch64.dmg`, + `${SLUG}_1.0.1_x64.app.tar.gz`, + `${SLUG}-1.0.1-windows.exe`, ...Object.keys(SIGNATURES), ]; @@ -45,26 +50,26 @@ describe('latest.json', () => { 'windows-x86_64': { format: 'nsis', signature: 'sig-nsis', - url: 'https://example.org/download/v1.0.1/devnotes_1.0.1_x64-setup.exe', + url: `https://example.org/download/v1.0.1/${SLUG}_1.0.1_x64-setup.exe`, }, 'linux-x86_64': { format: 'appimage', signature: 'sig-appimage', - url: 'https://example.org/download/v1.0.1/devnotes_1.0.1_x86_64.AppImage', + url: `https://example.org/download/v1.0.1/${SLUG}_1.0.1_x86_64.AppImage`, }, 'macos-aarch64': { format: 'app', signature: 'sig-arm', - url: 'https://example.org/download/v1.0.1/devnotes_1.0.1_aarch64.app.tar.gz', + url: `https://example.org/download/v1.0.1/${SLUG}_1.0.1_aarch64.app.tar.gz`, }, 'macos-x86_64': { format: 'app', signature: 'sig-intel', - url: 'https://example.org/download/v1.0.1/devnotes_1.0.1_x64.app.tar.gz', + url: `https://example.org/download/v1.0.1/${SLUG}_1.0.1_x64.app.tar.gz`, }, }, }); - assert.deepEqual(ignored, ['devnotes_1.0.1_amd64.deb', 'devnotes_1.0.1_aarch64.dmg']); + assert.deepEqual(ignored, [`${SLUG}_1.0.1_amd64.deb`, `${SLUG}_1.0.1_aarch64.dmg`]); }); it('never takes the standalone executable for the installer', () => { @@ -74,7 +79,7 @@ describe('latest.json', () => { }); it('refuses a signature without its file', () => { - assert.throws(() => build(RELEASE.filter((name) => name !== 'devnotes_1.0.1_amd64.deb')), /orphan/); + assert.throws(() => build(RELEASE.filter((name) => name !== `${SLUG}_1.0.1_amd64.deb`)), /orphan/); }); it('refuses a release without its Windows installer', () => { diff --git a/scripts/names.mjs b/scripts/names.mjs new file mode 100755 index 000000000..988f60f4a --- /dev/null +++ b/scripts/names.mjs @@ -0,0 +1,43 @@ +#!/usr/bin/env node +// The application's names (D36): `[workspace.metadata]` in the root Cargo.toml, which +// `crates/brand` reads for the code. The CI reads them here, as it reads the version from +// `version.mjs`: `node scripts/names.mjs slug`. + +import { readFileSync } from 'node:fs'; +import { pathToFileURL } from 'node:url'; + +/** Every `key = "value"` of `[workspace.metadata]`; empty when the section is not there. */ +export function workspaceNames(cargoToml) { + const names = {}; + let inside = false; + for (const line of cargoToml.split('\n')) { + const header = line.match(/^\s*\[([^\]]+)\]\s*$/); + if (header) { + inside = header[1].trim() === 'workspace.metadata'; + continue; + } + const value = inside && line.match(/^\s*([a-z-]+)\s*=\s*"([^"]*)"/); + if (value) { + names[value[1]] = value[2]; + } + } + return names; +} + +/** The value of `key`; throws when the manifest has none. */ +export function name(cargoToml, key) { + const value = workspaceNames(cargoToml)[key]; + if (value === undefined) { + throw new Error(`no ${key} in [workspace.metadata] of Cargo.toml`); + } + return value; +} + +if (import.meta.url === pathToFileURL(process.argv[1]).href) { + try { + console.log(name(readFileSync('Cargo.toml', 'utf8'), process.argv[2])); + } catch (error) { + console.error(`::error::${error.message}`); + process.exit(1); + } +} diff --git a/scripts/names.test.mjs b/scripts/names.test.mjs new file mode 100644 index 000000000..b258f9015 --- /dev/null +++ b/scripts/names.test.mjs @@ -0,0 +1,36 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { describe, it } from 'node:test'; + +import { name, workspaceNames } from './names.mjs'; + +const TOML = `[workspace] +members = ["crates/app"] + +[workspace.package] +version = "1.2.3" + +[workspace.metadata] +display-name = "Some App" +slug = "some-app" + +[workspace.dependencies] +slug = { version = "1" } +`; + +describe('names', () => { + it('reads every value of [workspace.metadata], and nothing outside it', () => { + assert.deepEqual(workspaceNames(TOML), { 'display-name': 'Some App', slug: 'some-app' }); + }); + + it('refuses a name the manifest does not hold', () => { + assert.equal(name(TOML, 'slug'), 'some-app'); + assert.throws(() => name(TOML, 'site'), /no site in \[workspace.metadata\]/); + }); + + it('reads the six names of the repository', () => { + const names = workspaceNames(readFileSync('Cargo.toml', 'utf8')); + const keys = ['display-name', 'author-handle', 'slug', 'identifier', 'file-extension', 'site']; + assert.deepEqual(Object.keys(names).sort(), keys.sort()); + }); +}); diff --git a/scripts/release-preview.test.mjs b/scripts/release-preview.test.mjs index 1115ad32d..bb080f33f 100644 --- a/scripts/release-preview.test.mjs +++ b/scripts/release-preview.test.mjs @@ -1,7 +1,12 @@ import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; import { describe, it } from 'node:test'; import { preview, renamed } from './release-preview.mjs'; +import { name } from './names.mjs'; + +/** The names of the release's files begin with the application's slug. */ +const SLUG = name(readFileSync('Cargo.toml', 'utf8'), 'slug'); const RELEASE = { repo: 'owner/name', @@ -11,16 +16,16 @@ const RELEASE = { subject: 'Website: language button named in full (#1652)', diff: '+## [1.2.0] - 2026-12-01\n+\n+- Tabs: raised (#1)', prompt: '### ✨ Added\n\n- Tabs: raised (#1)\n', - files: ['devnotes-1.2.0-linux', 'latest.json'], + files: [`${SLUG}-1.2.0-linux`, 'latest.json'], }; describe('renamed', () => { it('puts the new version in the names of the last release', () => { - const files = ['devnotes_1.1.0_x64-setup.exe', 'devnotes-1.1.0-linux', 'latest.json']; + const files = [`${SLUG}_1.1.0_x64-setup.exe`, `${SLUG}-1.1.0-linux`, 'latest.json']; assert.deepEqual(renamed(files, '1.1.0', '1.2.0'), [ - 'devnotes_1.2.0_x64-setup.exe', - 'devnotes-1.2.0-linux', + `${SLUG}_1.2.0_x64-setup.exe`, + `${SLUG}-1.2.0-linux`, 'latest.json', ]); }); @@ -36,7 +41,7 @@ describe('preview', () => { '`chore(release): v1.2.0`', '`v1.2.0`, sur ce commit', 'https://github.com/owner/name/compare/v1.1.0...v1.2.0', - '`devnotes-1.2.0-linux`
`latest.json`', + `\`${SLUG}-1.2.0-linux\`
\`latest.json\``, ]) { assert.ok(text.includes(said), said); }