Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Make publish-desktop-updater.yml manual-dispatch only (#8356)
Daniel Han08dfbdf45a72
diff --git a/.github/workflows/publish-desktop-updater.yml b/.github/workflows/publish-desktop-updater.ymlindex 987801466e3..8b1c554be02 100644--- a/.github/workflows/publish-desktop-updater.yml+++ b/.github/workflows/publish-desktop-updater.yml@@ -1,14 +1,19 @@name: Publish Desktop Release+# Manual dispatch only: sharing release-desktop.yml's concurrency group, a publish-fired+# run stalls the desktop build queued behind it -- and predates any bundles anyway.on:- release:- types: [published]workflow_dispatch:inputs:release_tag:- description: 'Unified v... release to expose once to legacy desktop-latest clients'+ description: 'Unified v... release to validate and expose to clients (for example, v0.1.61-beta)'type: stringrequired: true+ repair_pointer:+ description: 'Release carries no bundles of its own: carry the newest desktop manifest onto it so update checks stop 404ing'+ type: boolean+ required: false+ default: falsebridge_legacy_channel:description: 'One-time migration only: mirror this release manifest to existing desktop-latest'type: boolean@@ -26,15 +31,15 @@ concurrency:jobs:publish-updater:name: Validate published desktop release- if: >-- (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v')) ||- (github.event_name == 'workflow_dispatch' && inputs.bridge_legacy_channel)+ # A mistakenly flagged prerelease still reaches the job, so validation fails+ # visibly instead of silently skipping.+ if: ${{ startsWith(inputs.release_tag, 'v') }}runs-on: ubuntu-latestpermissions:contents: writeenv:GH_REPO: ${{ github.repository }}- RELEASE_TAG: ${{ github.event.release.tag_name || inputs.release_tag }}+ RELEASE_TAG: ${{ inputs.release_tag }}steps:- name: Harden runner (audit)@@ -42,19 +47,14 @@ jobs:with:egress-policy: audit- # The v... release is published before release-desktop.yml attaches the- # bundles, so this fires first on a release that carries none. Skip cleanly- # instead of failing; the desktop run advances the channel itself.+ # A release with no bundles is a normal dispatch, so decide from the assets: with+ # repair_pointer the run carries a manifest forward, without it nothing to validate.- name: Check for desktop bundlesid: gateenv:GH_TOKEN: ${{ github.token }}run: |set -euo pipefail- if [ "${{ github.event_name }}" != "release" ]; then- echo "proceed=true" >> "$GITHUB_OUTPUT"- exit 0- fiasset_names="$RUNNER_TEMP/release-asset-names.txt"# Fail closed: an unreadable release must not look like one with no bundles.if ! gh release view "$RELEASE_TAG" --json assets --jq '.assets[].name' > "$asset_names"; then@@ -74,8 +74,10 @@ jobs:# newest desktop manifest onto this release instead, so discovery follows# desktop metadata rather than release order. The manifest keeps its own# version and its URLs keep pointing at the immutable release that built it.+ # Validation and promotion below stay skipped; re-dispatch without repair_pointer+ # once the release carries its own bundles.- name: Carry desktop metadata forward- if: ${{ github.event_name == 'release' && steps.gate.outputs.proceed == 'false' }}+ if: ${{ inputs.repair_pointer && steps.gate.outputs.proceed == 'false' }}env:GH_TOKEN: ${{ github.token }}run: |@@ -96,6 +98,32 @@ jobs:semver = re.compile(r'^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?$')releases = json.loads(pathlib.Path(sys.argv[1]).read_text())++ # /releases/latest never resolves to a draft or prerelease, so a manifest+ # carried onto one cannot repair the endpoint however well the upload goes;+ # the source filter below already refuses them. Read the target from the+ # listing already fetched: /releases/tags/{tag} returns 404 for a draft,+ # which has no git tag until it is published.+ target = next(+ (r for r in releases if r.get('tag_name') == os.environ['RELEASE_TAG']),+ None,+ )+ # Fail closed: the listing is one page, so a target beyond it has a state+ # this step cannot read; skipping the check below would upload the manifest+ # and report a repair anyway.+ if target is None:+ sys.exit(+ f"{os.environ['RELEASE_TAG']} is not among the 100 most recent releases; "+ 'refusing to carry a manifest onto a target whose draft or '+ 'prerelease state cannot be checked'+ )+ if target.get('draft') or target.get('prerelease'):+ state = 'draft' if target.get('draft') else 'prerelease'+ sys.exit(+ f"{os.environ['RELEASE_TAG']} is a {state}, which /releases/latest never "+ 'resolves to; refusing to carry a manifest that cannot repair the pointer'+ )+candidates = [release for release in releasesif semver.fullmatch(release.get('tag_name') or '')@@ -145,14 +173,16 @@ jobs:PYgh release upload "$RELEASE_TAG" "$RUNNER_TEMP/carry-forward/latest.json" --clobberecho "Carried ${source_tag} updater metadata onto ${RELEASE_TAG}."- # GitHub moves /releases/latest when the release is published, before this- # job can start, so update checks 404 from that moment until the upload- # above. Record it: a long queue makes the gap worth knowing about.+ # GitHub moved /releases/latest when the release was published, so update+ # checks 404 from then until the upload above. Nothing is automatic now, so+ # record that gap: its length is a human response time.{printf '### Desktop updater pointer\n\n'printf '%s carried no desktop bundles, so it now serves the %s manifest.\n\n' \"$RELEASE_TAG" "$source_tag"printf 'Update checks returned 404 between the release being published and this upload.\n'+ printf '\nRe-dispatch without repair_pointer once %s carries its own bundles.\n' \+ "$RELEASE_TAG"} >> "$GITHUB_STEP_SUMMARY"- name: Download updater metadata@@ -166,20 +196,6 @@ jobs:gh release download "$RELEASE_TAG" --pattern latest.json --dir "$RUNNER_TEMP/desktop-updater"test -s "$RUNNER_TEMP/desktop-updater/latest.json"- - name: Remove standalone signature assets- if: ${{ github.event_name == 'release' && steps.gate.outputs.proceed == 'true' }}- env:- GH_TOKEN: ${{ github.token }}- run: |- set -euo pipefail- # Scoped to the desktop bundles: the v... release carries other assets too.- signature_assets="$(gh release view "$RELEASE_TAG" --json assets \- --jq '.assets[].name | select(startswith("Unsloth-Desktop-")) | select(endswith(".sig"))')"- while IFS= read -r asset_name; do- [[ -z "$asset_name" ]] || gh release delete-asset "$RELEASE_TAG" "$asset_name" --yes- done <<< "$signature_assets"- gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}" > "$RUNNER_TEMP/source-release.json"-- name: Validate updater metadataif: steps.gate.outputs.proceed == 'true'run: |@@ -238,7 +254,7 @@ jobs:PY- name: Prevent GitHub latest downgrade- if: ${{ github.event_name == 'release' && steps.gate.outputs.proceed == 'true' }}+ if: ${{ steps.gate.outputs.proceed == 'true' && !inputs.bridge_legacy_channel }}env:GH_TOKEN: ${{ github.token }}run: |@@ -303,8 +319,26 @@ jobs:PY+ # Deletion is permanent and the tag is now hand-typed, so every check that can+ # reject the target runs above this. Validation only asks whether each manifest+ # bundle is present, so the surviving .sig assets do not change its verdict.+ # The re-fetch keeps source-release.json current for the promotion below.+ - name: Remove standalone signature assets+ if: ${{ steps.gate.outputs.proceed == 'true' && !inputs.bridge_legacy_channel }}+ env:+ GH_TOKEN: ${{ github.token }}+ run: |+ set -euo pipefail+ # Scoped to the desktop bundles: the v... release carries other assets too.+ signature_assets="$(gh release view "$RELEASE_TAG" --json assets \+ --jq '.assets[].name | select(startswith("Unsloth-Desktop-")) | select(endswith(".sig"))')"+ while IFS= read -r asset_name; do+ [[ -z "$asset_name" ]] || gh release delete-asset "$RELEASE_TAG" "$asset_name" --yes+ done <<< "$signature_assets"+ gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}" > "$RUNNER_TEMP/source-release.json"+- name: Mark published release as GitHub latest- if: ${{ github.event_name == 'release' && steps.gate.outputs.proceed == 'true' }}+ if: ${{ steps.gate.outputs.proceed == 'true' && !inputs.bridge_legacy_channel }}env:GH_TOKEN: ${{ github.token }}run: |@@ -314,8 +348,11 @@ jobs:test "$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq .tag_name)" = "$RELEASE_TAG"test -n "$(gh release view "$RELEASE_TAG" --json assets --jq '.assets[] | select(.name == "latest.json") | .url')"+ # The gate conjunct is load-bearing: this step reads the manifest fetched by+ # "Download updater metadata", itself gated on proceed == 'true'. Without it a+ # repair_pointer run that also bridges would die on a file it never downloaded.- name: Bridge legacy desktop-latest clients once- if: ${{ github.event_name == 'workflow_dispatch' && inputs.bridge_legacy_channel }}+ if: ${{ steps.gate.outputs.proceed == 'true' && inputs.bridge_legacy_channel }}env:GH_TOKEN: ${{ github.token }}run: |diff --git a/tests/security/test_desktop_updater_pointer.py b/tests/security/test_desktop_updater_pointer.pyindex b42ecc1bd8f..abac606f197 100644--- a/tests/security/test_desktop_updater_pointer.py+++ b/tests/security/test_desktop_updater_pointer.py@@ -50,6 +50,8 @@ def _step_run():step = steps[STEP_NAME]# Only for a release that arrived without bundles of its own.assert "steps.gate.outputs.proceed == 'false'" in step["if"]+ # Nothing fires this workflow automatically, so the repair must be asked for.+ assert "inputs.repair_pointer" in step["if"]return step["run"]@@ -83,6 +85,7 @@ def _manifest(tag):def _run(tmp_path, *, release_tag, releases, manifest):+ tmp_path.mkdir(parents = True, exist_ok = True)fake_bin = tmp_path / "bin"fake_bin.mkdir()gh = fake_bin / "gh"@@ -152,6 +155,7 @@ def test_drafts_prereleases_and_bundleless_releases_are_never_the_source(tmp_pattmp_path,release_tag = "v0.1.53-beta",releases = [+ _release("v0.1.53-beta", has_manifest = False, published_at = "2026-04-01T00:00:00Z"),_release("v0.1.52-beta", draft = True, published_at = "2026-03-01T00:00:00Z"),_release("v0.1.51-beta", prerelease = True, published_at = "2026-02-01T00:00:00Z"),_release("v0.1.50-beta", has_manifest = False, published_at = "2026-01-01T00:00:00Z"),@@ -182,6 +186,7 @@ def test_an_already_carried_manifest_is_carried_forward_again(tmp_path):tmp_path,release_tag = "v0.1.54-beta",releases = [+ _release("v0.1.54-beta", has_manifest = False, published_at = "2026-05-01T00:00:00Z"),_release("v0.1.53-beta", published_at = "2026-04-01T00:00:00Z"),_release("v0.1.52-beta", published_at = "2026-03-01T00:00:00Z"),],@@ -195,7 +200,10 @@ def test_a_manifest_that_is_not_pinned_to_its_own_version_is_refused(tmp_path):result, commands = _run(tmp_path,release_tag = "v0.1.53-beta",- releases = [_release("v0.1.52-beta")],+ releases = [+ _release("v0.1.53-beta", has_manifest = False),+ _release("v0.1.52-beta"),+ ],manifest = {"version": "v0.1.52-beta","platforms": {@@ -215,8 +223,45 @@ def test_a_manifest_without_a_usable_version_is_refused(tmp_path):result, _ = _run(tmp_path,release_tag = "v0.1.53-beta",- releases = [_release("v0.1.52-beta")],+ releases = [+ _release("v0.1.53-beta", has_manifest = False),+ _release("v0.1.52-beta"),+ ],manifest = {"version": "latest", "platforms": {}},)assert result.returncode == 1assert "refusing to carry it forward" in result.stderr+++def test_a_draft_or_prerelease_target_is_refused(tmp_path):+ # /releases/latest never resolves to a draft or prerelease, so carrying a manifest+ # onto one cannot repair the endpoint. The source filter already refuses them; the+ # target is held to the same rule.+ for state in ("draft", "prerelease"):+ target = _release("v0.1.53-beta", has_manifest = False)+ target[state] = True+ result, commands = _run(+ tmp_path / state,+ release_tag = "v0.1.53-beta",+ releases = [target, _release("v0.1.52-beta")],+ manifest = _manifest("v0.1.52-beta"),+ )+ assert result.returncode != 0, f"{state} target was accepted"+ assert f"is a {state}" in result.stderr, result.stderr+ assert not [line for line in commands if line.startswith("gh release upload")], commands+++def test_a_target_missing_from_the_release_listing_is_refused(tmp_path):+ # The listing is the only view of the target's draft state: /releases/tags/{tag}+ # answers 404 for a draft, which has no git tag until it is published. A target+ # absent from that single page has an unverifiable state, so the draft/prerelease+ # refusal above would degrade into no check. Fail closed instead.+ result, commands = _run(+ tmp_path,+ release_tag = "v0.1.53-beta",+ releases = [_release("v0.1.52-beta")],+ manifest = _manifest("v0.1.52-beta"),+ )+ assert result.returncode != 0, result.stdout+ assert "is not among the 100 most recent releases" in result.stderr, result.stderr+ assert not [line for line in commands if line.startswith("gh release upload")], commandsdiff --git a/tests/security/test_release_desktop_permissions.py b/tests/security/test_release_desktop_permissions.pyindex a1039c39587..8ad0913af12 100644--- a/tests/security/test_release_desktop_permissions.py+++ b/tests/security/test_release_desktop_permissions.py@@ -198,17 +198,16 @@ def test_versioned_release_hides_updater_signature_assets():def test_publishing_draft_validates_normal_release_without_rebuilding():workflow = yaml.safe_load(UPDATER_WORKFLOW.read_text(encoding = "utf-8"))triggers = workflow.get("on", workflow.get(True))- assert triggers["release"] == {"types": ["published"]}- assert "workflow_dispatch" in triggers+ assert set(triggers) == {"workflow_dispatch"}assert workflow["permissions"] == {"contents": "read"}assert workflow["concurrency"]["queue"] == "max"job = workflow["jobs"]["publish-updater"]assert "build" not in workflow["jobs"]assert job["permissions"] == {"contents": "write"}- assert "startsWith(github.event.release.tag_name, 'v')" in job["if"]+ assert "startsWith(inputs.release_tag, 'v')" in job["if"]# The job runs for a mistakenly flagged prerelease so validation fails visibly.- assert "github.event.release.prerelease" not in job["if"]+ assert "prerelease" not in job["if"]assert not any("actions/checkout" in step.get("uses", "") for step in job["steps"])assert any("gh release delete-asset" in step.get("run", "") for step in job["steps"])@@ -240,8 +239,9 @@ def test_publishing_draft_validates_normal_release_without_rebuilding():for step in job["steps"]if step.get("name") == "Bridge legacy desktop-latest clients once")- assert "workflow_dispatch" in bridge["if"]assert "inputs.bridge_legacy_channel" in bridge["if"]+ # Without it the bridge reads a manifest that the gated download step never fetched.+ assert "steps.gate.outputs.proceed == 'true'" in bridge["if"]assert "gh release create desktop-latest" not in bridge["run"]assert "gh release upload desktop-latest" in bridge["run"]assert "--clobber" in bridge["run"]@@ -271,9 +271,47 @@ def test_the_updater_workflow_skips_releases_without_desktop_bundles():"Download updater metadata","Validate updater metadata","Remove standalone signature assets",+ "Prevent GitHub latest downgrade","Mark published release as GitHub latest",):assert "steps.gate.outputs.proceed == 'true'" in steps[name]["if"], name# The v... release is shared, so the sweep must not reach past desktop assets.assert 'startswith("Unsloth-Desktop-")' in steps["Remove standalone signature assets"]["run"]+++def test_the_updater_workflow_validates_the_target_before_deleting_its_assets():+ """The tag is typed by hand, so a mistyped or mis-flagged one names a real+ older release. Deleting release assets cannot be undone, so every check that+ rejects the target has to run before the sweep, or the rejected release is+ already missing its signatures by the time the run fails."""+ job = yaml.safe_load(UPDATER_WORKFLOW.read_text(encoding = "utf-8"))["jobs"]["publish-updater"]+ order = [step.get("name") for step in job["steps"]]++ remove = order.index("Remove standalone signature assets")+ for name in ("Validate updater metadata", "Prevent GitHub latest downgrade"):+ assert order.index(name) < remove, name+ # Still ahead of the promotion, which points clients here and reads the JSON it refreshes.+ assert remove < order.index("Mark published release as GitHub latest")+++def test_the_updater_workflow_is_manual_dispatch_only():+ """It shares a concurrency group with release-desktop.yml, so an auto-fired+ run queues ahead of the desktop build dispatched right after it and stalls+ the release. Nothing may start this workflow except a maintainer."""+ workflow = yaml.safe_load(UPDATER_WORKFLOW.read_text(encoding = "utf-8"))+ triggers = workflow.get("on", workflow.get(True))+ assert set(triggers) == {"workflow_dispatch"}, triggers++ job = workflow["jobs"]["publish-updater"]+ # A leftover github.event.release ref is null under dispatch: silently false, not an error.+ conditions = [job["if"]] + [step["if"] for step in job["steps"] if "if" in step]+ for condition in conditions:+ assert "github.event" not in condition, condition++ # Dropping the release trigger is only safe while the pointer repair stays reachable.+ carry = next(+ step for step in job["steps"] if step.get("name") == "Carry desktop metadata forward"+ )+ assert "inputs.repair_pointer" in carry["if"]+ assert triggers["workflow_dispatch"]["inputs"]["repair_pointer"]["default"] is False