Skip to content

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.

Desktop: publish stable latest downloads (#9652)

oobabooga493e6378fc6a
diff --git a/.github/workflows/publish-desktop-updater.yml b/.github/workflows/publish-desktop-updater.yml
index 99b931669c2..802211225cf 100644
--- a/.github/workflows/publish-desktop-updater.yml
+++ b/.github/workflows/publish-desktop-updater.yml
@@ -10,7 +10,7 @@ on:
type: string
required: true
repair_pointer:
- description: 'Release carries no bundles of its own: carry the newest desktop manifest onto it so update checks stop 404ing'
+ description: 'Release carries no bundles of its own: restore the newest complete Desktop release as GitHub latest'
type: boolean
required: false
default: false
@@ -47,12 +47,12 @@ jobs:
with:
egress-policy: audit
- # 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.
+ # Only validate complete Desktop publications; bundleless releases are normal.
- name: Check for desktop bundles
id: gate
env:
GH_TOKEN: ${{ github.token }}
+ REPAIR_POINTER: ${{ inputs.repair_pointer }}
run: |
set -euo pipefail
asset_names="$RUNNER_TEMP/release-asset-names.txt"
@@ -61,35 +61,63 @@ jobs:
echo "Could not list assets on ${RELEASE_TAG}; refusing to advance the channel." >&2
exit 1
fi
- if grep -Fxq 'latest.json' "$asset_names"; then
+ # Releases built before the rename carry the version in each filename, so
+ # completeness is judged against this tag's own scheme. Both spellings are
+ # whole publications; only a mixture of the two is partial. The same rule
+ # decides a repair source below, and the two must not disagree.
+ version="$(printf '%s' "${RELEASE_TAG#v}" | sed 's/[^0-9A-Za-z][^0-9A-Za-z]*/_/g; s/^_//; s/_$//')"
+ suffixes=(MacOS.dmg Linux.AppImage Ubuntu.deb Windows.exe)
+ stable_count=0
+ versioned_count=0
+ for suffix in "${suffixes[@]}"; do
+ if grep -Fxq "Unsloth-Desktop-${suffix}" "$asset_names"; then
+ stable_count=$(( stable_count + 1 ))
+ fi
+ if grep -Fxq "Unsloth-Desktop-${version}-${suffix}" "$asset_names"; then
+ versioned_count=$(( versioned_count + 1 ))
+ fi
+ done
+ complete=false
+ if [ "$stable_count" -eq "${#suffixes[@]}" ] || [ "$versioned_count" -eq "${#suffixes[@]}" ]; then
+ complete=true
+ fi
+ if grep -Fxq 'latest.json' "$asset_names" && [ "$complete" = 'true' ]; then
echo "proceed=true" >> "$GITHUB_OUTPUT"
+ elif grep -Fxq 'latest.json' "$asset_names" || grep -q '^Unsloth-Desktop-' "$asset_names"; then
+ # Half a publication: bundles without a manifest, a manifest without
+ # bundles, or some of each. Never validate it. Never block the repair
+ # either: the repair reads other releases and writes nothing here, and
+ # this is one of the states that leaves the pointer needing repair.
+ if [ "$REPAIR_POINTER" = 'true' ]; then
+ echo "${RELEASE_TAG} carries no complete Desktop publication; repairing the pointer instead."
+ echo "proceed=false" >> "$GITHUB_OUTPUT"
+ else
+ echo "${RELEASE_TAG} has an incomplete Desktop publication (${stable_count}/${#suffixes[@]} stable and ${versioned_count}/${#suffixes[@]} versioned downloads); refusing a partial publication." >&2
+ exit 1
+ fi
else
- echo "${RELEASE_TAG} carries no latest.json yet; nothing to validate."
+ echo "${RELEASE_TAG} carries no Desktop publication yet; nothing to validate."
echo "proceed=false" >> "$GITHUB_OUTPUT"
fi
- # /releases/latest is repo-wide, so publishing a v... release that carries no
- # desktop bundles moves that pointer to a release with no latest.json and
- # every client's update check 404s until the next desktop build. Copy the
- # 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
+ # /releases/latest is repo-wide. A bundleless release moves updater discovery
+ # and stable downloads to a 404, so restore the newest complete Desktop release
+ # as latest without duplicating its binaries.
+ - name: Restore latest complete Desktop release
if: ${{ inputs.repair_pointer && steps.gate.outputs.proceed == 'false' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
- if ! [[ "$RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$ ]]; then
- echo "${RELEASE_TAG} is not a v{SemVer} release; leaving the updater pointer alone."
- exit 0
- fi
+ # The target's tag shape does not matter: nothing is written to it. A
+ # prebuilt llama.cpp release (b8475) or a dated one takes the repo-wide
+ # pointer exactly as a bundleless v... release does, and takes the stable
+ # download links down with it, so all of them are repairable here.
+ #
# 100 most recent releases: far more than the gap between desktop builds,
# and one page keeps this to a single API call.
gh api "repos/${GITHUB_REPOSITORY}/releases?per_page=100" > "$RUNNER_TEMP/releases.json"
- source_tag="$(python3 - "$RUNNER_TEMP/releases.json" <<'PY'
+ python3 - "$RUNNER_TEMP/releases.json" "$RUNNER_TEMP/candidates.json" <<'PY'
import json
import os
import pathlib
@@ -98,30 +126,48 @@ 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())
+ SUFFIXES = ('MacOS.dmg', 'Linux.AppImage', 'Ubuntu.deb', 'Windows.exe')
+
+ def asset_prefixes(tag):
+ version = re.sub(r'[^0-9A-Za-z]+', '_', tag.removeprefix('v')).strip('_')
+ return ('Unsloth-Desktop', f'Unsloth-Desktop-{version}')
- # /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.
+ def has_complete_downloads(release):
+ names = {asset.get('name') for asset in release.get('assets', [])}
+ return any(
+ {'latest.json', *(f'{prefix}-{suffix}' for suffix in SUFFIXES)}.issubset(names)
+ for prefix in asset_prefixes(release.get('tag_name', ''))
+ )
+
+ def version_key(tag):
+ """SemVer precedence, so publish order can never pick an older build."""
+ major, minor, patch = (int(part) for part in re.findall(r'\d+', tag.split('-')[0]))
+ pre = tag.split('-', 1)[1] if '-' in tag else None
+ if pre is None:
+ return ((major, minor, patch), (1,))
+ identifiers = []
+ for part in pre.split('.'):
+ # Numeric identifiers rank below alphanumeric ones, as SemVer says.
+ identifiers.append((0, int(part), '') if part.isdigit() else (1, 0, part))
+ return ((major, minor, patch), (0, tuple(identifiers)))
+
+ # Read the target here because /releases/tags/{tag} returns 404 for drafts.
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.
+ # Fail closed when a target beyond this page has an unreadable state.
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 '
+ 'refusing to repair latest for 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'
+ 'resolves to; refusing a repair that cannot affect the pointer'
)
candidates = [
@@ -129,58 +175,163 @@ jobs:
if semver.fullmatch(release.get('tag_name') or '')
and release.get('tag_name') != os.environ['RELEASE_TAG']
and not release.get('draft') and not release.get('prerelease')
- and any(asset.get('name') == 'latest.json' for asset in release.get('assets', []))
+ and has_complete_downloads(release)
]
- # Newest by publish time. A downgrade here only withholds an update
- # prompt, never offers an older build: clients compare versions.
- candidates.sort(key=lambda release: release.get('published_at') or '', reverse=True)
- print(candidates[0]['tag_name'] if candidates else '')
+ # Highest version first, publish time only as a tie-break: a release
+ # republished out of order must not drag the pointer onto an older build.
+ candidates.sort(
+ key=lambda release: (
+ version_key(release['tag_name']),
+ release.get('published_at') or '',
+ ),
+ reverse=True,
+ )
+ chosen = []
+ for release in candidates:
+ release_id = release.get('id')
+ if not isinstance(release_id, int):
+ sys.exit(f"{release.get('tag_name')} is missing its GitHub release id")
+ tag = release['tag_name']
+ chosen.append({
+ 'tag': tag,
+ 'id': release_id,
+ 'assets': sorted(
+ name for name in (a.get('name') for a in release.get('assets', []))
+ if isinstance(name, str)
+ ),
+ # A pre-rename release restores update checks but not the stable
+ # download links, which only exist on releases built after it.
+ 'stable_names': {f'Unsloth-Desktop-{s}' for s in SUFFIXES}.issubset(
+ {a.get('name') for a in release.get('assets', [])}
+ ),
+ })
+ pathlib.Path(sys.argv[2]).write_text(json.dumps(chosen))
PY
- )"
- if [ -z "$source_tag" ]; then
- echo "No published release carries latest.json yet; nothing to carry forward."
- exit 0
- fi
- mkdir -p "$RUNNER_TEMP/carry-forward"
- gh release download "$source_tag" --pattern latest.json \
- --dir "$RUNNER_TEMP/carry-forward" --clobber
- SOURCE_TAG="$source_tag" python3 <<'PY'
+
+ # Validate candidates newest first and restore the first sound one. One bad
+ # manifest must not end the repair while a good pointer target is waiting.
+ cat > "$RUNNER_TEMP/validate-source.py" <<'PY'
import json
import os
import pathlib
import re
import sys
+ import urllib.parse
source_tag = os.environ['SOURCE_TAG']
- data = json.loads(pathlib.Path(os.environ['RUNNER_TEMP'], 'carry-forward', 'latest.json').read_text())
+ assets = set(json.loads(os.environ['SOURCE_ASSETS']))
+ data = json.loads(pathlib.Path(
+ os.environ['RUNNER_TEMP'], 'restore-latest', 'latest.json'
+ ).read_text())
version = data.get('version')
semver = r'v?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?'
if not isinstance(version, str) or not re.fullmatch(semver, version):
- sys.exit(f'{source_tag} latest.json declares version {version!r}; refusing to carry it forward')
+ sys.exit(f'{source_tag} latest.json declares invalid version {version!r}')
- # Pinned to the release its own version names, which is the source release
- # for a freshly built manifest and an older one for an already carried
- # manifest. Either is safe to carry forward; the bundles are immutable.
bundle_tag = version if version.startswith('v') else f'v{version}'
- expected_prefix = f'https://github.com/{os.environ["GITHUB_REPOSITORY"]}/releases/download/{bundle_tag}/'
+ if bundle_tag != source_tag:
+ sys.exit(f'{source_tag} latest.json names {bundle_tag}; refusing to restore a pointer release')
+ expected_prefix = f'https://github.com/{os.environ["GITHUB_REPOSITORY"]}/releases/download/{source_tag}/'
platforms = data.get('platforms')
if not isinstance(platforms, dict) or not platforms:
sys.exit(f'{source_tag} latest.json has no platforms')
- for platform, entry in platforms.items():
+ for platform, entry in sorted(platforms.items()):
url = (entry or {}).get('url')
+ signature = (entry or {}).get('signature')
if not isinstance(url, str) or not url.startswith(expected_prefix):
- sys.exit(f'{source_tag} latest.json {platform} URL is not pinned to {bundle_tag}: {url}')
+ sys.exit(f'{source_tag} latest.json {platform} URL is not pinned to its release: {url}')
+ if not isinstance(signature, str) or not signature.strip():
+ sys.exit(f'{source_tag} latest.json {platform} has no signature')
+ # Prefix-matching a URL says nothing about the asset still being there.
+ # Promoting a release whose manifest names a deleted bundle hands every
+ # client on that platform a 404 instead of an update.
+ bundle = urllib.parse.unquote(urllib.parse.urlparse(url).path.rsplit('/', 1)[-1])
+ if bundle not in assets:
+ sys.exit(f'{source_tag} latest.json {platform} names a missing asset: {bundle}')
PY
- gh release upload "$RELEASE_TAG" "$RUNNER_TEMP/carry-forward/latest.json" --clobber
- echo "Carried ${source_tag} updater metadata onto ${RELEASE_TAG}."
- # 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.
+
+ source_tag=''
+ source_id=''
+ source_has_stable_names=''
+ candidate_count="$(python3 -c 'import json,os,pathlib; print(len(json.loads(pathlib.Path(os.environ["RUNNER_TEMP"], "candidates.json").read_text())))')"
+ index=0
+ while [ "$index" -lt "$candidate_count" ]; do
+ entry="$(INDEX="$index" python3 -c 'import json,os,pathlib; print(json.dumps(json.loads(pathlib.Path(os.environ["RUNNER_TEMP"], "candidates.json").read_text())[int(os.environ["INDEX"])]))')"
+ candidate_tag="$(printf '%s' "$entry" | python3 -c 'import json,sys; print(json.load(sys.stdin)["tag"])')"
+ candidate_id="$(printf '%s' "$entry" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
+ candidate_assets="$(printf '%s' "$entry" | python3 -c 'import json,sys; print(json.dumps(json.load(sys.stdin)["assets"]))')"
+ candidate_stable="$(printf '%s' "$entry" | python3 -c 'import json,sys; print(json.load(sys.stdin)["stable_names"])')"
+ index=$(( index + 1 ))
+ rm -rf "$RUNNER_TEMP/restore-latest"
+ mkdir -p "$RUNNER_TEMP/restore-latest"
+ if ! gh release download "$candidate_tag" --pattern latest.json \
+ --dir "$RUNNER_TEMP/restore-latest" --clobber; then
+ echo "${candidate_tag} has no readable latest.json; trying the next candidate." >&2
+ continue
+ fi
+ if ! SOURCE_TAG="$candidate_tag" SOURCE_ASSETS="$candidate_assets" \
+ python3 "$RUNNER_TEMP/validate-source.py"; then
+ echo "${candidate_tag} is not a sound pointer target; trying the next candidate." >&2
+ continue
+ fi
+ source_tag="$candidate_tag"
+ source_id="$candidate_id"
+ source_has_stable_names="$candidate_stable"
+ break
+ done
+
+ if [ -z "$source_tag" ]; then
+ echo "No published release carries a sound complete Desktop publication; nothing to restore." >&2
+ {
+ printf '### Desktop updater pointer\n\n'
+ printf 'GitHub latest still points at %s, which carries no Desktop build.\n\n' "$RELEASE_TAG"
+ printf 'No release among the 100 most recent could be restored, so update checks and\n'
+ printf 'stable downloads are still returning 404. Publish a Desktop release to fix this.\n'
+ } >> "$GITHUB_STEP_SUMMARY"
+ exit 1
+ fi
+
+ # Re-read the pointer against the world as it is now, not as the listing
+ # above found it. Promoting an older release over a healthy newer one, or
+ # over one another job just published, hands every client an older manifest.
+ current_latest="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq .tag_name 2>/dev/null || true)"
+ if [ "$current_latest" != "$RELEASE_TAG" ]; then
+ echo "GitHub latest is ${current_latest:-unset}, not ${RELEASE_TAG}; nothing to repair."
+ {
+ printf '### Desktop updater pointer\n\n'
+ printf 'Left GitHub latest on %s: it is no longer %s, so there was nothing to repair.\n' \
+ "${current_latest:-unset}" "$RELEASE_TAG"
+ } >> "$GITHUB_STEP_SUMMARY"
+ exit 0
+ fi
+
+ gh api --method PATCH "repos/${GITHUB_REPOSITORY}/releases/${source_id}" \
+ -f make_latest=true > "$RUNNER_TEMP/restored-latest.json"
+ # The pointer is read back rather than assumed, with a little patience for
+ # propagation so a slow read does not report a repair that did happen as a
+ # failure. A disagreement that outlives the retries is a real one.
+ restored=''
+ for _ in 1 2 3 4 5; do
+ restored="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq .tag_name 2>/dev/null || true)"
+ [ "$restored" = "$source_tag" ] && break
+ sleep 2
+ done
+ if [ "$restored" != "$source_tag" ]; then
+ echo "GitHub latest reads ${restored:-unset} after promoting ${source_tag}; another run may have moved it." >&2
+ exit 1
+ fi
+ echo "Restored ${source_tag} as GitHub latest while ${RELEASE_TAG} has no Desktop build."
+ # Record the gap while GitHub latest pointed at a bundleless release.
{
printf '### Desktop updater pointer\n\n'
- printf '%s carried no desktop bundles, so it now serves the %s manifest.\n\n' \
+ printf '%s carries no desktop bundles, so GitHub latest now points back to %s.\n\n' \
"$RELEASE_TAG" "$source_tag"
- printf 'Update checks returned 404 between the release being published and this upload.\n'
+ printf 'Update checks and stable downloads returned 404 between publication and this repair.\n'
+ if [ "$source_has_stable_names" != 'True' ]; then
+ printf '\n%s predates the stable asset names, so update checks work again but the\n' "$source_tag"
+ printf 'stable /releases/latest/download/Unsloth-Desktop-... links are still 404\n'
+ printf 'until a release built with the stable names is published.\n'
+ fi
printf '\nRe-dispatch without repair_pointer once %s carries its own bundles.\n' \
"$RELEASE_TAG"
} >> "$GITHUB_STEP_SUMMARY"
@@ -218,6 +369,17 @@ jobs:
if source.get('prerelease'):
sys.exit(f'{release_tag} must be a normal GitHub release, not a prerelease')
release_assets = {asset.get('name') for asset in source.get('assets', [])}
+ # Same rule as the gate: this tag's own naming scheme, whichever it is.
+ asset_version = re.sub(r'[^0-9A-Za-z]+', '_', match.group(1)).strip('_')
+ suffixes = ('MacOS.dmg', 'Linux.AppImage', 'Ubuntu.deb', 'Windows.exe')
+ download_sets = {
+ prefix: {f'{prefix}-{suffix}' for suffix in suffixes}
+ for prefix in ('Unsloth-Desktop', f'Unsloth-Desktop-{asset_version}')
+ }
+ if not any(names.issubset(release_assets) for names in download_sets.values()):
+ missing = sorted(min(download_sets.values(), key=lambda names: len(names - release_assets))
+ - release_assets)
+ sys.exit(f'{release_tag} is missing public Desktop downloads: {missing}')
latest_path = pathlib.Path(os.environ['RUNNER_TEMP'], 'desktop-updater', 'latest.json')
data = json.loads(latest_path.read_text())
@@ -346,7 +508,30 @@ jobs:
release_id="$(python3 -c 'import json,os,pathlib; print(json.loads(pathlib.Path(os.environ["RUNNER_TEMP"], "source-release.json").read_text())["id"])')"
gh api --method PATCH "repos/${GITHUB_REPOSITORY}/releases/${release_id}" -f make_latest=true >/dev/null
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')"
+ gh release view "$RELEASE_TAG" --json assets --jq '[.assets[].name]' \
+ > "$RUNNER_TEMP/promoted-asset-names.json"
+ python3 <<'PY'
+ import json
+ import os
+ import pathlib
+ import re
+ import sys
+
+ names = set(json.loads(
+ pathlib.Path(os.environ['RUNNER_TEMP'], 'promoted-asset-names.json').read_text()
+ ))
+ tag = os.environ['RELEASE_TAG']
+ # The same either-scheme rule the gate applied to let this release through.
+ version = re.sub(r'[^0-9A-Za-z]+', '_', tag.removeprefix('v')).strip('_')
+ suffixes = ('MacOS.dmg', 'Linux.AppImage', 'Ubuntu.deb', 'Windows.exe')
+ if 'latest.json' not in names:
+ sys.exit(f'{tag} is GitHub latest but serves no latest.json')
+ if not any(
+ {f'{prefix}-{suffix}' for suffix in suffixes}.issubset(names)
+ for prefix in ('Unsloth-Desktop', f'Unsloth-Desktop-{version}')
+ ):
+ sys.exit(f'{tag} is GitHub latest but serves no complete Desktop download set')
+ PY
# The gate conjunct is load-bearing: this step reads the manifest fetched by
# "Download updater metadata", itself gated on proceed == 'true'. Without it a
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 61171c8672c..a83b8d1909e 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -3,8 +3,8 @@ name: Release Desktop App
on:
workflow_dispatch:
# Both version inputs are free text in the dispatch UI, and studio_version
- # alone decides the release tag, all nine asset filenames and the updater
- # manifest version together. Near-miss tags are the failure mode worth
+ # alone decides the release tag and updater manifest version. Asset filenames
+ # stay stable across releases. Near-miss tags are the failure mode worth
# guarding, because they look right at a glance:
#
# studio_version v0.1.52-beta correct
@@ -38,9 +38,9 @@ env:
DESKTOP_RELEASE_NOTES: |
Desktop app for Unsloth.
- **macOS**: Download the Apple Silicon `.dmg`.
- **Windows**: Download the `-setup.exe` installer.
- **Linux**: Download `.deb` for Ubuntu/Debian. `.AppImage` is experimental.
+ **macOS**: Download `Unsloth-Desktop-MacOS.dmg` (Apple Silicon).
+ **Windows**: Download `Unsloth-Desktop-Windows.exe`.
+ **Linux**: Download `Unsloth-Desktop-Ubuntu.deb` for Ubuntu/Debian. `.AppImage` is experimental.
> Linux in-app updates are AppImage-oriented. Package installs should update by downloading a new package.
> Linux AppImage can show a blank window on some Tauri/WebKitGTK + Wayland/Mesa stacks; use `.deb` when available.
@@ -71,7 +71,6 @@ jobs:
outputs:
studio_version: ${{ steps.prepare.outputs.studio_version }}
app_version: ${{ steps.prepare.outputs.app_version }}
- asset_version: ${{ steps.prepare.outputs.asset_version }}
desktop_release_tag: ${{ steps.prepare.outputs.desktop_release_tag }}
pypi_version: ${{ steps.backend.outputs.pypi_version }}
@@ -126,7 +125,6 @@ jobs:
sys.exit(f'studio_version must be a SemVer tag with leading v, for example v0.1.52-beta: {studio_version}')
app_version = studio_version.removeprefix('v')
- asset_version = re.sub(r'[^0-9A-Za-z]+', '_', app_version).strip('_')
desktop_release_tag = studio_version
# Both updater paths compare SemVer, so a tag whose numbers go backwards
@@ -189,7 +187,6 @@ jobs:
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:
print(f'studio_version={studio_version}', file=output)
print(f'app_version={app_version}', file=output)
- print(f'asset_version={asset_version}', file=output)
print(f'desktop_release_tag={desktop_release_tag}', file=output)
PY
@@ -281,7 +278,6 @@ jobs:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
DESKTOP_RELEASE_TAG: ${{ steps.prepare.outputs.desktop_release_tag }}
- ASSET_VERSION: ${{ steps.prepare.outputs.asset_version }}
run: |
set -euo pipefail
# v{version} is tagged and published when main is tagged, before this runs,
@@ -297,11 +293,6 @@ jobs:
exit 1
fi
gh api "repos/${GH_REPO}/releases/tags/${DESKTOP_RELEASE_TAG}" > "$RUNNER_TEMP/target-release.json"
- # A carried-forward manifest for an older version is expected here (see
- # publish-desktop-updater.yml), so read it rather than judge by name alone.
- mkdir -p "$RUNNER_TEMP/target-manifest"
- gh release download "$DESKTOP_RELEASE_TAG" --pattern latest.json \
- --dir "$RUNNER_TEMP/target-manifest" --clobber 2>/dev/null || true
python3 <<'PY'
import json, os, pathlib, sys
@@ -313,27 +304,26 @@ jobs:
if release.get('prerelease'):
sys.exit(f'Release {tag} is a prerelease; GitHub cannot mark it latest.')
- prefix = f'Unsloth-Desktop-{os.environ["ASSET_VERSION"]}'
+ prefix = 'Unsloth-Desktop-'
clashing = sorted(
asset['name']
for asset in release.get('assets', [])
if str(asset.get('name', '')).startswith(prefix)
+ or asset.get('name') == 'latest.json'
)
- manifest_path = runner / 'target-manifest' / 'latest.json'
- if manifest_path.is_file():
- try:
- version = json.loads(manifest_path.read_text()).get('version')
- except json.JSONDecodeError:
- version = None
- # Only this version's own manifest is a clash; anything else is the
- # pointer being carried forward and is overwritten on upload.
- if not isinstance(version, str) or version.removeprefix('v') == tag.removeprefix('v'):
- clashing.append('latest.json')
if clashing:
print(f'Refusing to republish {tag}: it already carries desktop assets.', file=sys.stderr)
for name in clashing:
print(f' gh release delete-asset {tag} {name} --yes', file=sys.stderr)
+ if 'latest.json' in clashing:
+ # Deleting a manifest off whichever release is currently GitHub
+ # latest 404s every update check until this workflow finishes.
+ print(
+ ' latest.json is the live updater manifest: only delete it once '
+ f'{tag} is not the GitHub latest release.',
+ file=sys.stderr,
+ )
sys.exit(1)
PY
@@ -539,7 +529,6 @@ jobs:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
APP_VERSION: ${{ needs.prepare-version.outputs.app_version }}
- ASSET_VERSION: ${{ needs.prepare-version.outputs.asset_version }}
STUDIO_VERSION: ${{ needs.prepare-version.outputs.studio_version }}
DESKTOP_RELEASE_TAG: ${{ needs.prepare-version.outputs.desktop_release_tag }}
# Compiled in by preflight/version.rs. Without it the app only knows the
@@ -1522,7 +1511,7 @@ jobs:
destination = pathlib.Path(os.environ['RUNNER_TEMP'], 'desktop-release-assets')
destination.mkdir(parents=True, exist_ok=True)
- base_name = f'Unsloth-Desktop-{os.environ["ASSET_VERSION"]}'
+ base_name = 'Unsloth-Desktop'
suffix_names = (
('.app.tar.gz.sig', f'{base_name}-ARM64.app.tar.gz.sig'),
('.app.tar.gz', f'{base_name}-ARM64.app.tar.gz'),
@@ -1586,7 +1575,6 @@ jobs:
env:
GH_REPO: ${{ github.repository }}
APP_VERSION: ${{ needs.prepare-version.outputs.app_version }}
- ASSET_VERSION: ${{ needs.prepare-version.outputs.asset_version }}
PYPI_VERSION: ${{ needs.prepare-version.outputs.pypi_version }}
STUDIO_VERSION: ${{ needs.prepare-version.outputs.studio_version }}
DESKTOP_RELEASE_TAG: ${{ needs.prepare-version.outputs.desktop_release_tag }}
@@ -1693,7 +1681,7 @@ jobs:
asset_dir = pathlib.Path(os.environ['RUNNER_TEMP'], 'desktop-release-assets')
files = [path for path in asset_dir.iterdir() if path.is_file()]
- base_name = f'Unsloth-Desktop-{os.environ["ASSET_VERSION"]}'
+ base_name = 'Unsloth-Desktop'
expected_names = {
f'{base_name}-MacOS.dmg',
f'{base_name}-ARM64.app.tar.gz',
@@ -1736,11 +1724,6 @@ jobs:
echo " Tag main and publish it first, then re-dispatch this workflow." >&2
exit 1
fi
- # A carried-forward manifest for an older version is expected here (see
- # publish-desktop-updater.yml), so read it rather than judge by name alone.
- mkdir -p "$RUNNER_TEMP/target-manifest"
- gh release download "$DESKTOP_RELEASE_TAG" --pattern latest.json \
- --dir "$RUNNER_TEMP/target-manifest" --clobber 2>/dev/null || true
python3 <<'PY'
import json, os, pathlib, sys
@@ -1752,27 +1735,26 @@ jobs:
if release.get('prerelease'):
sys.exit(f'Release {tag} is a prerelease; GitHub cannot mark it latest.')
- prefix = f'Unsloth-Desktop-{os.environ["ASSET_VERSION"]}'
+ prefix = 'Unsloth-Desktop-'
clashing = sorted(
asset['name']
for asset in release.get('assets', [])
if str(asset.get('name', '')).startswith(prefix)
+ or asset.get('name') == 'latest.json'
)
- manifest_path = runner / 'target-manifest' / 'latest.json'
- if manifest_path.is_file():
- try:
- version = json.loads(manifest_path.read_text()).get('version')
- except json.JSONDecodeError:
- version = None
- # Only this version's own manifest is a clash; anything else is the
- # pointer being carried forward and is overwritten on upload.
- if not isinstance(version, str) or version.removeprefix('v') == tag.removeprefix('v'):
- clashing.append('latest.json')
if clashing:
print(f'Refusing to republish {tag}: it already carries desktop assets.', file=sys.stderr)
for name in clashing:
print(f' gh release delete-asset {tag} {name} --yes', file=sys.stderr)
+ if 'latest.json' in clashing:
+ # Deleting a manifest off whichever release is currently GitHub
+ # latest 404s every update check until this workflow finishes.
+ print(
+ ' latest.json is the live updater manifest: only delete it once '
+ f'{tag} is not the GitHub latest release.',
+ file=sys.stderr,
+ )
sys.exit(1)
PY
@@ -1848,7 +1830,7 @@ jobs:
# The release body is the maintainer's changelog and this workflow never
# rewrites it. The target release is already public, so a validation-only
# run must not upload to it.
- - name: Publish versioned release assets
+ - name: Publish release assets
if: ${{ !inputs.draft }}
shell: bash
env:
@@ -1869,9 +1851,7 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
- # --clobber only for latest.json: it may already hold an older version's
- # pointer. The bundles above are still uploaded without it.
- gh release upload "$DESKTOP_RELEASE_TAG" "$RUNNER_TEMP/latest.json" --clobber
+ gh release upload "$DESKTOP_RELEASE_TAG" "$RUNNER_TEMP/latest.json"
- name: Download versioned updater metadata
if: ${{ !inputs.draft }}
@@ -2050,8 +2030,16 @@ jobs:
if latest.get('draft') or latest.get('prerelease'):
sys.exit(f'GitHub latest release {expected} is not a normal published release')
names = {asset.get('name') for asset in latest.get('assets', [])}
- if 'latest.json' not in names:
- sys.exit(f'GitHub latest release {expected} is missing latest.json')
+ required = {
+ 'latest.json',
+ 'Unsloth-Desktop-MacOS.dmg',
+ 'Unsloth-Desktop-Linux.AppImage',
+ 'Unsloth-Desktop-Ubuntu.deb',
+ 'Unsloth-Desktop-Windows.exe',
+ }
+ missing = sorted(required - names)
+ if missing:
+ sys.exit(f'GitHub latest release {expected} is missing stable download assets: {missing}')
PY
diff --git a/tests/python/test_virustotal_scan.py b/tests/python/test_virustotal_scan.py
index 26487044aec..cd16834a580 100644
--- a/tests/python/test_virustotal_scan.py
+++ b/tests/python/test_virustotal_scan.py
@@ -1040,7 +1040,7 @@ class TestWorkflowOrdering:
names = self._publish_steps()
validate = names.index("Validate versioned release state")
assert names[validate + 1] == "Generate versioned updater metadata"
- assert names[validate + 2] == "Publish versioned release assets"
+ assert names[validate + 2] == "Publish release assets"
def test_release_notes_are_written_unconditionally(self):
# Validation writes the notes; the metadata step consumes that same file
@@ -1069,7 +1069,7 @@ class TestWorkflowOrdering:
assert "Create versioned release" not in by_name
# Validation runs on every dispatch; only a non-draft run touches the release.
- for name in ("Publish versioned release assets", "Publish versioned updater metadata"):
+ for name in ("Publish release assets", "Publish versioned updater metadata"):
assert by_name[name]["if"] == "${{ !inputs.draft }}"
def test_the_scan_step_does_not_swallow_its_own_failure(self):
@@ -1164,7 +1164,7 @@ class TestWorkflowOrdering:
draft = workflow.get("on", workflow.get(True))["workflow_dispatch"]["inputs"]["draft"]
assert draft["default"] is True
- upload = self._publish_step_map()["Publish versioned release assets"]
+ upload = self._publish_step_map()["Publish release assets"]
assert upload["if"] == "${{ !inputs.draft }}"
heading = vt.SUMMARY_HEADING.lower()
diff --git a/tests/security/test_desktop_updater_pointer.py b/tests/security/test_desktop_updater_pointer.py
index abac606f197..832e4413e03 100644
--- a/tests/security/test_desktop_updater_pointer.py
+++ b/tests/security/test_desktop_updater_pointer.py
@@ -1,15 +1,21 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-"""Discovery must follow desktop metadata, not whichever release is newest.
+"""Desktop discovery must stay on a release with one complete asset set.
-Clients poll the repo-wide `/releases/latest/download/latest.json`. Publishing a
-`v...` release that carries no desktop bundles moves that pointer, so the
-publish workflow carries the newest desktop manifest onto it instead.
+Clients poll the repo-wide `/releases/latest/download/latest.json`, so whichever
+release holds GitHub's Latest label is the release that serves both the updater
+manifest and the `Unsloth-Desktop-*` download links. Publishing anything without
+Desktop bundles takes that label, so the repair moves it back.
+
+Every test here runs the workflow's real `run:` text through bash against a
+stateful fake `gh`. The fake refuses to answer an invocation it does not model,
+because a shim that quietly succeeds turns a broken step into a passing test.
"""
import json
import os
import subprocess
+import sys
from pathlib import Path
import yaml
@@ -19,36 +25,110 @@ REPO_ROOT = Path(__file__).resolve().parents[2]
UPDATER_WORKFLOW = REPO_ROOT / ".github" / "workflows" / "publish-desktop-updater.yml"
REPOSITORY = "unslothai/unsloth"
-STEP_NAME = "Carry desktop metadata forward"
-
-FAKE_GH = """#!/bin/sh
-set -eu
-printf 'gh %s\\n' "$*" >> "$COMMAND_LOG"
-if [ "$1" = "api" ]; then
- cat "$RELEASES_FIXTURE"
- exit 0
-fi
-if [ "$1" = "release" ] && [ "$2" = "download" ]; then
- directory=""
- want_directory=0
- for argument in "$@"; do
- if [ "$want_directory" = "1" ]; then directory="$argument"; want_directory=0; continue; fi
- [ "$argument" = "--dir" ] && want_directory=1
- done
- mkdir -p "$directory"
- cp "$MANIFEST_FIXTURE" "$directory/latest.json"
- exit 0
-fi
-exit 0
+STEP_NAME = "Restore latest complete Desktop release"
+GATE_NAME = "Check for desktop bundles"
+SUFFIXES = ("MacOS.dmg", "Linux.AppImage", "Ubuntu.deb", "Windows.exe")
+STABLE_ASSETS = tuple(f"Unsloth-Desktop-{suffix}" for suffix in SUFFIXES)
+
+# A `gh` that keeps state, so a PATCH is observable in the next read and an
+# unmodelled call is a loud failure rather than a silent success. The body is
+# Python because the state it keeps is JSON; it is reached through a /bin/sh
+# shim like every other fake in this directory, because a `python3` shebang does
+# not resolve on a Windows runner, where the interpreter is `python.exe`.
+FAKE_GH_BODY = r"""
+import json, os, pathlib, sys
+
+state_path = pathlib.Path(os.environ["FAKE_STATE"])
+state = json.loads(state_path.read_text())
+argv = sys.argv[1:]
+with open(os.environ["COMMAND_LOG"], "a") as handle:
+ handle.write("gh " + " ".join(argv) + "\n")
+
+
+def by_tag(tag):
+ return next((r for r in state["releases"] if r.get("tag_name") == tag), None)
+
+
+def emit(payload, argv):
+ if "--jq" in argv:
+ expression = argv[argv.index("--jq") + 1]
+ if expression == ".tag_name":
+ print(payload["tag_name"])
+ elif expression == ".assets[].name":
+ for asset in payload.get("assets", []):
+ print(asset["name"])
+ elif expression == "[.assets[].name]":
+ print(json.dumps([a["name"] for a in payload.get("assets", [])]))
+ else:
+ sys.stderr.write("fake gh: unmodelled --jq %r\n" % expression)
+ return 2
+ return 0
+ print(json.dumps(payload))
+ return 0
+
+
+if argv[:2] == ["release", "view"]:
+ release = by_tag(argv[2])
+ if release is None:
+ sys.stderr.write("release not found\n")
+ return_code = 1
+ else:
+ return_code = emit(release, argv)
+ sys.exit(return_code)
+
+if argv[:2] == ["release", "download"]:
+ tag = argv[2]
+ manifest = state.get("manifests", {}).get(tag)
+ if manifest is None:
+ sys.stderr.write("no latest.json on %s\n" % tag)
+ sys.exit(1)
+ directory = pathlib.Path(argv[argv.index("--dir") + 1])
+ directory.mkdir(parents=True, exist_ok=True)
+ (directory / "latest.json").write_text(json.dumps(manifest))
+ sys.exit(0)
+
+if argv[:1] == ["api"]:
+ if "--method" in argv and "PATCH" in argv:
+ release_id = int(argv[argv.index("PATCH") + 1].rsplit("/", 1)[-1])
+ release = next((r for r in state["releases"] if r.get("id") == release_id), None)
+ if release is None:
+ sys.stderr.write("HTTP 404\n")
+ sys.exit(1)
+ fields = dict(argv[i + 1].split("=", 1) for i, a in enumerate(argv) if a == "-f")
+ if fields.get("make_latest") == "true":
+ if release.get("draft") or release.get("prerelease"):
+ sys.stderr.write("HTTP 422: cannot mark a draft or prerelease latest\n")
+ sys.exit(1)
+ state["latest"] = release["tag_name"]
+ if state.get("race_latest"):
+ state["latest"] = state.pop("race_latest")
+ state_path.write_text(json.dumps(state))
+ sys.exit(emit(release, argv))
+ route = argv[1]
+ if route.endswith("/releases/latest"):
+ release = by_tag(state.get("latest"))
+ if release is None or release.get("draft") or release.get("prerelease"):
+ sys.stderr.write("HTTP 404: Not Found\n")
+ sys.exit(1)
+ sys.exit(emit(release, argv))
+ if "releases?per_page=" in route:
+ sys.exit(emit(state["releases"], argv))
+
+sys.stderr.write("fake gh: unmodelled invocation %r\n" % (argv,))
+sys.exit(2)
"""
-def _step_run():
+def _step(name):
job = yaml.safe_load(UPDATER_WORKFLOW.read_text(encoding = "utf-8"))["jobs"]["publish-updater"]
steps = {step.get("name"): step for step in job["steps"]}
- assert STEP_NAME in steps, sorted(steps)
- step = steps[STEP_NAME]
- # Only for a release that arrived without bundles of its own.
+ assert name in steps, sorted(steps)
+ return steps[name]
+
+
+def _step_run():
+ step = _step(STEP_NAME)
+ # Only for a release that arrived without a complete publication 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"]
@@ -58,197 +138,499 @@ def _step_run():
def _release(
tag,
*,
- has_manifest = True,
+ release_id,
+ complete = True,
draft = False,
prerelease = False,
published_at = "2026-01-01T00:00:00Z",
+ legacy = False,
+ manifest_only = False,
+ drop = (),
+ assets = None,
):
+ if assets is not None:
+ names = list(assets)
+ elif manifest_only:
+ names = ["latest.json"]
+ elif not complete:
+ names = ["notes.txt"]
+ else:
+ version = tag.removeprefix("v").replace(".", "_").replace("-", "_")
+ base = f"Unsloth-Desktop-{version}" if legacy else "Unsloth-Desktop"
+ names = ["latest.json", *(f"{base}-{suffix}" for suffix in SUFFIXES)]
+ names.append(f"{base}-ARM64.app.tar.gz")
+ names = [name for name in names if name not in drop]
return {
+ "id": release_id,
"tag_name": tag,
"draft": draft,
"prerelease": prerelease,
"published_at": published_at,
- "assets": [{"name": "latest.json"}] if has_manifest else [{"name": "notes.txt"}],
+ "assets": [{"name": name} for name in names],
}
-def _manifest(tag):
- base = f"https://github.com/{REPOSITORY}/releases/download/{tag}/"
+def _manifest(tag, *, legacy = False):
+ base = (
+ f"Unsloth-Desktop-{tag.removeprefix('v').replace('.', '_').replace('-', '_')}"
+ if legacy
+ else "Unsloth-Desktop"
+ )
+ prefix = f"https://github.com/{REPOSITORY}/releases/download/{tag}/"
return {
"version": tag,
"platforms": {
- "darwin-aarch64": {"url": f"{base}app.tar.gz", "signature": "c2ln"},
- "linux-x86_64": {"url": f"{base}app.AppImage", "signature": "c2ln"},
- "windows-x86_64": {"url": f"{base}app.exe", "signature": "c2ln"},
+ "darwin-aarch64": {"url": f"{prefix}{base}-ARM64.app.tar.gz", "signature": "c2ln"},
+ "linux-x86_64": {"url": f"{prefix}{base}-Linux.AppImage", "signature": "c2ln"},
+ "windows-x86_64": {"url": f"{prefix}{base}-Windows.exe", "signature": "c2ln"},
},
}
-def _run(tmp_path, *, release_tag, releases, manifest):
+def _world(
+ tmp_path,
+ *,
+ releases,
+ manifests,
+ latest,
+ race_latest = None,
+):
+ state = {"releases": releases, "manifests": manifests, "latest": latest}
+ if race_latest:
+ state["race_latest"] = race_latest
+ tmp_path.mkdir(parents = True, exist_ok = True)
+ path = tmp_path / "github.json"
+ path.write_text(json.dumps(state), encoding = "utf-8")
+ return path
+
+
+def _run_step(
+ tmp_path,
+ script,
+ *,
+ release_tag,
+ state_path,
+ repair_pointer = "true",
+):
tmp_path.mkdir(parents = True, exist_ok = True)
fake_bin = tmp_path / "bin"
- fake_bin.mkdir()
+ fake_bin.mkdir(exist_ok = True)
+ body = fake_bin / "fake_gh.py"
+ body.write_text(FAKE_GH_BODY, encoding = "utf-8")
gh = fake_bin / "gh"
- gh.write_text(FAKE_GH, encoding = "utf-8")
+ gh.write_text(f'#!/bin/sh\nexec "$FAKE_GH_PYTHON" "{body}" "$@"\n', encoding = "utf-8")
gh.chmod(0o755)
- releases_fixture = tmp_path / "releases.fixture.json"
- releases_fixture.write_text(json.dumps(releases), encoding = "utf-8")
- manifest_fixture = tmp_path / "manifest.fixture.json"
- manifest_fixture.write_text(json.dumps(manifest), encoding = "utf-8")
log = tmp_path / "commands.log"
log.write_text("", encoding = "utf-8")
-
+ output = tmp_path / "github-output"
+ output.write_text("", encoding = "utf-8")
env = os.environ.copy()
env.update(
{
"COMMAND_LOG": str(log),
+ "FAKE_GH_PYTHON": sys.executable,
+ "FAKE_STATE": str(state_path),
+ "GITHUB_OUTPUT": str(output),
"GITHUB_REPOSITORY": REPOSITORY,
- "MANIFEST_FIXTURE": str(manifest_fixture),
- "PATH": f"{fake_bin}:{env['PATH']}",
- "RELEASES_FIXTURE": str(releases_fixture),
"GITHUB_STEP_SUMMARY": str(tmp_path / "step-summary.md"),
+ "PATH": f"{fake_bin}:{env['PATH']}",
+ "REPAIR_POINTER": repair_pointer,
"RELEASE_TAG": release_tag,
"RUNNER_TEMP": str(tmp_path),
}
)
result = subprocess.run(
- ["bash", "-c", _step_run()],
+ ["bash", "-c", script],
cwd = tmp_path,
env = env,
text = True,
capture_output = True,
check = False,
)
- return result, log.read_text(encoding = "utf-8").splitlines()
+ outputs = {}
+ for line in output.read_text(encoding = "utf-8").splitlines():
+ if "=" in line:
+ key, value = line.split("=", 1)
+ outputs[key] = value
+ return result, log.read_text(encoding = "utf-8").splitlines(), outputs
+
+
+def _run(
+ tmp_path,
+ *,
+ release_tag,
+ releases,
+ manifest = None,
+ manifests = None,
+ latest = None,
+ race_latest = None,
+):
+ """Run the repair step. `latest` defaults to the release being repaired."""
+ if manifests is None:
+ manifests = {}
+ if manifest is not None:
+ # The manifest fixture belongs to whichever release would be chosen.
+ for release in releases:
+ if release["tag_name"] != release_tag:
+ manifests[release["tag_name"]] = manifest
+ state_path = _world(
+ tmp_path,
+ releases = releases,
+ manifests = manifests,
+ latest = release_tag if latest is None else latest,
+ race_latest = race_latest,
+ )
+ result, commands, _ = _run_step(
+ tmp_path, _step_run(), release_tag = release_tag, state_path = state_path
+ )
+ return result, commands
+
+
+def _latest_of(tmp_path):
+ return json.loads((tmp_path / "github.json").read_text(encoding = "utf-8"))["latest"]
+
+
+# ------------------------------------------------------------------ the gate
+
+
+def _run_gate(tmp_path, *, release_tag, assets, repair_pointer):
+ state_path = _world(
+ tmp_path,
+ releases = [_release(release_tag, release_id = 1, assets = assets)],
+ manifests = {},
+ latest = release_tag,
+ )
+ return _run_step(
+ tmp_path,
+ _step(GATE_NAME)["run"],
+ release_tag = release_tag,
+ state_path = state_path,
+ repair_pointer = repair_pointer,
+ )
-def test_the_newest_desktop_manifest_is_carried_onto_a_bundleless_release(tmp_path):
+LEGACY_ASSETS = tuple(f"Unsloth-Desktop-0_1_53_beta-{suffix}" for suffix in SUFFIXES)
+
+
+def test_the_gate_classifies_every_shape_of_release(tmp_path):
+ """The four-way classification, executed rather than grepped."""
+ cases = (
+ # assets, repair_pointer, expected proceed (None means the step must fail)
+ ((), "false", "false"),
+ ((), "true", "false"),
+ (("notes.txt",), "false", "false"),
+ (("latest.json", *STABLE_ASSETS), "false", "true"),
+ (("latest.json", *STABLE_ASSETS), "true", "true"),
+ # Everything published before the rename is still a whole publication.
+ (("latest.json", *LEGACY_ASSETS), "false", "true"),
+ (("latest.json", *LEGACY_ASSETS), "true", "true"),
+ # Partial publications are never validated...
+ (("latest.json", *STABLE_ASSETS[:3]), "false", None),
+ ((*STABLE_ASSETS,), "false", None),
+ (("latest.json",), "false", None),
+ (("latest.json", *STABLE_ASSETS[:2], *LEGACY_ASSETS[2:]), "false", None),
+ # ...but they must never block the repair, which writes nothing here.
+ (("latest.json", *STABLE_ASSETS[:3]), "true", "false"),
+ ((*STABLE_ASSETS,), "true", "false"),
+ (("latest.json",), "true", "false"),
+ )
+ for index, (assets, repair_pointer, expected) in enumerate(cases):
+ result, _, outputs = _run_gate(
+ tmp_path / f"case{index}",
+ release_tag = "v0.1.53-beta",
+ assets = assets,
+ repair_pointer = repair_pointer,
+ )
+ label = (assets, repair_pointer)
+ if expected is None:
+ assert result.returncode == 1, label
+ assert "refusing a partial publication" in result.stderr, label
+ else:
+ assert result.returncode == 0, (label, result.stderr)
+ assert outputs.get("proceed") == expected, (label, outputs)
+
+
+def test_the_gate_fails_closed_when_the_release_cannot_be_read(tmp_path):
+ state_path = _world(tmp_path, releases = [], manifests = {}, latest = None)
+ result, _, outputs = _run_step(
+ tmp_path,
+ _step(GATE_NAME)["run"],
+ release_tag = "v0.1.53-beta",
+ state_path = state_path,
+ repair_pointer = "false",
+ )
+ assert result.returncode == 1
+ assert "refusing to advance the channel" in result.stderr
+ assert outputs == {}
+
+
+# ---------------------------------------------------------------- the repair
+
+
+def test_the_newest_complete_desktop_release_is_restored_without_copying_assets(tmp_path):
result, commands = _run(
tmp_path,
release_tag = "v0.1.53-beta",
releases = [
- _release("v0.1.52-beta", published_at = "2026-03-01T00:00:00Z"),
- _release("v0.1.51-beta", published_at = "2026-02-01T00:00:00Z"),
- _release("v0.1.53-beta", has_manifest = False, published_at = "2026-04-01T00:00:00Z"),
+ _release("v0.1.52-beta", release_id = 52, published_at = "2026-03-01T00:00:00Z"),
+ _release("v0.1.51-beta", release_id = 51, published_at = "2026-02-01T00:00:00Z"),
+ _release(
+ "v0.1.53-beta",
+ release_id = 53,
+ complete = False,
+ published_at = "2026-04-01T00:00:00Z",
+ ),
],
- manifest = _manifest("v0.1.52-beta"),
+ manifests = {
+ "v0.1.52-beta": _manifest("v0.1.52-beta"),
+ "v0.1.51-beta": _manifest("v0.1.51-beta"),
+ },
)
assert result.returncode == 0, result.stderr
- assert "gh release download v0.1.52-beta" in "\n".join(commands)
+ assert "gh release download v0.1.52-beta --pattern latest.json" in "\n".join(commands)
assert any(
- line.startswith("gh release upload v0.1.53-beta") and "--clobber" in line
+ line.startswith(f"gh api --method PATCH repos/{REPOSITORY}/releases/52")
+ and "-f make_latest=true" in line
for line in commands
), commands
- # The manifest is copied byte for byte, so it keeps pointing at its own release.
- carried = json.loads((tmp_path / "carry-forward" / "latest.json").read_text(encoding = "utf-8"))
- assert carried == _manifest("v0.1.52-beta")
+ # The binaries are never duplicated; only the label moves.
+ assert not [line for line in commands if line.startswith("gh release upload")]
+ assert _latest_of(tmp_path) == "v0.1.52-beta"
- # The 404 gap between publish and this upload is recorded, not silent.
+ restored = json.loads((tmp_path / "restore-latest" / "latest.json").read_text(encoding = "utf-8"))
+ assert restored == _manifest("v0.1.52-beta")
summary = (tmp_path / "step-summary.md").read_text(encoding = "utf-8")
- assert "v0.1.52-beta manifest" in summary
+ assert "points back to v0.1.52-beta" in summary
assert "404" in summary
-def test_drafts_prereleases_and_bundleless_releases_are_never_the_source(tmp_path):
+def test_legacy_downloads_are_restored_during_migration(tmp_path):
+ result, commands = _run(
+ tmp_path,
+ release_tag = "v0.1.802-beta",
+ releases = [
+ _release("v0.1.802-beta", release_id = 802, complete = False),
+ _release("v0.1.801-beta", release_id = 801, legacy = True),
+ ],
+ manifests = {"v0.1.801-beta": _manifest("v0.1.801-beta", legacy = True)},
+ )
+ assert result.returncode == 0, result.stderr
+ assert "gh release download v0.1.801-beta --pattern latest.json" in "\n".join(commands)
+ assert any("releases/801 -f make_latest=true" in line for line in commands)
+ assert _latest_of(tmp_path) == "v0.1.801-beta"
+ # A pre-rename release cannot serve the stable links, and the summary says so
+ # rather than reporting the downloads as repaired.
+ summary = (tmp_path / "step-summary.md").read_text(encoding = "utf-8")
+ assert "predates the stable asset names" in summary
+
+
+def test_a_release_holding_only_a_manifest_is_not_a_restore_candidate(tmp_path):
+ """`latest.json` alone is the state the old carry-forward repair left behind."""
+ result, commands = _run(
+ tmp_path,
+ release_tag = "v0.1.53-beta",
+ releases = [
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52, manifest_only = True),
+ ],
+ manifests = {"v0.1.52-beta": _manifest("v0.1.52-beta")},
+ )
+ assert result.returncode == 1
+ assert "nothing to restore" in result.stderr
+ assert not [line for line in commands if "--method PATCH" in line]
+
+
+def test_incomplete_draft_and_prerelease_releases_are_never_restored(tmp_path):
result, commands = _run(
tmp_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"),
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52, draft = True),
+ _release("v0.1.51-beta", release_id = 51, prerelease = True),
+ _release("v0.1.50-beta", release_id = 50, complete = False),
],
- manifest = _manifest("v0.1.52-beta"),
+ manifests = {"v0.1.52-beta": _manifest("v0.1.52-beta")},
+ )
+ # An explicit repair request that cannot be honoured leaves production broken,
+ # so it must go red rather than finish green with nothing done.
+ assert result.returncode == 1
+ assert "nothing to restore" in result.stderr
+ assert not [line for line in commands if "--method PATCH" in line]
+ summary = (tmp_path / "step-summary.md").read_text(encoding = "utf-8")
+ assert "still returning 404" in summary
+
+
+def test_a_prebuilt_release_holding_the_pointer_is_repaired(tmp_path):
+ """llama.cpp prebuilts (b8475) are normal releases in this same repository.
+
+ They take the repo-wide pointer exactly as a bundleless v... release does, and
+ with it the stable download links, so they have to be repairable too.
+ """
+ result, commands = _run(
+ tmp_path,
+ release_tag = "b8475",
+ releases = [
+ _release(
+ "b8475",
+ release_id = 8475,
+ assets = ["llama-b8475-bin-ubuntu-x64.zip"],
+ published_at = "2026-04-01T00:00:00Z",
+ ),
+ _release("v0.1.52-beta", release_id = 52, published_at = "2026-03-01T00:00:00Z"),
+ ],
+ manifests = {"v0.1.52-beta": _manifest("v0.1.52-beta")},
)
assert result.returncode == 0, result.stderr
- assert "nothing to carry forward" in result.stdout
- assert not [line for line in commands if line.startswith("gh release upload")]
+ assert any("releases/52 -f make_latest=true" in line for line in commands)
+ assert _latest_of(tmp_path) == "v0.1.52-beta"
-def test_a_non_semver_release_leaves_the_pointer_alone(tmp_path):
+def test_the_highest_version_wins_over_a_later_publish_time(tmp_path):
+ """A republished older release must not drag the pointer onto an older build."""
result, commands = _run(
tmp_path,
- release_tag = "vnext",
- releases = [_release("v0.1.52-beta")],
- manifest = _manifest("v0.1.52-beta"),
+ release_tag = "v0.1.54-beta",
+ releases = [
+ _release(
+ "v0.1.54-beta", release_id = 54, complete = False, published_at = "2026-05-01T00:00:00Z"
+ ),
+ _release("v0.1.52-beta", release_id = 52, published_at = "2026-04-01T00:00:00Z"),
+ _release("v0.1.53-beta", release_id = 53, published_at = "2026-03-01T00:00:00Z"),
+ ],
+ manifests = {
+ "v0.1.52-beta": _manifest("v0.1.52-beta"),
+ "v0.1.53-beta": _manifest("v0.1.53-beta"),
+ },
)
assert result.returncode == 0, result.stderr
- assert commands == [], commands
+ assert _latest_of(tmp_path) == "v0.1.53-beta", commands
-def test_an_already_carried_manifest_is_carried_forward_again(tmp_path):
- # The carried release is now the newest one holding latest.json, and the
- # manifest it holds names an older version on purpose. Forwarding it again is
- # the only thing that keeps the pointer resolving.
+def test_an_unsound_candidate_is_skipped_for_the_next_one(tmp_path):
+ """One bad manifest must not end a repair that a good candidate could finish."""
+ broken = _manifest("v0.1.53-beta")
+ broken["platforms"]["linux-x86_64"]["url"] = (
+ f"https://github.com/{REPOSITORY}/releases/latest/download/Unsloth-Desktop-Linux.AppImage"
+ )
result, commands = _run(
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"),
+ _release("v0.1.54-beta", release_id = 54, complete = False),
+ _release("v0.1.53-beta", release_id = 53),
+ _release("v0.1.52-beta", release_id = 52),
],
- manifest = _manifest("v0.1.52-beta"),
+ manifests = {
+ "v0.1.53-beta": broken,
+ "v0.1.52-beta": _manifest("v0.1.52-beta"),
+ },
)
assert result.returncode == 0, result.stderr
- assert any(line.startswith("gh release upload v0.1.54-beta") for line in commands), commands
+ assert _latest_of(tmp_path) == "v0.1.52-beta"
+ assert any("releases/52 -f make_latest=true" in line for line in commands)
-def test_a_manifest_that_is_not_pinned_to_its_own_version_is_refused(tmp_path):
+def test_a_manifest_naming_a_missing_bundle_is_refused(tmp_path):
+ """Prefix-matching a URL says nothing about the asset still being there."""
result, commands = _run(
tmp_path,
release_tag = "v0.1.53-beta",
releases = [
- _release("v0.1.53-beta", has_manifest = False),
- _release("v0.1.52-beta"),
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52, drop = ("Unsloth-Desktop-ARM64.app.tar.gz",)),
],
- manifest = {
- "version": "v0.1.52-beta",
- "platforms": {
- "linux-x86_64": {
- "url": f"https://github.com/{REPOSITORY}/releases/latest/download/app.AppImage",
- "signature": "c2ln",
- }
- },
- },
+ manifests = {"v0.1.52-beta": _manifest("v0.1.52-beta")},
)
assert result.returncode == 1
- assert "not pinned to v0.1.52-beta" in result.stderr
- assert not [line for line in commands if line.startswith("gh release upload")]
+ assert "names a missing asset" in result.stderr
+ assert not [line for line in commands if "--method PATCH" in line]
+
+
+def test_a_manifest_with_an_empty_signature_is_refused(tmp_path):
+ manifest = _manifest("v0.1.52-beta")
+ manifest["platforms"]["windows-x86_64"]["signature"] = " "
+ result, commands = _run(
+ tmp_path,
+ release_tag = "v0.1.53-beta",
+ releases = [
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52),
+ ],
+ manifests = {"v0.1.52-beta": manifest},
+ )
+ assert result.returncode == 1
+ assert "has no signature" in result.stderr
+ assert not [line for line in commands if "--method PATCH" in line]
+
+
+def test_a_manifest_naming_another_release_is_refused(tmp_path):
+ result, commands = _run(
+ tmp_path,
+ release_tag = "v0.1.54-beta",
+ releases = [
+ _release("v0.1.54-beta", release_id = 54, complete = False),
+ _release("v0.1.53-beta", release_id = 53),
+ ],
+ manifests = {"v0.1.53-beta": _manifest("v0.1.52-beta")},
+ )
+ assert result.returncode == 1
+ assert "names v0.1.52-beta" in result.stderr
+ assert not [line for line in commands if "--method PATCH" in line]
+
+
+def test_a_manifest_with_a_moving_bundle_url_is_refused(tmp_path):
+ manifest = _manifest("v0.1.52-beta")
+ manifest["platforms"]["linux-x86_64"]["url"] = (
+ f"https://github.com/{REPOSITORY}/releases/latest/download/Unsloth-Desktop-Linux.AppImage"
+ )
+ result, commands = _run(
+ tmp_path,
+ release_tag = "v0.1.53-beta",
+ releases = [
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52),
+ ],
+ manifests = {"v0.1.52-beta": manifest},
+ )
+ assert result.returncode == 1
+ assert "URL is not pinned to its release" in result.stderr
+ assert not [line for line in commands if "--method PATCH" in line]
def test_a_manifest_without_a_usable_version_is_refused(tmp_path):
- result, _ = _run(
+ result, commands = _run(
tmp_path,
release_tag = "v0.1.53-beta",
releases = [
- _release("v0.1.53-beta", has_manifest = False),
- _release("v0.1.52-beta"),
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52),
],
- manifest = {"version": "latest", "platforms": {}},
+ manifests = {"v0.1.52-beta": {"version": "latest", "platforms": {}}},
)
assert result.returncode == 1
- assert "refusing to carry it forward" in result.stderr
+ assert "declares invalid version" in result.stderr
+ assert not [line for line in commands if "--method PATCH" in line]
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
+ # /releases/latest never resolves to a draft or prerelease, so a repair aimed at
+ # one cannot affect 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 = _release("v0.1.53-beta", release_id = 53, complete = 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"),
+ releases = [target, _release("v0.1.52-beta", release_id = 52)],
+ manifests = {"v0.1.52-beta": _manifest("v0.1.52-beta")},
+ latest = "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
+ assert not [line for line in commands if "--method PATCH" in line], commands
def test_a_target_missing_from_the_release_listing_is_refused(tmp_path):
@@ -259,9 +641,51 @@ def test_a_target_missing_from_the_release_listing_is_refused(tmp_path):
result, commands = _run(
tmp_path,
release_tag = "v0.1.53-beta",
- releases = [_release("v0.1.52-beta")],
- manifest = _manifest("v0.1.52-beta"),
+ releases = [_release("v0.1.52-beta", release_id = 52)],
+ manifests = {"v0.1.52-beta": _manifest("v0.1.52-beta")},
+ latest = "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")], commands
+ assert not [line for line in commands if "--method PATCH" in line], commands
+
+
+def test_a_pointer_that_moved_on_is_left_alone(tmp_path):
+ """Between the dispatch and the PATCH someone else fixed or replaced Latest."""
+ result, commands = _run(
+ tmp_path,
+ release_tag = "v0.1.53-beta",
+ releases = [
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52),
+ _release("v0.1.54-beta", release_id = 54, published_at = "2026-06-01T00:00:00Z"),
+ ],
+ manifests = {
+ "v0.1.52-beta": _manifest("v0.1.52-beta"),
+ "v0.1.54-beta": _manifest("v0.1.54-beta"),
+ },
+ latest = "v0.1.54-beta",
+ )
+ assert result.returncode == 0, result.stderr
+ assert not [line for line in commands if "--method PATCH" in line], commands
+ assert _latest_of(tmp_path) == "v0.1.54-beta"
+ assert "nothing to repair" in result.stdout
+
+
+def test_a_pointer_moved_by_someone_else_after_the_patch_fails_loudly(tmp_path):
+ result, commands = _run(
+ tmp_path,
+ release_tag = "v0.1.53-beta",
+ releases = [
+ _release("v0.1.53-beta", release_id = 53, complete = False),
+ _release("v0.1.52-beta", release_id = 52),
+ _release(
+ "v0.1.55-beta", release_id = 55, published_at = "2026-07-01T00:00:00Z", complete = False
+ ),
+ ],
+ manifests = {"v0.1.52-beta": _manifest("v0.1.52-beta")},
+ race_latest = "v0.1.55-beta",
+ )
+ assert result.returncode == 1
+ assert "another run may have moved it" in result.stderr
+ assert any("--method PATCH" in line for line in commands)
diff --git a/tests/security/test_release_desktop_integrity.py b/tests/security/test_release_desktop_integrity.py
index 77faed7b707..c3fe8f3be3d 100644
--- a/tests/security/test_release_desktop_integrity.py
+++ b/tests/security/test_release_desktop_integrity.py
@@ -3,7 +3,6 @@
from __future__ import annotations
import base64
-import hashlib
import os
import subprocess
from pathlib import Path
@@ -127,7 +126,6 @@ def _run_step(
"GITHUB_OUTPUT": str(tmp_path / "github-output"),
"GH_TOKEN": "masked-token",
"PATH": f"{fake_bin}:{env['PATH']}",
- "ASSET_VERSION": "0_1_50_beta",
"RUNNER_TEMP": str(tmp_path),
"SOURCE_COMMIT_SHA": SOURCE_SHA,
"TARGET_HAS_DESKTOP_ASSETS": "1" if target_has_desktop_assets else "0",
@@ -147,8 +145,8 @@ def _run_step(
return result, log.read_text(encoding = "utf-8").splitlines()
-def _stage_assets(tmp_path: Path) -> dict[str, str]:
- """Create release assets and return their digests."""
+def _stage_assets(tmp_path: Path) -> None:
+ """Create the one release asset set."""
asset_dir = tmp_path / "desktop-release-assets"
asset_dir.mkdir(exist_ok = True)
signature = base64.b64encode(
@@ -157,21 +155,17 @@ def _stage_assets(tmp_path: Path) -> dict[str, str]:
b"trusted comment: timestamp:1\tfile:test\n"
b"test global signature bytes\n"
)
- digests = {}
for name, payload in (
- ("Unsloth-Desktop-0_1_50_beta-MacOS.dmg", b"disk image"),
- ("Unsloth-Desktop-0_1_50_beta-Ubuntu.deb", b"package"),
- ("Unsloth-Desktop-0_1_50_beta-ARM64.app.tar.gz", b"mac updater"),
- ("Unsloth-Desktop-0_1_50_beta-ARM64.app.tar.gz.sig", signature),
- ("Unsloth-Desktop-0_1_50_beta-Linux.AppImage", b"linux updater"),
- ("Unsloth-Desktop-0_1_50_beta-Linux.AppImage.sig", signature),
- ("Unsloth-Desktop-0_1_50_beta-Windows.exe", b"installer"),
- ("Unsloth-Desktop-0_1_50_beta-Windows.exe.sig", signature),
+ ("Unsloth-Desktop-MacOS.dmg", b"disk image"),
+ ("Unsloth-Desktop-Ubuntu.deb", b"package"),
+ ("Unsloth-Desktop-ARM64.app.tar.gz", b"mac updater"),
+ ("Unsloth-Desktop-ARM64.app.tar.gz.sig", signature),
+ ("Unsloth-Desktop-Linux.AppImage", b"linux updater"),
+ ("Unsloth-Desktop-Linux.AppImage.sig", signature),
+ ("Unsloth-Desktop-Windows.exe", b"installer"),
+ ("Unsloth-Desktop-Windows.exe.sig", signature),
):
(asset_dir / name).write_bytes(payload)
- if not name.endswith(".sig"):
- digests[name] = hashlib.sha256(payload).hexdigest()
- return digests
def _run_create_release(
@@ -183,9 +177,9 @@ def _run_create_release(
):
_stage_assets(tmp_path)
if invalid_signature:
- (
- tmp_path / "desktop-release-assets" / "Unsloth-Desktop-0_1_50_beta-Linux.AppImage.sig"
- ).write_text("Tauri signer diagnostic, not a signature\n", encoding = "utf-8")
+ (tmp_path / "desktop-release-assets" / "Unsloth-Desktop-Linux.AppImage.sig").write_text(
+ "Tauri signer diagnostic, not a signature\n", encoding = "utf-8"
+ )
env = {
"DESKTOP_RELEASE_NOTES": workflow["env"]["DESKTOP_RELEASE_NOTES"],
"APP_VERSION": "0.1.50",
@@ -348,21 +342,18 @@ def test_the_publish_sequence_never_rewrites_the_release_body(tmp_path):
assert "Desktop app for Unsloth." in notes
-def test_versioned_uploads_never_clobber_or_mutate_the_legacy_channel():
+def test_release_uploads_never_clobber_or_mutate_the_legacy_channel():
uploads = _upload_commands(_workflow())
versioned = [line for line in uploads if "$DESKTOP_RELEASE_TAG" in line]
channel = [line for line in uploads if "desktop-latest" in line]
assert len(versioned) == 2, uploads
assert channel == [], uploads
- # latest.json is the moving updater pointer and may already hold a carried
- # forward manifest, so only it may be replaced. Bundles stay immutable.
for line in versioned:
- if "latest.json" not in line:
- assert "--clobber" not in line, line
+ assert "--clobber" not in line, line
-def test_a_carried_forward_manifest_does_not_block_the_guard(tmp_path):
+def test_any_existing_manifest_blocks_republishing_the_release(tmp_path):
workflow = _workflow()
result, _ = _run_step(
workflow,
@@ -372,14 +363,15 @@ def test_a_carried_forward_manifest_does_not_block_the_guard(tmp_path):
target_has_desktop_assets = True,
target_manifest_version = "v0.1.49-beta",
)
- assert result.returncode == 0, result.stderr
+ assert result.returncode == 1
+ assert "latest.json" in result.stderr
def test_a_validation_only_run_touches_nothing_public():
steps = _workflow()["jobs"]["publish-release"]["steps"]
names = [step.get("name") for step in steps]
mutating = (
- "Publish versioned release assets",
+ "Publish release assets",
"Publish versioned updater metadata",
"Promote normal release to GitHub latest",
)
diff --git a/tests/security/test_release_desktop_permissions.py b/tests/security/test_release_desktop_permissions.py
index 8ad0913af12..37e402a3aa0 100644
--- a/tests/security/test_release_desktop_permissions.py
+++ b/tests/security/test_release_desktop_permissions.py
@@ -128,9 +128,7 @@ def test_build_matrix_hands_off_assets_without_release_credentials():
assert re.search(r"^\s*break\b", loop_body, re.MULTILINE), wait_run
names = [step.get("name") for step in publish["steps"]]
- assert names.index("Wait for the build matrix") < names.index(
- "Publish versioned release assets"
- )
+ assert names.index("Wait for the build matrix") < names.index("Publish release assets")
# And it has to clear before the assets are pulled, or the download races the
# legs and publish-release dies on artifacts that do not exist yet.
download = next(
@@ -188,7 +186,7 @@ def test_post_publish_scan_job_holds_no_release_credentials():
def test_versioned_release_hides_updater_signature_assets():
steps = _workflow()["jobs"]["publish-release"]["steps"]
- publish = next(step for step in steps if step.get("name") == "Publish versioned release assets")
+ publish = next(step for step in steps if step.get("name") == "Publish release assets")
assert '[[ "$asset" == *.sig ]] || release_assets+=("$asset")' in publish["run"]
assert '"${release_assets[@]}"' in publish["run"]
@@ -264,8 +262,27 @@ def test_the_updater_workflow_skips_releases_without_desktop_bundles():
steps = {step.get("name"): step for step in job["steps"]}
gate = steps["Check for desktop bundles"]
assert gate["id"] == "gate"
+ assert gate["env"]["REPAIR_POINTER"] == "${{ inputs.repair_pointer }}"
+ # A repair dispatch must never be turned away by the state it exists to repair.
+ assert "[ \"$REPAIR_POINTER\" = 'true' ]" in gate["run"]
+ assert "grep -q '^Unsloth-Desktop-'" in gate["run"]
# An unreadable release must not look like one that simply has no bundles.
assert "refusing to advance the channel" in gate["run"]
+ # Completeness is judged over the four public downloads, in whichever naming
+ # scheme the release was built with. tests/security/test_desktop_updater_pointer.py
+ # executes the classification; these only pin that all three steps share it.
+ for step_name in (
+ "Check for desktop bundles",
+ "Validate updater metadata",
+ "Mark published release as GitHub latest",
+ ):
+ run = steps[step_name]["run"]
+ for suffix in ("MacOS.dmg", "Linux.AppImage", "Ubuntu.deb", "Windows.exe"):
+ assert suffix in run, (step_name, suffix)
+ assert "Unsloth-Desktop" in run, step_name
+ # Every release published before the rename carries the version in each
+ # filename; refusing those would make the workflow unusable on all of them.
+ assert "version" in run, step_name
for name in (
"Download updater metadata",
@@ -310,8 +327,12 @@ def test_the_updater_workflow_is_manual_dispatch_only():
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"
+ restore = next(
+ step
+ for step in job["steps"]
+ if step.get("name") == "Restore latest complete Desktop release"
)
- assert "inputs.repair_pointer" in carry["if"]
+ assert "inputs.repair_pointer" in restore["if"]
+ assert "gh release upload" not in restore["run"]
+ assert "-f make_latest=true" in restore["run"]
assert triggers["workflow_dispatch"]["inputs"]["repair_pointer"]["default"] is False
diff --git a/tests/studio/test_tauri_branding_contract.py b/tests/studio/test_tauri_branding_contract.py
index 6a458a0ac26..6d95421e243 100644
--- a/tests/studio/test_tauri_branding_contract.py
+++ b/tests/studio/test_tauri_branding_contract.py
@@ -176,9 +176,7 @@ def test_dmg_icon_label_stays_legible_over_the_halo() -> None:
def test_desktop_release_asset_names_are_human_readable() -> None:
workflow = read(REPO / ".github/workflows/release-desktop.yml")
- assert "re.sub(r'[^0-9A-Za-z]+', '_', app_version).strip('_')" in workflow
-
- assert "base_name = f'Unsloth-Desktop-{os.environ[\"ASSET_VERSION\"]}'" in workflow
+ assert "base_name = 'Unsloth-Desktop'" in workflow
expected_suffixes = {
"MacOS.dmg",
"ARM64.app.tar.gz",
@@ -192,6 +190,14 @@ def test_desktop_release_asset_names_are_human_readable() -> None:
for suffix in expected_suffixes:
assert f"f'{{base_name}}-{suffix}'" in workflow
+ for name in (
+ "Unsloth-Desktop-MacOS.dmg",
+ "Unsloth-Desktop-Linux.AppImage",
+ "Unsloth-Desktop-Ubuntu.deb",
+ "Unsloth-Desktop-Windows.exe",
+ ):
+ assert name in workflow
+
LOCALES = FRONTEND / "src/i18n/locales"