Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(release): mac_only proves it changed nothing but the Mac

purplecadf3a215115
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b9d6f7ef..fee747e4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1370,9 +1370,14 @@ jobs:
if (!names.some((n) => re.test(n))) fail(tag + ' has no ' + what + '; run the whole release, not mac_only')
}
if (names.some((n) => /_aarch64\.dmg$/.test(n))) console.log('::warning::' + tag + ' already has a disk image; this run replaces the Mac files')
- console.log('OK: ' + tag + ' is published with ' + names.length + ' files; the Mac app is added to it.')
+ // What must still be there, unchanged, after the upload: every file
+ // but the Mac ones and latest.json, by GitHub's own sha256.
+ const keep = (rel.assets || []).filter((a) => !/(_aarch64\.dmg|\.app\.tar\.gz(\.sig)?|^latest\.json)$/.test(a.name))
+ for (const a of keep) if (!/^sha256:[0-9a-f]{64}$/.test(a.digest || '')) fail(a.name + ' has no sha256 digest to compare against')
+ fs.writeFileSync(process.env.RUNNER_TEMP + '/mac-only-before.json', JSON.stringify(Object.fromEntries(keep.map((a) => [a.name, a.digest])), null, 1))
+ console.log('OK: ' + tag + ' is published with ' + names.length + ' files; the Mac app is added to it. Kept as they are: ' + keep.length)
JS
- json="$RUNNER_TEMP/latest.json"
+ json="$RUNNER_TEMP/mac-only-latest-before.json"
curl -fsSL --retry 3 "https://github.com/$GITHUB_REPOSITORY/releases/download/$RELEASE_TAG/latest.json" -o "$json"
node -e 'const d=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));const want=process.argv[2].replace(/^v/,"");if(d.version!==want){console.error("::error::latest.json of "+process.argv[2]+" says version "+d.version);process.exit(1)}console.log("OK: latest.json is version "+d.version+" with "+Object.keys(d.platforms||{}).join(", "))' "$json" "$RELEASE_TAG"
@@ -1969,6 +1974,34 @@ jobs:
if (later.length) console.log('NOTE: not attached yet: ' + later.join(', ') + '. Do not flip this release to Latest before they are.')
console.log('OK: darwin-aarch64 -> ' + file + ', every attached platform kept its key, .dmg attached')
NODE
+ # A Mac-only run adds to a release that was checked without the Mac.
+ # Proof that it added and changed nothing else: every other file has
+ # the digest it had before, and every latest.json entry that was
+ # there is the same, with only darwin keys new.
+ if [ "$MAC_ONLY" = true ]; then
+ gh api "repos/$GITHUB_REPOSITORY/releases/tags/$RELEASE_TAG" > "$dir/release-after.json"
+ node - "$RUNNER_TEMP/mac-only-before.json" "$dir/release-after.json" "$RUNNER_TEMP/mac-only-latest-before.json" "$dir/latest.json" <<'NODE'
+ const fs = require('node:fs')
+ const read = (f) => JSON.parse(fs.readFileSync(f, 'utf8'))
+ const [before, rel, jsonBefore, jsonAfter] = process.argv.slice(2).map(read)
+ const fail = (m) => { console.error('FAIL: ' + m + '. Do NOT flip this release to Latest.'); process.exit(1) }
+ const now = Object.fromEntries(rel.assets.map((a) => [a.name, a.digest]))
+ for (const [name, digest] of Object.entries(before)) {
+ if (!(name in now)) fail(name + ' is gone from the release')
+ if (now[name] !== digest) fail(name + ' changed: ' + digest + ' -> ' + now[name])
+ }
+ if (jsonAfter.version !== jsonBefore.version) fail('latest.json version changed: ' + jsonBefore.version + ' -> ' + jsonAfter.version)
+ // Same keys, same values; the order of keys inside an entry is not
+ // a change.
+ const same = (x) => JSON.stringify(x && Object.keys(x).sort().map((k) => [k, x[k]]))
+ for (const [key, entry] of Object.entries(jsonBefore.platforms || {})) {
+ if (same(jsonAfter.platforms?.[key]) !== same(entry)) fail('latest.json entry ' + key + ' changed')
+ }
+ const added = Object.keys(jsonAfter.platforms || {}).filter((k) => !(k in (jsonBefore.platforms || {})))
+ if (added.some((k) => !k.startsWith('darwin-'))) fail('latest.json gained a platform that is not a Mac: ' + added.join(', '))
+ console.log('OK: ' + Object.keys(before).length + ' files unchanged by digest, ' + Object.keys(jsonBefore.platforms || {}).length + ' latest.json entries unchanged, added: ' + added.join(', '))
+ NODE
+ fi
# Software bill of materials and checksums, attached to the release once the
# installers are. Three CycloneDX files, one per ecosystem that ends up on a
@@ -1990,6 +2023,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }}
+ MAC_ONLY: ${{ inputs.mac_only && 'true' || 'false' }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
@@ -2038,6 +2072,10 @@ jobs:
rm -f "$dir/SHA256SUMS.txt"
(cd "$dir" && sha256sum -- * | sort -k2 > "$RUNNER_TEMP/SHA256SUMS.txt")
cat "$RUNNER_TEMP/SHA256SUMS.txt"
+ if [ "$MAC_ONLY" = true ]; then
+ grep -qE ' [^ ]+_aarch64\.dmg$' "$RUNNER_TEMP/SHA256SUMS.txt" || { echo "FAIL: SHA256SUMS.txt lists no .dmg" >&2; exit 1; }
+ grep -qE ' [^ ]+\.app\.tar\.gz$' "$RUNNER_TEMP/SHA256SUMS.txt" || { echo "FAIL: SHA256SUMS.txt lists no updater archive" >&2; exit 1; }
+ fi
gh release upload "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --clobber "$RUNNER_TEMP/SHA256SUMS.txt"
# The promise above, made real for every trigger. Runs after the binaries are
diff --git a/src/lib/__tests__/mac-release-lane.test.ts b/src/lib/__tests__/mac-release-lane.test.ts
index 9a699429..e90cc292 100644
--- a/src/lib/__tests__/mac-release-lane.test.ts
+++ b/src/lib/__tests__/mac-release-lane.test.ts
@@ -568,11 +568,38 @@ describe('release.yml, a Mac-only run adds to an existing release and touches no
expect(laneSteps[upload + 1]).toContain('kept the other platforms')
})
+ it('proves after the upload that nothing but the Mac was added', () => {
+ const before = laneSteps[check]
+ expect(before).toContain('mac-only-before.json')
+ expect(before).toContain('mac-only-latest-before.json')
+ const after = laneSteps[upload + 1]
+ expect(after).toMatch(/if \[ "\$MAC_ONLY" = true \]; then/)
+ expect(after).toContain('mac-only-before.json')
+ expect(after).toContain("changed: ' + digest")
+ expect(after).toContain("latest.json entry ' + key + ' changed")
+ expect(after).toContain("!k.startsWith('darwin-')")
+ })
+
+ it('changes nothing for a release or a dry run: every Mac-only step and check asks for the input', () => {
+ // The input is read in five places only: the gate, the Mac lane's
+ // condition and its MAC_ONLY, the checksums job's condition and its
+ // MAC_ONLY.
+ expect(withoutComments(RELEASE_YML).match(/inputs\.mac_only/g) ?? []).toHaveLength(5)
+ expect(withoutComments(lane).match(/^ {6}MAC_ONLY:\s*\$\{\{ inputs\.mac_only && 'true' \|\| 'false' \}\}\s*$/m)).not.toBeNull()
+ expect(withoutComments(jobBlock(RELEASE_YML, 'sbom-and-checksums')))
+ .toMatch(/^ {6}MAC_ONLY:\s*\$\{\{ inputs\.mac_only && 'true' \|\| 'false' \}\}\s*$/m)
+ // Every use of MAC_ONLY in a step is a guard on that value.
+ const uses = withoutComments(RELEASE_YML).split('\n').filter((l) => /MAC_ONLY/.test(l) && !/^ {6}MAC_ONLY:/.test(l))
+ for (const line of uses) expect(line).toMatch(/env\.MAC_ONLY == 'true'|"\$MAC_ONLY" = true/)
+ })
+
it('leaves the Latest flag alone and rebuilds the checksums', () => {
// enforce-prerelease reads PUBLISHED_TAG, which a dispatch does not set.
expect(withoutComments(jobBlock(RELEASE_YML, 'enforce-prerelease'))).toContain('PUBLISHED_TAG: ${{ github.event.release.tag_name }}')
- expect(withoutComments(jobBlock(RELEASE_YML, 'sbom-and-checksums')))
- .toContain("inputs.mac_only && needs.build-tauri-macos.result == 'success'")
+ const sums = withoutComments(jobBlock(RELEASE_YML, 'sbom-and-checksums'))
+ expect(sums).toContain("inputs.mac_only && needs.build-tauri-macos.result == 'success'")
+ expect(sums).toContain('SHA256SUMS.txt lists no .dmg')
+ expect(sums).toContain('SHA256SUMS.txt lists no updater archive')
})
})