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.

ci(release): the prerelease promise holds on every trigger, not just dispatch

David913d84558c96
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a67f200b..9ec43a9c 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -184,5 +184,31 @@ jobs:
# Prerelease keeps `releases/latest` on the last verified version.
# Flipping to Latest is the separate, deliberate step that happens
# after the build is installed and checked on a real machine.
+ #
+ # This input alone is NOT the guarantee. tauri-action passes
+ # draft/prerelease to createRelease only, so on this workflow's own
+ # primary trigger (`on: release: [published]`, where the release by
+ # definition already exists) the action reuses the release untouched
+ # and the input does nothing. The enforce-prerelease job below is what
+ # actually holds the promise.
prerelease: true
args: ${{ matrix.args }}
+
+ # The promise above, made real for every trigger. Runs after the binaries are
+ # attached, so a release published as a full release is put back before
+ # anyone is offered it, and never touches the release that is already Latest.
+ enforce-prerelease:
+ needs: build-tauri
+ if: always()
+ runs-on: ubuntu-22.04
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
+ with:
+ node-version: 20
+ - name: Keep the release out of Latest until it is verified
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_REPOSITORY: ${{ github.repository }}
+ TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }}
+ run: node scripts/enforce-prerelease.mjs
diff --git a/scripts/enforce-prerelease.mjs b/scripts/enforce-prerelease.mjs
new file mode 100644
index 00000000..1b11c001
--- /dev/null
+++ b/scripts/enforce-prerelease.mjs
@@ -0,0 +1,62 @@
+#!/usr/bin/env node
+/**
+ * Put the release this build belongs to back into prerelease, unless it is the
+ * one someone has already flipped to Latest.
+ *
+ * release.yml asks tauri-action for `prerelease: true`, and on the workflow's
+ * own primary trigger that input is ignored: tauri-action only passes the flag
+ * to createRelease, and on `on: release: [published]` the release already
+ * exists, so the action reuses it untouched. A release published as a full
+ * release therefore became GitHub's `latest` the moment CI attached the
+ * binaries, with the download routes and every installed updater following
+ * within minutes. That is exactly the 2026-08-10 incident the comment in
+ * release.yml describes as fixed.
+ *
+ * Idempotent, and it can never undo a deliberate flip: the release that IS
+ * Latest is left alone.
+ *
+ * Usage: TAG=v2.6.5 node scripts/enforce-prerelease.mjs
+ */
+
+import { shouldForcePrerelease } from './release-rules.mjs'
+
+const repo = process.env.GITHUB_REPOSITORY ?? 'PurpleDoubleD/locally-uncensored'
+const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN
+const tag = process.env.TAG
+if (!token) {
+ console.error('GITHUB_TOKEN missing')
+ process.exit(1)
+}
+if (!tag) {
+ console.error('TAG missing')
+ process.exit(1)
+}
+
+const api = async (path, init = {}) => {
+ const res = await fetch(`https://api.github.com/repos/${repo}${path}`, {
+ ...init,
+ headers: {
+ Accept: 'application/vnd.github+json',
+ Authorization: `Bearer ${token}`,
+ 'User-Agent': 'lu-enforce-prerelease',
+ ...(init.headers ?? {}),
+ },
+ })
+ if (!res.ok) throw new Error(`${init.method ?? 'GET'} ${path} -> ${res.status} ${await res.text()}`)
+ return res.json()
+}
+
+const rel = await api(`/releases/tags/${tag}`)
+// A repo whose only release is this one has no `latest` to compare against.
+const latest = await api('/releases/latest').catch(() => null)
+
+if (!shouldForcePrerelease(rel, latest)) {
+ console.log(`${tag} needs nothing: prerelease=${rel.prerelease}, draft=${rel.draft}, isLatest=${rel.id === latest?.id}`)
+ process.exit(0)
+}
+
+await api(`/releases/${rel.id}`, {
+ method: 'PATCH',
+ body: JSON.stringify({ prerelease: true, make_latest: 'false' }),
+})
+console.log(`${tag} was a full release and has been put back to prerelease. Flip it to Latest by hand once it is verified.`)
diff --git a/scripts/mark-old-releases.mjs b/scripts/mark-old-releases.mjs
index c6ac4c13..ed5d09ef 100644
--- a/scripts/mark-old-releases.mjs
+++ b/scripts/mark-old-releases.mjs
@@ -14,7 +14,7 @@
* re-run or a manual dispatch is free.
*/
-import { MARKER, BANNER, withoutBanner, shouldCarryBanner } from './release-banner-rules.mjs'
+import { MARKER, BANNER, withoutBanner, shouldCarryBanner } from './release-rules.mjs'
const repo = process.env.GITHUB_REPOSITORY ?? 'PurpleDoubleD/locally-uncensored'
const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN
diff --git a/scripts/release-banner-rules.d.mts b/scripts/release-rules.d.mts
similarity index 81%
rename from scripts/release-banner-rules.d.mts
rename to scripts/release-rules.d.mts
index a2a85c68..4e1d97f4 100644
--- a/scripts/release-banner-rules.d.mts
+++ b/scripts/release-rules.d.mts
@@ -19,3 +19,8 @@ export declare function shouldCarryBanner(
rel: GitHubRelease,
latest: GitHubRelease | null | undefined,
): boolean
+
+export declare function shouldForcePrerelease(
+ rel: GitHubRelease | null | undefined,
+ latest: GitHubRelease | null | undefined,
+): boolean
diff --git a/scripts/release-banner-rules.mjs b/scripts/release-rules.mjs
similarity index 56%
rename from scripts/release-banner-rules.mjs
rename to scripts/release-rules.mjs
index 172bb95c..99553781 100644
--- a/scripts/release-banner-rules.mjs
+++ b/scripts/release-rules.mjs
@@ -1,9 +1,9 @@
/**
- * Which releases carry the "old release" banner.
+ * The rules about release state that CI applies, in one testable place.
*
- * Pulled out of mark-old-releases.mjs so the rule can be tested without a
- * GitHub token. The script itself is a top-level-await program that talks to
- * the API on import, and the rule is the only part that can be wrong quietly.
+ * Both callers are top-level-await programs that talk to the GitHub API on
+ * import, so the part that can be wrong quietly lives here instead, where a
+ * test can reach it without a token.
*/
export const MARKER = '<!-- lu-old-release-banner -->'
@@ -46,3 +46,27 @@ export function shouldCarryBanner(rel, latest) {
const upcoming = (rel.prerelease === true || rel.draft === true) && stamp(rel) >= stamp(latest)
return !upcoming
}
+
+/**
+ * True when this release must be forced back to prerelease.
+ *
+ * release.yml passes `prerelease: true` to tauri-action, and on the workflow's
+ * OWN primary trigger that input does nothing. tauri-action only passes
+ * draft/prerelease to createRelease (src/create-release.ts): when the release
+ * already exists, which it always does on `on: release: [published]`, the
+ * action reuses it and never patches the flag. So the guarantee written into
+ * that comment ("a build is not a decision") held for workflow_dispatch and
+ * for nothing else, and a release published as a full release went straight to
+ * Latest with the download routes and every updater following within minutes.
+ * That is the 2026-08-10 incident the comment says was fixed.
+ *
+ * The rule is the same one the banner uses, from the other side: a release
+ * that is not the flagged Latest has not been verified yet, so it belongs in
+ * prerelease. The deliberate flip to Latest is what takes it out, and this
+ * must never undo that flip.
+ */
+export function shouldForcePrerelease(rel, latest) {
+ if (!rel || rel.prerelease === true || rel.draft === true) return false
+ if (latest && rel.id === latest.id) return false
+ return true
+}
diff --git a/src/lib/__tests__/release-banner-rules.test.ts b/src/lib/__tests__/release-rules.test.ts
similarity index 55%
rename from src/lib/__tests__/release-banner-rules.test.ts
rename to src/lib/__tests__/release-rules.test.ts
index 7b95cc3b..74d0de97 100644
--- a/src/lib/__tests__/release-banner-rules.test.ts
+++ b/src/lib/__tests__/release-rules.test.ts
@@ -12,7 +12,10 @@
* Run: npx vitest run src/lib/__tests__/release-banner-rules.test.ts
*/
import { describe, it, expect } from 'vitest'
-import { shouldCarryBanner, withoutBanner, BANNER, MARKER } from '../../../scripts/release-banner-rules.mjs'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve } from 'node:path'
+import { shouldCarryBanner, shouldForcePrerelease, withoutBanner, BANNER, MARKER } from '../../../scripts/release-rules.mjs'
const rel = (over: Record<string, unknown> = {}) => ({
id: 1, tag_name: 'v1', prerelease: false, draft: false,
@@ -83,3 +86,59 @@ describe('the banner text itself', () => {
expect(BANNER.startsWith(MARKER)).toBe(true)
})
})
+
+// P4 from the review, confirmed at the source of the pinned action. release.yml
+// passes `prerelease: true` to tauri-action, and tauri-action hands
+// draft/prerelease to createRelease ONLY (src/create-release.ts at
+// 51a9f115): when the release already exists, which it always does on
+// `on: release: [published]`, the action reuses it and never patches the flag.
+// So the guarantee in that comment held for workflow_dispatch and nothing else,
+// and a release published as a full release went straight to Latest with the
+// download routes and every updater following. That is the 2026-08-10 incident
+// the comment claims was fixed.
+describe('a build is not a decision, on every trigger', () => {
+ const latest = rel({ id: 100, tag_name: 'v2.6.4', published_at: '2026-08-10T00:00:00Z' })
+
+ it('a full release that is not Latest is forced back', () => {
+ const fresh = rel({ id: 3, tag_name: 'v2.6.5', prerelease: false })
+ expect(shouldForcePrerelease(fresh, latest)).toBe(true)
+ })
+
+ it('the release that IS Latest is never touched, or the flip would undo itself', () => {
+ expect(shouldForcePrerelease(latest, latest)).toBe(false)
+ })
+
+ it('a release already marked prerelease needs nothing', () => {
+ expect(shouldForcePrerelease(rel({ id: 4, prerelease: true }), latest)).toBe(false)
+ })
+
+ it('a draft is left alone', () => {
+ expect(shouldForcePrerelease(rel({ id: 5, draft: true }), latest)).toBe(false)
+ })
+
+ it('the very first release of a repo, with no Latest to compare, is still held back', () => {
+ expect(shouldForcePrerelease(rel({ id: 6, prerelease: false }), null)).toBe(true)
+ })
+})
+
+describe('the workflow actually calls it', () => {
+ const wf = readFileSync(
+ resolve(dirname(fileURLToPath(import.meta.url)), '../../../.github/workflows/release.yml'), 'utf8',
+ )
+
+ it('after the binaries are attached, not before', () => {
+ expect(wf).toContain('enforce-prerelease:')
+ expect(wf).toContain('needs: build-tauri')
+ expect(wf).toContain('node scripts/enforce-prerelease.mjs')
+ })
+
+ it('with the tag from either trigger', () => {
+ expect(wf).toContain('TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }}')
+ })
+
+ it('and even when a platform of the matrix failed', () => {
+ // A failed Linux lane must not leave a full release standing.
+ const job = wf.slice(wf.indexOf('enforce-prerelease:'))
+ expect(job).toContain('if: always()')
+ })
+})