From 999c157b2cbf7613dc50beea286e45bf6abc7c1e Mon Sep 17 00:00:00 2001 From: Fabian Meyer <44942030+dinooo13@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:31:23 +0100 Subject: [PATCH 1/4] Scripts: check-release.sh, a read-only check that a release went out Nothing checked a release once release.yml was green, and a failed cask bump even leaves the run green. The script checks, one line each, the release and its title, that it is the latest, its three files, the SHA-256 three ways, the appcast's version, build, enclosure and length, the EdDSA signature against SUPublicEDKey at the tag, Gatekeeper, the staple, the app inside the read-only mounted DMG and its team, the tap's cask, and the releases/latest/download links. A draft skips what only a published release has; Linux skips what needs macOS and verifies the signature with OpenSSL 3. The exit code is the contract. Co-Authored-By: Claude Opus 5.5 --- scripts/check-release.sh | 359 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100755 scripts/check-release.sh diff --git a/scripts/check-release.sh b/scripts/check-release.sh new file mode 100755 index 0000000..464773a --- /dev/null +++ b/scripts/check-release.sh @@ -0,0 +1,359 @@ +#!/usr/bin/env bash +# Checks that a release went out: the GitHub release, its three files, the +# appcast's version, build and EdDSA signature, the DMG's notarisation and the +# app inside it, the Homebrew cask, and the releases/latest/download links. +# Read only: it reads GitHub and downloads the files into a temporary +# directory, and mounts the DMG read-only and hidden to read the app. It +# never reads local git state, so it runs from any checkout. +# +# Usage: scripts/check-release.sh +# scripts/check-release.sh 0.2.1 +# +# One line per check, PASS, FAIL or SKIP, then a summary. A draft skips what +# only a published release has (latest, cask, latest-download); Linux skips +# what needs macOS (gatekeeper, staple, app) and verifies the signature with +# OpenSSL 3. Exit 0 when nothing failed, 1 when a check failed, 2 on bad +# usage, a missing tool, or gh not signed in. +set -euo pipefail +for arg in "$@"; do + case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac +done + +REPO=dinooo13/pladder +TAP=dinooo13/homebrew-tap +# Sparkle refuses an update signed by another team, and the Accessibility and +# Microphone grants are keyed to it. +TEAM=V2KCT6R76J +BASE="https://github.com/$REPO/releases" + +if [[ $# -ne 1 || ! "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "usage: scripts/check-release.sh , major.minor.patch" >&2 + exit 2 +fi +VERSION="$1" +TAG="v$VERSION" + +darwin=0 +if [[ "$(uname -s)" == Darwin ]]; then darwin=1; fi +tools=(gh curl awk sed) +if [[ "$darwin" -eq 1 ]]; then tools+=(shasum xcrun spctl hdiutil codesign /usr/libexec/PlistBuddy); fi +for tool in "${tools[@]}"; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "check-release.sh: $tool is missing" >&2 + exit 2 + fi +done +if command -v shasum >/dev/null 2>&1; then + sha256() { shasum -a 256 "$1" | cut -d ' ' -f 1; } +elif command -v sha256sum >/dev/null 2>&1; then + sha256() { sha256sum "$1" | cut -d ' ' -f 1; } +else + echo "check-release.sh: neither shasum nor sha256sum is there" >&2 + exit 2 +fi +if ! gh auth status >/dev/null 2>&1; then + echo "check-release.sh: gh is not signed in (gh auth login)" >&2 + exit 2 +fi + +tmp=$(mktemp -d) +mounted=0 +cleanup() { + if [[ "$mounted" -eq 1 ]]; then + hdiutil detach "$tmp/mnt" -quiet 2>/dev/null || hdiutil detach "$tmp/mnt" -force -quiet 2>/dev/null || true + fi + rm -rf "$tmp" +} +trap cleanup EXIT +trap 'exit 1' HUP INT TERM + +passed=0 +failed=0 +skipped_draft=0 +skipped_os=0 +line() { printf '%s %-15s %s\n' "$1" "$2" "$3"; } +pass() { line PASS "$1" "$2"; passed=$((passed + 1)); } +fail() { line FAIL "$1" "$2"; failed=$((failed + 1)); } +skip_draft() { line SKIP "$1" "a draft; checked once it is published"; skipped_draft=$((skipped_draft + 1)); } +skip_os() { line SKIP "$1" "needs macOS"; skipped_os=$((skipped_os + 1)); } +# A tool's own words go to stderr, so stdout stays one line per check. +quote() { if [[ -s "$1" ]]; then sed 's/^/ /' "$1" >&2; fi; } +summary() { + local title="Pladder $VERSION" parts=() joined + if [[ "${draft:-false}" == true ]]; then title="$title is a draft"; fi + if [[ "$failed" -gt 0 ]]; then parts+=("$failed failed"); fi + if [[ "$passed" -gt 0 || "$failed" -eq 0 ]]; then parts+=("$passed passed"); fi + if [[ "$skipped_draft" -gt 0 ]]; then parts+=("$skipped_draft skipped until it is published"); fi + if [[ "$skipped_os" -gt 0 ]]; then parts+=("$skipped_os skipped on $(uname -s)"); fi + joined=$(printf '%s, ' "${parts[@]}") + echo + echo "$title: ${joined%, }." +} + +# release +if ! meta=$(gh release view "$TAG" -R "$REPO" --json tagName,name,isDraft,isPrerelease,url,assets \ + --jq '"\(.tagName)\t\(.isDraft)\t\(.isPrerelease)\t\(.url)\t\(.name)", (.assets[] | "asset\t\(.name)\t\(.digest)")' 2>"$tmp/err"); then + fail release "no release $TAG in $REPO" + quote "$tmp/err" + summary + exit 1 +fi +IFS=$'\t' read -r tag_name draft prerelease url title <<<"$(head -n 1 <<<"$meta")" +problems=() +if [[ "$tag_name" != "$TAG" ]]; then problems+=("its tag is $tag_name"); fi +if [[ "$title" != "Pladder $VERSION" ]]; then problems+=("titled \"$title\", not \"Pladder $VERSION\""); fi +if [[ "$prerelease" == true ]]; then problems+=("marked a pre-release"); fi +if [[ ${#problems[@]} -gt 0 ]]; then + fail release "$(printf '%s; ' "${problems[@]}" | sed 's/; $//')" + summary + exit 1 +fi +if [[ "$draft" == true ]]; then + pass release "\"$title\", a draft, $url" +else + pass release "\"$title\", $url" +fi + +# latest +if [[ "$draft" == true ]]; then + skip_draft latest +elif ! latest=$(gh api "repos/$REPO/releases/latest" --jq .tag_name 2>"$tmp/err"); then + fail latest "GitHub names no latest release" + quote "$tmp/err" +elif [[ "$latest" == "$TAG" ]]; then + pass latest "$TAG is the latest release" +else + fail latest "the latest release is $latest, not $TAG" +fi + +# assets +names=(Pladder.dmg Pladder.dmg.sha256 appcast.xml) +digest="" +missing=() +for name in "${names[@]}"; do + row=$(awk -F '\t' -v n="$name" '$1 == "asset" && $2 == n { print; exit }' <<<"$meta") + if [[ -z "$row" ]]; then + missing+=("$name not attached") + continue + fi + if [[ "$name" == Pladder.dmg ]]; then digest=$(cut -f 3 <<<"$row"); fi + if [[ "$draft" == true ]]; then + # A draft's files are not public yet; gh fetches them signed in. + if ! gh release download "$TAG" -R "$REPO" --pattern "$name" --dir "$tmp" 2>"$tmp/err"; then + missing+=("$name not downloaded") + quote "$tmp/err" + fi + elif ! curl -fsSL --retry 2 -o "$tmp/$name" "$BASE/download/$TAG/$name" 2>"$tmp/err"; then + missing+=("$name not downloaded from $BASE/download/$TAG/$name") + quote "$tmp/err" + fi +done +dmg="$tmp/Pladder.dmg" +have() { [[ -s "$tmp/$1" ]]; } +if [[ ${#missing[@]} -gt 0 ]]; then + fail assets "$(printf '%s; ' "${missing[@]}" | sed 's/; $//')" +else + pass assets "Pladder.dmg ($(($(wc -c <"$dmg"))) bytes), Pladder.dmg.sha256, appcast.xml" +fi +# Each check below names what it could not check, rather than being skipped. +needs() { + local check="$1" absent=() name + shift + for name in "$@"; do have "$name" || absent+=("$name"); done + if [[ ${#absent[@]} -gt 0 ]]; then + fail "$check" "not checked: no $(printf '%s, ' "${absent[@]}" | sed 's/, $//')" + return 1 + fi +} + +# sha256 +dmg_sha="" +if have Pladder.dmg; then dmg_sha=$(sha256 "$dmg"); fi +if needs sha256 Pladder.dmg Pladder.dmg.sha256; then + listed=$(awk '{ print $1; exit }' "$tmp/Pladder.dmg.sha256") + digest=${digest#sha256:} + if [[ -z "$digest" || "$digest" == null ]]; then + fail sha256 "GitHub gives no digest for Pladder.dmg" + elif [[ "$listed" != "$dmg_sha" ]]; then + fail sha256 "Pladder.dmg.sha256 says $listed, the DMG is $dmg_sha" + elif [[ "$digest" != "$dmg_sha" ]]; then + fail sha256 "GitHub's digest is $digest, the DMG is $dmg_sha" + else + pass sha256 "$dmg_sha" + fi +fi + +# appcast +build="" +if ! build=$(gh api graphql -f query="{repository(owner:\"${REPO%/*}\",name:\"${REPO#*/}\"){object(expression:\"$TAG^{commit}\"){... on Commit{history{totalCount}}}}}" \ + --jq '.data.repository.object.history.totalCount' 2>"$tmp/err") || [[ ! "$build" =~ ^[0-9]+$ ]]; then + build="" + quote "$tmp/err" +fi +signature="" +if needs appcast appcast.xml Pladder.dmg; then + feed="$tmp/appcast.xml" + field() { sed -n "s|.*\\([^<]*\\).*|\\1|p" "$feed" | head -n 1; } + items=$(grep -c '' "$feed" || true) + short=$(field shortVersionString) + feed_build=$(field version) + enclosure=$(sed -n 's|.*]*url="\([^"]*\)".*|\1|p' "$feed" | head -n 1) + length=$(sed -n 's|.*]*length="\([0-9]*\)".*|\1|p' "$feed" | head -n 1) + signature=$(sed -n 's|.*]*sparkle:edSignature="\([^"]*\)".*|\1|p' "$feed" | head -n 1) + size=$(($(wc -c <"$dmg"))) + problems=() + if [[ "$items" != 1 ]]; then problems+=("$items items, not one"); fi + if [[ "$short" != "$VERSION" ]]; then problems+=("version \"$short\""); fi + if [[ -z "$build" ]]; then + problems+=("could not count the commits at $TAG") + elif [[ "$feed_build" != "$build" ]]; then + problems+=("build \"$feed_build\", but $TAG is commit $build") + fi + if [[ "$enclosure" != "$BASE/download/$TAG/Pladder.dmg" ]]; then problems+=("enclosure $enclosure"); fi + if [[ "$length" != "$size" ]]; then problems+=("length $length, the DMG has $size bytes"); fi + if [[ ${#problems[@]} -gt 0 ]]; then + fail appcast "$(printf '%s; ' "${problems[@]}" | sed 's/; $//')" + else + pass appcast "$VERSION, build $build, $size bytes, this release's DMG" + fi +fi + +# signature +if needs signature appcast.xml Pladder.dmg; then + key="" + if gh api "repos/$REPO/contents/Sources/Pladder/Resources/Info.plist?ref=$TAG" \ + -H 'Accept: application/vnd.github.raw' >"$tmp/Info.plist" 2>"$tmp/err"; then + key=$(awk ' + /SUPublicEDKey<\/key>/ { found = 1; sub(/.*SUPublicEDKey<\/key>/, "") } + found && // { sub(/.*/, ""); sub(/<\/string>.*/, ""); print; exit } + ' "$tmp/Info.plist") + else + quote "$tmp/err" + fi + if [[ -z "$key" ]]; then + fail signature "no SUPublicEDKey in Sources/Pladder/Resources/Info.plist at $TAG" + elif [[ -z "$signature" ]]; then + fail signature "the appcast's enclosure has no sparkle:edSignature" + elif [[ "$darwin" -eq 1 ]]; then + # The check appcast.sh makes before it prints the feed. + if xcrun swift - "$key" "$signature" "$dmg" >"$tmp/err" 2>&1 <<'SWIFT' +import CryptoKit +import Foundation +let arguments = CommandLine.arguments +guard let key = Data(base64Encoded: arguments[1]), let signature = Data(base64Encoded: arguments[2]), + let publicKey = try? Curve25519.Signing.PublicKey(rawRepresentation: key), + let data = FileManager.default.contents(atPath: arguments[3]), + publicKey.isValidSignature(signature, for: data) else { exit(1) } +SWIFT + then + pass signature "verifies against SUPublicEDKey at $TAG (CryptoKit)" + else + fail signature "does not verify against SUPublicEDKey at $TAG" + quote "$tmp/err" + fi + elif ! openssl version 2>/dev/null | grep -q '^OpenSSL 3'; then + fail signature "no verifier: on Linux this needs OpenSSL 3, found $(openssl version 2>/dev/null || echo none)" + else + # An Ed25519 SubjectPublicKeyInfo is this fixed DER prefix and the raw key. + { printf '\060\052\060\005\006\003\053\145\160\003\041\000'; base64 -d <<<"$key"; } >"$tmp/key.der" + base64 -d <<<"$signature" >"$tmp/signature.bin" + if openssl pkeyutl -verify -pubin -inkey "$tmp/key.der" -keyform DER -rawin \ + -in "$dmg" -sigfile "$tmp/signature.bin" >"$tmp/err" 2>&1; then + pass signature "verifies against SUPublicEDKey at $TAG (OpenSSL)" + else + fail signature "does not verify against SUPublicEDKey at $TAG" + quote "$tmp/err" + fi + fi +fi + +# gatekeeper, staple, app +if [[ "$darwin" -eq 0 ]]; then + skip_os gatekeeper + skip_os staple + skip_os app +else + if needs gatekeeper Pladder.dmg; then + if spctl -a -vvv -t open --context context:primary-signature "$dmg" >"$tmp/err" 2>&1; then + pass gatekeeper "accepted, $(sed -n 's/^source=//p' "$tmp/err")" + else + fail gatekeeper "spctl rejects the DMG" + quote "$tmp/err" + fi + fi + if needs staple Pladder.dmg; then + if xcrun stapler validate "$dmg" >"$tmp/err" 2>&1; then + pass staple "the notarisation ticket is stapled" + else + fail staple "stapler validate fails" + quote "$tmp/err" + fi + fi + if needs app Pladder.dmg; then + mkdir "$tmp/mnt" + if ! hdiutil attach -readonly -nobrowse -noautoopen -mountpoint "$tmp/mnt" "$dmg" >"$tmp/err" 2>&1; then + fail app "the DMG does not mount" + quote "$tmp/err" + else + mounted=1 + app="$tmp/mnt/Pladder.app" + plist() { /usr/libexec/PlistBuddy -c "Print $1" "$app/Contents/Info.plist" 2>/dev/null || true; } + team() { codesign -dv "$1" 2>&1 | sed -n 's/^TeamIdentifier=//p' || true; } + app_version=$(plist CFBundleShortVersionString) + app_build=$(plist CFBundleVersion) + app_team=$(team "$app") + dmg_team=$(team "$dmg") + problems=() + if [[ ! -d "$app" ]]; then problems+=("no Pladder.app in the DMG"); fi + if [[ "$app_version" != "$VERSION" ]]; then problems+=("version \"$app_version\""); fi + if [[ -z "$build" || "$app_build" != "$build" ]]; then problems+=("build \"$app_build\", not ${build:-the commit count}"); fi + if [[ "$app_team" != "$TEAM" ]]; then problems+=("the app's team is \"$app_team\", not $TEAM"); fi + if [[ "$dmg_team" != "$TEAM" ]]; then problems+=("the DMG's team is \"$dmg_team\", not $TEAM"); fi + if [[ ${#problems[@]} -gt 0 ]]; then + fail app "$(printf '%s; ' "${problems[@]}" | sed 's/; $//')" + else + pass app "Pladder.app $app_version ($app_build), the app and the DMG by team $TEAM" + fi + if hdiutil detach "$tmp/mnt" -quiet >"$tmp/err" 2>&1; then mounted=0; else quote "$tmp/err"; fi + fi + fi +fi + +# cask +if [[ "$draft" == true ]]; then + skip_draft cask +else + sha=${digest#sha256:} + if [[ -z "$sha" || "$sha" == null ]]; then sha=$dmg_sha; fi + if ! gh api "repos/$TAP/contents/Casks/pladder.rb" -H 'Accept: application/vnd.github.raw' >"$tmp/pladder.rb" 2>"$tmp/err"; then + fail cask "no Casks/pladder.rb in $TAP" + quote "$tmp/err" + elif ! grep -qF "version \"$VERSION\"" "$tmp/pladder.rb"; then + fail cask "$TAP's cask is $(sed -n 's/^ *version "\([^"]*\)".*/\1/p' "$tmp/pladder.rb" | head -n 1), not $VERSION" + elif [[ -z "$sha" || "$sha" == null ]]; then + fail cask "not checked: no SHA-256 of the DMG" + elif ! grep -qF "sha256 \"$sha\"" "$tmp/pladder.rb"; then + fail cask "$TAP's cask names $VERSION with another SHA-256" + else + pass cask "$TAP names $VERSION and its SHA-256" + fi +fi + +# latest-download +if [[ "$draft" == true ]]; then + skip_draft latest-download +else + problems=() + for name in Pladder.dmg appcast.xml; do + target=$(curl -sSI -o /dev/null -w '%{redirect_url}' "$BASE/latest/download/$name" 2>"$tmp/err") || quote "$tmp/err" + if [[ "$target" != "$BASE/download/$TAG/$name" ]]; then problems+=("$name goes to ${target:-nowhere}"); fi + done + if [[ ${#problems[@]} -gt 0 ]]; then + fail latest-download "$(printf '%s; ' "${problems[@]}" | sed 's/; $//')" + else + pass latest-download "Pladder.dmg and appcast.xml resolve to $TAG" + fi +fi + +summary +if [[ "$failed" -gt 0 ]]; then exit 1; fi From ba5d39baee8e82ca7ac51529be2266564eca61ee Mon Sep 17 00:00:00 2001 From: Fabian Meyer <44942030+dinooo13@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:31:23 +0100 Subject: [PATCH 2/4] Scripts: release-preflight.sh, whether main can be released A release should stop before anyone is asked to approve it: on another branch, a checkout behind or ahead of origin/main, a head commit that is not green in CI, Docs and Scripts, a Release run already open, a local tag the remote no longer has, or nothing the build reads changed since the last tag. The path list is read from release.yml at the head, so the preflight and the workflow's own check cannot disagree. Co-Authored-By: Claude Opus 5.5 --- scripts/release-preflight.sh | 150 +++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100755 scripts/release-preflight.sh diff --git a/scripts/release-preflight.sh b/scripts/release-preflight.sh new file mode 100755 index 0000000..5b2aaee --- /dev/null +++ b/scripts/release-preflight.sh @@ -0,0 +1,150 @@ +#!/usr/bin/env bash +# Says whether main can be released: this is a Mac, the checkout is on main +# and level with origin/main, CI, Docs and Scripts are green on its commit, no +# Release run is open, the last tag is on origin, and something the build +# reads changed since it. release.yml refuses a release on its own terms too; +# this stops before anyone is asked to approve one. +# +# Usage: scripts/release-preflight.sh [--force] +# --force go on although nothing the build reads changed since the last tag +# +# Read only, apart from fetching main and the tags. One line per check, PASS +# or STOP; the first STOP ends it. Exit 0 when main can be released, 1 when a +# check stopped it, 2 on bad usage or a missing tool. +set -euo pipefail +for arg in "$@"; do + case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac +done + +REPO=dinooo13/pladder +WORKFLOWS=(CI Docs Scripts) + +force=false +case "$*" in +"") ;; +--force) force=true ;; +*) + echo "usage: scripts/release-preflight.sh [--force]" >&2 + exit 2 + ;; +esac +for tool in git gh awk sed; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "release-preflight.sh: $tool is missing" >&2 + exit 2 + fi +done +cd "$(dirname "$0")/.." + +line() { printf '%s %-11s %s\n' "$1" "$2" "$3"; } +pass() { line PASS "$1" "$2"; } +stop() { + line STOP "$1" "$2" + exit 1 +} + +# mac +if [[ "$(uname -s)" != Darwin ]]; then + stop mac "this is $(uname -s); scripts/check-release.sh needs macOS for half its checks" +fi +pass mac "$(sw_vers -productVersion 2>/dev/null || uname -r)" + +# branch +branch=$(git rev-parse --abbrev-ref HEAD) +if [[ "$branch" != main ]]; then + stop branch "on $branch; a release starts from main" +fi +pass branch main + +# up-to-date +# --tags: the workflow tags a commit this checkout may already have, and the +# last tag below must be the remote's. +if ! git fetch --quiet --tags origin main; then + stop up-to-date "git fetch origin main failed" +fi +head=$(git rev-parse HEAD) +remote=$(git rev-parse FETCH_HEAD) +if [[ "$head" != "$remote" ]]; then + ahead=$(git rev-list --count FETCH_HEAD..HEAD) + behind=$(git rev-list --count HEAD..FETCH_HEAD) + stop up-to-date "main is $ahead ahead of and $behind behind origin/main; pull or push first" +fi +pass up-to-date "${head:0:7} is origin/main" + +# checks +if ! runs=$(gh run list -R "$REPO" --commit "$head" --limit 100 --json workflowName,status,conclusion,url \ + --jq '.[] | "\(.workflowName)\t\(.status)\t\(.url)\t\(.conclusion)"'); then + stop checks "gh run list failed" +fi +for workflow in "${WORKFLOWS[@]}"; do + # gh lists the newest run first; a rerun's result is the one that counts. + run=$(awk -F '\t' -v w="$workflow" '$1 == w { print; exit }' <<<"$runs") + if [[ -z "$run" ]]; then + stop checks "$workflow has no run on ${head:0:7}" + fi + # conclusion is empty until a run completes, and read folds an empty field + # between tabs, so it comes last. + IFS=$'\t' read -r _ status url conclusion <<<"$run" + if [[ "$status" != completed ]]; then + stop checks "$workflow is $status on ${head:0:7}: $url" + fi + if [[ "$conclusion" != success ]]; then + stop checks "$workflow ended $conclusion on ${head:0:7}: $url" + fi +done +pass checks "$(printf '%s, ' "${WORKFLOWS[@]}" | sed 's/, $//') green on ${head:0:7}" + +# no-open-run +if ! open=$(gh run list -R "$REPO" --workflow release.yml --limit 20 --json status,displayTitle,url \ + --jq '.[] | select(.status != "completed") | "\(.displayTitle), \(.status): \(.url)"'); then + stop no-open-run "gh run list failed" +fi +if [[ -n "$open" ]]; then + stop no-open-run "$(head -n 1 <<<"$open")" +fi +pass no-open-run "no Release run is open" + +# last-tag +last=$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' HEAD 2>/dev/null || true) +if [[ -z "$last" ]]; then + stop last-tag "no v* tag reaches ${head:0:7}" +fi +if [[ -z "$(git ls-remote --tags origin "refs/tags/$last")" ]]; then + stop last-tag "$last is a local tag origin does not have; delete it with git tag -d $last" +fi +if ! last_draft=$(gh release view "$last" -R "$REPO" --json isDraft --jq .isDraft 2>&1); then + if [[ "$last_draft" == *"release not found"* ]]; then + stop last-tag "$last has no release; a run that failed left its tag, which is the maintainer's to delete" + fi + stop last-tag "gh release view $last failed: $last_draft" +fi +if [[ "$last_draft" == true ]]; then + stop last-tag "$last is an unpublished draft; publishing it, or deleting it and its tag, is the maintainer's" +fi +if [[ "$last_draft" != false ]]; then + stop last-tag "gh release view $last returned: $last_draft" +fi +pass last-tag "$last" + +# changes +# The list release.yml's own check reads, from the commit being released, so +# the two can never disagree. +paths=() +while IFS= read -r path; do paths+=("$path"); done < <(git show HEAD:.github/workflows/release.yml | awk ' + /git diff --quiet "\$last" HEAD -- \\$/ { on = 1; next } + on { line = $0; done = (line !~ /\\$/); sub(/; then$/, "", line); sub(/[ \t]*\\$/, "", line); print line; if (done) exit } +' | tr -s ' \t' '\n' | sed '/^$/d') +if [[ ${#paths[@]} -eq 0 ]]; then + stop changes "cannot read the source paths from .github/workflows/release.yml" +fi +if git diff --quiet "$last" HEAD -- "${paths[@]}"; then + if [[ "$force" != true ]]; then + stop changes "nothing the build reads changed since $last; --force releases anyway" + fi + pass changes "nothing the build reads changed since $last, forced" +else + pass changes "$(git diff --name-only "$last" HEAD -- "${paths[@]}" | wc -l | tr -d ' ') files the build reads changed since $last" +fi + +echo +echo "Ready: ${head:0:7}, last tag $last." From f9f1af341c2c388912dca0b211169bb811ad6773 Mon Sep 17 00:00:00 2001 From: Fabian Meyer <44942030+dinooo13@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:31:23 +0100 Subject: [PATCH 3/4] CI: a release run is titled with its version The approval page showed only "Release", so the reviewer could not see which version they were approving. Now it says "Release 0.3.0", with "(draft)" for a draft: approving accepts that version, rejecting and naming another changes it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d022536..d7b744e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ name: Release +run-name: Release ${{ inputs.version }}${{ inputs.draft && ' (draft)' || '' }} # Started by hand only, from main. See INSTALL.md, "Releasing". on: From 401314c8c0c98cfaed8c5f3a6b8ad09f690a2d8e Mon Sep 17 00:00:00 2001 From: Fabian Meyer <44942030+dinooo13@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:31:23 +0100 Subject: [PATCH 4/4] Skills: release, from the request to a checked release The pipeline existed but nothing drove it end to end: the version, the notes, the dispatch, following the run and checking what went out were all by hand. The skill does them, and leaves the maintainer one step, the approval of the release environment, which no agent takes by any route. It touches no copy of Pladder on the Mac. Ship names the skill and check-release.sh as the live check, INSTALL.md the two scripts, and docs.yml now checks the scripts the skills name as it does CLAUDE.md's. Closes #126. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/release/SKILL.md | 151 ++++++++++++++++++++++++++++++++ .github/workflows/docs.yml | 4 +- CLAUDE.md | 5 +- INSTALL.md | 2 + 4 files changed, 158 insertions(+), 4 deletions(-) create mode 100644 .claude/skills/release/SKILL.md diff --git a/.claude/skills/release/SKILL.md b/.claude/skills/release/SKILL.md new file mode 100644 index 0000000..aa5c997 --- /dev/null +++ b/.claude/skills/release/SKILL.md @@ -0,0 +1,151 @@ +--- +name: release +description: Release Pladder from main through release.yml, up to the maintainer's approval and then to a checked release. Preflight, a suggested version with its notes, the dispatch, the run followed to the end, scripts/check-release.sh, and the Homebrew cask by hand if its bump failed. Use when asked to "release", "cut a release", "release 0.x.y" or "release as a draft". +--- + +# Releasing Pladder + +Drives the Release workflow (`.github/workflows/release.yml`, INSTALL.md, "Releasing") from the request to a +checked release. The maintainer's one step is approving the `release` environment; everything around it is +here. Only when the maintainer asks for a release: a release is never part of shipping a change. + +## Rules + +- Run on the MacBook Air (`hostname` is `MacBookAir.fritz.box`), from the root checkout on `main`, not a + worktree. On the code-box, say so and stop: half of `scripts/check-release.sh` needs macOS. +- The approval is the maintainer's. Never approve, reject or bypass a deployment, by any route: REST, + GraphQL, the browser, or a change to the environment's rules. Read "waiting" from the run's status only. + The maintainer's Claude Code settings deny the REST and GraphQL approval routes; that is a guardrail, not + a boundary, since GitHub cannot tell this session from the maintainer: both use the same `gh` login. +- Never cancel or rerun a release run. A new attempt is a new dispatch, through the preflight again. +- Never launch, quit, update or replace a copy of Pladder on the Mac: no `brew upgrade` or `brew install`, + no `bundle.sh --install`, no Check for Updates…, never open the DMG. The developer dictates with it + (CLAUDE.md, "Working on this Mac while Pladder is in use"). `check-release.sh` mounts the DMG read-only and + hidden, and that is all. +- Never read, write or print the signing secrets or keys, and never change the `release` environment. +- Never delete or edit a release or a tag. When one has to go, give the maintainer the command. + +## Steps + +1. **Preflight.** From the root checkout: + + ```sh + scripts/release-preflight.sh + ``` + + `--force` only when the maintainer asked to release although nothing changed. On a `STOP`, say its line + and stop. If it stopped on an open release run and the maintainer says to follow that run, go to step 4 + with it. + +2. **Version and notes, a suggestion, not a question.** With the last tag from the preflight's `last-tag` + line: + + ```sh + git log --no-merges --format=%s ..HEAD + scripts/changelog.sh HEAD + ``` + + - A **minor**, X.(Y+1).0, when a subject outside the notes' Internals group adds something a user can + newly do or set: a setting, a mode, a hotkey role, an engine or polish model in the picker, a managed + policy key, a way to install or update. + - A **patch**, X.Y.(Z+1), otherwise: fixes, speed, wording, look, Internals only. + - Never a major unless asked: Pladder is an application with no programmatic consumers, so nothing it + ships is a breaking change in the semver sense. A version, "minor" or "patch" in the request wins. + + Show it in a message the maintainer sees now (in T3 Code, `send_to_user`), as + `Pladder 0.3.0 (minor): "Settings: …" adds a setting.` followed by the notes, then go on without + waiting. + +3. **Dispatch.** + + ```sh + date -u +%FT%TZ && gh workflow run release.yml -R dinooo13/pladder --ref main -f version= [-f draft=true] [-f force=true] + ``` + + `draft=true` for "as a draft", `force=true` only with the preflight's `--force`. The run id is the last + segment of the URL it prints. If it prints none, look for up to a minute: + + ```sh + gh run list -R dinooo13/pladder --workflow release.yml --event workflow_dispatch --limit 5 \ + --json databaseId,displayTitle,headSha,createdAt \ + --jq '[.[] | select(.displayTitle == "Release ")][0] // empty | "\(.databaseId) \(.headSha) \(.createdAt)"' + ``` + + The title is `Release (draft)` for a draft. Any status counts, since a refused `check` ends the + run within seconds. It is this dispatch's run only if its `createdAt` is not before the time printed + with the dispatch and its `headSha` is the preflight's commit; otherwise look again. + +4. **Until it waits.** The `check` job takes under a minute. Wait with one command in the background, and + start it again if the harness ends it while the run is still open: + + ```sh + until s=$(gh run view -R dinooo13/pladder --json status --jq .status) && + { [ "$s" = waiting ] || [ "$s" = completed ]; }; do sleep 10; done; echo "$s" + ``` + + `waiting` goes on to step 5, `completed` to step 6. A run followed from the preflight may be past its + approval already, and `in_progress` looks the same before and after it, so only these two decide. + +5. **The approval.** One line the maintainer sees now: + `Pladder () is waiting for your approval: `. To release another version they + reject the run on that page and say which; nothing is tagged before the approval. Then wait with one + blocking command in the background, not a loop of `gh run view`, and start it again if the harness ends + it while the run is still open: + + ```sh + gh run watch -R dinooo13/pladder --exit-status --interval 30 + ``` + +6. **When the run ends.** + - **Success**: step 7. + - **Rejected**: `gh api repos/dinooo13/pladder/actions/runs//approvals` shows `"state": "rejected"` + and the reviewer's comment. Confirm nothing was tagged: `git ls-remote --tags origin refs/tags/v` + prints nothing. If the maintainer named another version, in the thread or in the rejection comment, go + to step 1 with it. Otherwise say it was rejected and stop. + - **The `check` job failed**: it refused the release before anyone was asked; quote its `::error::` + line from `gh run view -R dinooo13/pladder --log-failed` and stop. Nothing was tagged. + - **A step failed**: name the step and quote its error from + `gh run view -R dinooo13/pladder --log-failed`. Then say what is left, from + `git ls-remote --tags origin refs/tags/v` and `gh release view v -R dinooo13/pladder`. + No tag and no release: the run cleaned up after itself; report and stop, and start again at step 1 + only when the maintainer asks. A tag but no release: the run's own delete failed; give the maintainer + `git push origin --delete v`. A release: its tag stays, go to step 7. + - **Cancelled**, while waiting or later: there is no failed log. Say so with what is left, read as above, + and stop. + +7. **Check what went out.** + + ```sh + scripts/check-release.sh + ``` + + A draft skips `latest`, `cask` and `latest-download` and says so in its summary; that is a checked draft. + Any other `FAIL` goes into the report as it stands. + +8. **Cask by hand**, only for a published release whose one `FAIL` is `cask` (the Bump the Homebrew cask + step failed, or the maintainer has since published a draft), as INSTALL.md, "Homebrew", describes: + + ```sh + rm -rf /tmp/pladder-tap- && + gh repo clone dinooo13/homebrew-tap /tmp/pladder-tap- -- --depth 1 --quiet && + scripts/cask.sh > /tmp/pladder-tap-/Casks/pladder.rb && # reads the SHA-256 from the release + git -C /tmp/pladder-tap- diff + ``` + + Read the diff before going on. It may change the `version` and `sha256` lines and what + `git diff v -- scripts/pladder.rb` changed in the template; anything else, stop and + show it. Then, as a separate command: + + ```sh + git -C /tmp/pladder-tap- commit -qam "pladder " && + git -C /tmp/pladder-tap- push -q && + rm -rf /tmp/pladder-tap- && + scripts/check-release.sh + ``` + + The path is written out in every command because shell variables do not last from one command to the + next, and a `git -C` with an empty path would commit in this checkout. + +9. **Report**: the release link, the version and why, the notes, every line of `check-release.sh`, and what + is left for a human: Check for Updates… and Install on an installed copy, and `brew upgrade` on a real + Mac. For a draft, also that publishing it, or deleting it and its tag, is the maintainer's. diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f9ed2bb..f3e4562 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -16,5 +16,5 @@ jobs: run: ./scripts/check-doc-pointers.sh - name: The site's numbers match the docs run: ./scripts/check-site-numbers.sh - - name: CLAUDE.md names scripts and pladder-cli commands that exist - run: ./scripts/check-doc-commands.sh + - name: CLAUDE.md and the skills name scripts and pladder-cli commands that exist + run: ./scripts/check-doc-commands.sh CLAUDE.md .claude/skills/*/SKILL.md diff --git a/CLAUDE.md b/CLAUDE.md index e2bacaf..1557810 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -156,9 +156,9 @@ Only a human can check: a real dictation into other apps, since no agent posts a ## Ship -- **Verify:** `## Verify` for the kind of change, and what CI runs: `swift build` with no new warning, `swift test`, `shellcheck scripts/*.sh`, every script's `--help`, the three `check-*.sh`. A change on the release-to-paste path carries its benchmark, before and after. The pull request follows `.github/pull_request_template.md` and says what was not checked and who has to check it. +- **Verify:** `## Verify` for the kind of change, and what CI runs: `swift build` with no new warning, `swift test`, `shellcheck scripts/*.sh`, every script's `--help`, the three doc checks, `check-doc-pointers.sh`, `check-doc-commands.sh` and `check-site-numbers.sh`. A change on the release-to-paste path carries its benchmark, before and after. The pull request follows `.github/pull_request_template.md` and says what was not checked and who has to check it. - **Merge:** Rebase only, so every commit lands as it is: the subject an area, a colon and a sentence, the body the reason, `Closes #.` at the end of the last one, fixups squashed. `build-and-test`, `scripts` and `doc-pointers` green on the last commit and every review thread resolved, then `gh pr merge --rebase --match-head-commit `. GitHub keeps the branch; delete it. -- **After merge:** Pull `main` in the root checkout. A change the build reads (`Sources`, `Package.swift`, `Package.resolved`, `Assets`, `scripts/bundle.sh`, `scripts/Pladder.entitlements`) is installed from there, on the Mac, with `./scripts/bundle.sh --install --run`. That stops `/Applications/Pladder.app`, the copy in use, and drops a recording in progress, so an agent runs it without asking only while the developer is not dictating: build first with a plain `./scripts/bundle.sh`, run the check below, and start the install as soon as it prints `idle`, so the install's own build has nothing left to do. When it prints nothing, ask first. A change under `site/` is published by `pages.yml`; wait for its run on the merge commit. Anything else needs nothing. A release is never part of shipping a change: `release.yml` is dispatched by hand. +- **After merge:** Pull `main` in the root checkout. A change the build reads (`Sources`, `Package.swift`, `Package.resolved`, `Assets`, `scripts/bundle.sh`, `scripts/Pladder.entitlements`) is installed from there, on the Mac, with `./scripts/bundle.sh --install --run`. That stops `/Applications/Pladder.app`, the copy in use, and drops a recording in progress, so an agent runs it without asking only while the developer is not dictating: build first with a plain `./scripts/bundle.sh`, run the check below, and start the install as soon as it prints `idle`, so the install's own build has nothing left to do. When it prints nothing, ask first. A change under `site/` is published by `pages.yml`; wait for its run on the merge commit. Anything else needs nothing. A release is never part of shipping a change (Release, below). ```sh p='subsystem == "de.dinooo13.pladder" AND category == "capture" AND processImagePath == "/Applications/Pladder.app/Contents/MacOS/Pladder"' @@ -169,3 +169,4 @@ Only a human can check: a real dictation into other apps, since no agent posts a The installed copy logs `capture started` when the microphone opens and `capture stop called` on every release, cancel, cap and quit, and `log show` sees each within a second. `idle` means the last start in the past 61 minutes (the latched cap, and a minute) was followed by a stop, and nothing started or stopped in the past 20 s, long enough for a polish and the clipboard's return. A `log show` that fails prints no `Timestamp` header, so it never reads as `idle`. - **Live check:** After an install, `/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Applications/Pladder.app/Contents/Info.plist` prints what `git rev-list --count HEAD` prints on `main`, and `pgrep -f /Applications/Pladder.app/Contents/MacOS/Pladder` finds the copy. The first real dictation is the developer's; its release-to-paste line shows with the `log show` command under "Critical-path rule". For the site, load https://dinooo13.github.io/pladder/ and look at what changed. For anything else, the checks on the merge commit: `gh run list --commit `. +- **Release:** Only when the maintainer asks. The `release` skill (`.claude/skills/release/`) runs `scripts/release-preflight.sh`, suggests the version with its notes, dispatches `release.yml` and follows the run to the end. The approval of the `release` environment is the maintainer's: no agent approves, rejects or bypasses it, by any route. `scripts/check-release.sh ` is the live check. A release installs nothing on the Mac. diff --git a/INSTALL.md b/INSTALL.md index 1c75d9a..d9af88b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -120,6 +120,8 @@ A release comes from the **Release** workflow (`.github/workflows/release.yml`): ./scripts/changelog.sh v0.1.0 HEAD ``` +The `release` skill (`.claude/skills/release/`) does all of this from a Claude Code session on the Mac, up to the approval, which stays the reviewer's, and checks the release once it is out. By hand, `scripts/release-preflight.sh` says whether `main` can be released, and `scripts/check-release.sh ` checks what went out: the release and its files, the appcast and its signature, the notarised DMG and the app in it, the cask and the `releases/latest/download` links. A run is titled "Release ", with "(draft)" for a draft, so the approval page names the version. + Before anyone is asked to approve, a Linux job refuses a ref other than `main`, a version that is not `major.minor.patch`, one whose tag exists or that is not newer than the last tag, and a release in which nothing the build reads (the paths `ci.yml` builds for) changed since the last tag, unless **force** is ticked. The release job then waits for a reviewer of the `release` environment. Once approved, it tags the commit `v`, builds and runs the tests as CI does, imports the certificate into a throwaway keychain, runs `scripts/release.sh`, checks that the build number is the commit count, signs the DMG with the update key and writes `appcast.xml` with `scripts/appcast.sh`, uploads the DMG as a workflow artifact, and publishes the release "Pladder " with `Pladder.dmg`, its `.sha256`, `appcast.xml` and the notes from `scripts/changelog.sh`, then bumps the [Homebrew](#homebrew) cask. Every release names its DMG `Pladder.dmg` and its feed `appcast.xml`, so `releases/latest/download/Pladder.dmg` always resolves and every copy's feed, `releases/latest/download/appcast.xml`, is always the newest release's; the version is in the tag and the title. Tick **draft** to check a release before it is public. The keychain and the key files are deleted as soon as `release.sh` is done, before the upload and the publish, and also when a step failed. The tag comes first because GitHub lets the workflow's token tag a commit only while its `.github/workflows` matches a branch tip: a push to `main` that changes a workflow during the run would otherwise fail it at the very end. If main's workflows changed between the dispatch and the approval, the job stops at once; run it again. A run that fails or is cancelled before the release exists deletes its tag, so it can simply be run again. The changelog groups the commit subjects since the last tag by their `Area:` prefix, folds the internal areas (Tests, CI, Bench, Docs, Scripts) into an Internals group at the end, and links the pull request a subject names, `(#93)`, and the issues a body `Closes` or `Refs`. Merge and `fixup!` commits are left out.