Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
ci(desktop): publish stable releases via draft and clean up RCs
Dongdong Chencd0e23af6cac
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.ymlindex b8532c4d..bd2f7982 100644--- a/.github/workflows/desktop-release.yml+++ b/.github/workflows/desktop-release.yml@@ -1,13 +1,16 @@name: Desktop release# Pushing a desktop-v<version> tag builds the macOS (Apple silicon), Linux x64-# and Windows x64 packages and publishes them, with SHA256SUMS.txt, as the+# and Windows x64 packages and uploads them, with SHA256SUMS.txt, to the# GitHub Release of that tag in RELEASE_REPO (simplexai-labs/linger unless the-# variable says otherwise); a version with a hyphen is a prerelease. A manual-# run builds a version from the chosen branch and keeps the files as workflow-# artifacts unless "publish" is set. scripts/ci/desktop-release.sh does the-# work; docs/desktop-release.md lists the variables and secrets. This is the-# only workflow that publishes desktop releases.+# variable says otherwise). Stable tags create a draft release so release notes+# are attached before notifying subscribers or updating releases/latest+# (`scripts/ci/desktop-release.sh publish`); versions with a hyphen publish+# immediately as prereleases. A manual run builds a version from the chosen+# branch and keeps the files as workflow artifacts unless "publish" is set.+# scripts/ci/desktop-release.sh does the work; docs/desktop-release.md lists+# the variables and secrets. This is the only workflow that publishes desktop+# releases.on:push:tags: ["desktop-v*"]@@ -323,7 +326,7 @@ jobs:- run: scripts/ci/desktop-release.sh checksums release "${{ needs.prepare.outputs.version }}"# GITHUB_TOKEN can write only this repository; a release in another one# takes LINGER_RELEASE_TOKEN, which prepare checked.- - name: Publish the release+ - name: Create or update the GitHub Releaseenv:GH_TOKEN: ${{ env.RELEASE_REPO == github.repository && github.token || secrets.LINGER_RELEASE_TOKEN }}run: >-diff --git a/docs/desktop-release.md b/docs/desktop-release.mdindex b7ffe0bd..4f05f1fd 100644--- a/docs/desktop-release.md+++ b/docs/desktop-release.md@@ -19,17 +19,28 @@ becomes the latest release. Link there, not to a version.## Releasing+Stable releases use a two-stage Draft → Publish flow so release subscribers and+auto-updating clients never see placeholder notes before the final release notes+are attached.+In a checkout of simplexai-labs/linger:```sh+# 1. Tag and push to build all targets and create the draft GitHub Releasegit tag desktop-v0.16.36git push origin desktop-v0.16.36++# 2. Once Desktop release finishes, attach release notes and publish as latest+scripts/ci/desktop-release.sh publish desktop-v0.16.36 --notes-file notes.md```- The tag is `desktop-v<major>.<minor>.<patch>`, optionally with a suffix suchas `-rc.1`, beside the `cli-v<version>` tags of the CLI. A version with a- hyphen is published as a GitHub prerelease whose notes start with- **Prerelease**; a stable version is marked as the latest release.+ hyphen is published immediately as a GitHub prerelease whose notes start with+ **Prerelease**; a stable version is created as a draft release until+ `scripts/ci/desktop-release.sh publish` validates the uploaded assets,+ attaches the release notes, marks it as the latest release, and cleans up+ matching `desktop-v<version>-rc.*` prereleases and tags.- The version comes from the tag. The build writes it into`apps/desktop/package.json` for packaging and restores the file afterwards, sono version commit is needed.@@ -56,9 +67,10 @@ credentials, downloads no model weights, and does not verify the graphicalinstaller, model inference, restart persistence, or uninstallation. `release`requires `windows-smoke` to pass, downloads `desktop-*`, checks the same`windows-setup.sha256` digest before removing that file, writes-`SHA256SUMS.txt`, and creates the GitHub Release (or uploads the files again to-an existing one). A manual run publishes only with `publish` set, and a-`publish=false` run still executes `windows-smoke`.+`SHA256SUMS.txt`, and creates the GitHub Release (as a draft for stable tags or+published prerelease for hyphenated tags; reruns upload files to an existing+release with `--clobber`). A manual run creates a release only with `publish`+set, and a `publish=false` run still executes `windows-smoke`.The release goes to `RELEASE_REPO`, `simplexai-labs/linger` by default:@@ -121,9 +133,12 @@ gh release upload native-deps <archive> --repo simplexai-labs/lingerFrom another repository, also set `LINGER_RELEASE_TOKEN` there and pushthe tags to that repository instead.-3. Check the release page, download each file and compare it with- `SHA256SUMS.txt`. A test release is removed with its tag:- `gh release delete desktop-v0.16.36-rc.1 --repo simplexai-labs/linger --cleanup-tag`.+3. Check the draft release page, download each file and compare it with+ `SHA256SUMS.txt`, then publish the stable release with its notes:+ `scripts/ci/desktop-release.sh publish desktop-v0.16.36 --notes-file notes.md`+ (this also deletes matching `desktop-v0.16.36-rc.*` prereleases and tags; a+ standalone test prerelease can still be removed with+ `gh release delete desktop-v0.16.36-rc.1 --repo simplexai-labs/linger --cleanup-tag`).### Physical Windows acceptancediff --git a/scripts/ci/desktop-release.sh b/scripts/ci/desktop-release.shindex 6a840d38..b42f0156 100755--- a/scripts/ci/desktop-release.sh+++ b/scripts/ci/desktop-release.sh@@ -22,7 +22,12 @@ set -euo pipefail# package from a GitLab CI job (test builds only)# desktop-release.sh github-release <dir> <tag> <version># create or update the GitHub Release of <tag>-# in RELEASE_REPO with <dir>'s files (gh)+# in RELEASE_REPO with <dir>'s files (gh);+# stable releases are created as drafts+# desktop-release.sh publish <tag> --notes-file <file>+# attach release notes, publish a stable draft+# release as latest, and remove matching+# desktop-v<version>-rc.* prereleases## Inputs (environment):# DESKTOP_VERSION release version, as printed by `version` (compile, package)@@ -68,7 +73,7 @@ die() {usage() {echo "Usage: $0 version <tag> | fetch-native|compile|package|build <target>" \"| manifest|checksums <dir> <version> | github-release <dir> <tag> <version>" \- "| gitlab-upload <dir> <version>" >&2+ "| publish <tag> --notes-file <file> | gitlab-upload <dir> <version>" >&2exit 2}@@ -286,6 +291,7 @@ cmd_build() {# packageFor in apps/desktop/src/main/update-manifest.ts. Linux and the# portable Windows folder only link to the release.update_packages='darwin-arm64:macos-arm64.app.tar.gz linux-x64:linux-x64.tar.gz win32-x64:windows-x64-setup.exe'+required_installers='macos-arm64.dmg linux-x64.tar.gz windows-x64-setup.exe'# manifest.json lists every platform's package with its size and sha256, and# manifest.json.sig is its Ed25519 signature, made with DESKTOP_UPDATE_KEY.@@ -350,7 +356,7 @@ cmd_checksums() {local dir="${1:-}" version="${2:-}" required file files=()[[ -d "$dir" ]] || die "checksums needs the folder holding the release files"[[ "$version" =~ $version_pattern ]] || die "checksums needs the release version"- for required in macos-arm64.dmg linux-x64.tar.gz windows-x64-setup.exe; do+ for required in $required_installers; do[[ -f "$dir/Linger-$version-$required" ]] || die "$dir has no Linger-$version-$required"donewhile IFS= read -r file; do@@ -419,17 +425,79 @@ cmd_github_release() {notes="**Prerelease** for testing, not for general use. $notes"flags+=(--prerelease)else- # releases/latest, which the download links use, follows this flag.- flags+=(--latest)+ # Stable releases start as drafts so subscribers and auto-updaters never+ # see placeholder notes; `publish` attaches the release notes and marks latest.+ flags+=(--draft)fiif gh release view "$tag" --repo "$repo" >/dev/null 2>&1; thengh release upload "$tag" "$dir"/* --repo "$repo" --clobberecho "desktop-release: updated the $tag release of $repo"elsegh release create "$tag" "$dir"/* --repo "$repo" --title "Linger Desktop $version" --notes "$notes" "${flags[@]}"- echo "desktop-release: created the $tag release of $repo"+ if [[ "$version" == *-* ]]; then+ echo "desktop-release: created the $tag prerelease of $repo"+ else+ echo "desktop-release: created draft release $tag of $repo (publish with: $0 publish $tag --notes-file <file>)"+ fi+ fi+ echo "desktop-release: https://github.com/$repo/releases/tag/$tag"+}++cmd_publish() {+ local tag="${1:-}" notes_file="" version repo assets required missing=() rc_jq rc_tags rc_tag+ shift || true+ while [[ $# -gt 0 ]]; do+ case "$1" in+ --notes-file)+ [[ $# -ge 2 ]] || die "publish --notes-file needs a file path"+ notes_file="$2"+ shift 2+ ;;+ *) die "unknown publish argument: $1" ;;+ esac+ done+ [[ -n "$tag" && "$tag" == desktop-v* ]] ||+ die "publish needs a stable desktop-v<version> tag and --notes-file <file>"+ version="${tag#desktop-v}"+ [[ "$version" =~ $version_pattern ]] ||+ die "$tag does not hold a valid version"+ [[ "$version" != *-* ]] ||+ die "publish is for stable desktop-v<version> releases, not prereleases ($tag)"+ [[ -n "$notes_file" && -f "$notes_file" ]] ||+ die "publish needs an existing --notes-file <file>"+ grep -q '[^[:space:]]' "$notes_file" ||+ die "release notes file is empty: $notes_file"+ repo="${RELEASE_REPO:-$default_release_repo}"+ [[ "$repo" =~ ^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$ ]] || die "RELEASE_REPO must be owner/name, not $repo"+ command -v gh >/dev/null || die "publish needs the GitHub CLI (gh)"++ assets="$(gh release view "$tag" --repo "$repo" --json assets --jq '.assets[].name')" ||+ die "could not read release $tag in $repo"+ for required in $required_installers; do+ grep -qxF "Linger-$version-$required" <<<"$assets" || missing+=("Linger-$version-$required")+ done+ grep -qxF "SHA256SUMS.txt" <<<"$assets" || missing+=("SHA256SUMS.txt")+ if [[ ${#missing[@]} -gt 0 ]]; then+ die "refusing to publish $tag: missing required assets: ${missing[*]}"fi++ gh release edit "$tag" --repo "$repo" --notes-file "$notes_file" --draft=false --latest+ echo "desktop-release: published $tag as latest in $repo"echo "desktop-release: https://github.com/$repo/releases/tag/$tag"++ rc_jq=".[] | select(.isPrerelease and (.isDraft | not) and (.tagName | startswith(\"desktop-v${version}-rc.\"))) | .tagName"+ if rc_tags="$(gh release list --repo "$repo" --limit 100 --json tagName,isPrerelease,isDraft --jq "$rc_jq" 2>/dev/null)"; then+ while IFS= read -r rc_tag; do+ [[ -n "$rc_tag" ]] || continue+ if gh release delete "$rc_tag" --repo "$repo" --cleanup-tag --yes; then+ echo "desktop-release: removed graduated prerelease $rc_tag"+ else+ echo "desktop-release: warning: could not remove graduated prerelease $rc_tag" >&2+ fi+ done <<<"$rc_tags"+ else+ echo "desktop-release: warning: could not list prereleases for RC cleanup" >&2+ fi}command="${1:-}"@@ -444,5 +512,6 @@ case "$command" inchecksums) cmd_checksums "$@" ;;gitlab-upload) cmd_gitlab_upload "$@" ;;github-release) cmd_github_release "$@" ;;+ publish) cmd_publish "$@" ;;*) usage ;;esacdiff --git a/scripts/ci/desktop-release.test.ts b/scripts/ci/desktop-release.test.tsindex d7b42ea9..dea6f8c9 100644--- a/scripts/ci/desktop-release.test.ts+++ b/scripts/ci/desktop-release.test.ts@@ -347,7 +347,7 @@ describe("desktop-release.sh github-release", () => {expect(result.calls).not.toContain("abc123");});- it("marks a stable release as the latest", () => {+ it("creates a stable release as a draft without marking it latest", () => {const dir = folder();const bin = folder();const log = join(dir, "gh.log");@@ -365,7 +365,11 @@ describe("desktop-release.sh github-release", () => {});expect(result.status).toBe(0);- expect(readFileSync(log, "utf8")).toContain("--latest");+ const calls = readFileSync(log, "utf8");+ expect(calls).toContain("--draft");+ expect(calls).not.toContain("--latest");+ expect(calls).not.toContain("--prerelease");+ expect(result.stdout).toContain("publish desktop-v1.0.0 --notes-file");});it("needs LINGER_RELEASE_TOKEN to publish from another repository", () => {@@ -386,3 +390,107 @@ describe("desktop-release.sh github-release", () => {expect(result.stderr).toContain("owner/name");});});++describe("desktop-release.sh publish", () => {+ function setupPublish(assets: string[], rcTags: string[] = []) {+ const dir = folder();+ const bin = folder();+ const log = join(dir, "gh.log");+ const assetsFile = join(dir, "assets.txt");+ const rcFile = join(dir, "rc-tags.txt");+ writeFileSync(assetsFile, assets.length ? `${assets.join("\n")}\n` : "");+ writeFileSync(rcFile, rcTags.length ? `${rcTags.join("\n")}\n` : "");+ writeFileSync(+ join(bin, "gh"),+ [+ "#!/bin/sh",+ `echo "$*" >>"${log}"`,+ 'if [ "$2" = view ]; then',+ ` cat "${assetsFile}"`,+ " exit 0",+ "fi",+ 'if [ "$2" = list ]; then',+ ` cat "${rcFile}"`,+ " exit 0",+ "fi",+ "exit 0",+ "",+ ].join("\n"),+ );+ chmodSync(join(bin, "gh"), 0o755);+ const notes = join(dir, "notes.md");+ writeFileSync(notes, "Linger Desktop 1.0.0\n\n## Highlights\n\n- Works.\n");+ return { bin, log, notes };+ }++ it("publishes a stable draft with notes as latest and removes matching RC prereleases", () => {+ const { bin, log, notes } = setupPublish(+ [+ "Linger-1.0.0-macos-arm64.dmg",+ "Linger-1.0.0-linux-x64.tar.gz",+ "Linger-1.0.0-windows-x64-setup.exe",+ "SHA256SUMS.txt",+ ],+ ["desktop-v1.0.0-rc.0", "desktop-v1.0.0-rc.1"],+ );++ const result = run(["publish", "desktop-v1.0.0", "--notes-file", notes], {+ PATH: `${bin}:${process.env.PATH ?? ""}`,+ });++ expect(result.status).toBe(0);+ const calls = readFileSync(log, "utf8");+ expect(calls).toContain(+ "release view desktop-v1.0.0 --repo simplexai-labs/linger --json assets --jq .assets[].name",+ );+ expect(calls).toContain(+ `release edit desktop-v1.0.0 --repo simplexai-labs/linger --notes-file ${notes} --draft=false --latest`,+ );+ expect(calls).toContain(+ 'release list --repo simplexai-labs/linger --limit 100 --json tagName,isPrerelease,isDraft --jq .[] | select(.isPrerelease and (.isDraft | not) and (.tagName | startswith("desktop-v1.0.0-rc."))) | .tagName',+ );+ expect(calls).toContain(+ "release delete desktop-v1.0.0-rc.0 --repo simplexai-labs/linger --cleanup-tag --yes",+ );+ expect(calls).toContain(+ "release delete desktop-v1.0.0-rc.1 --repo simplexai-labs/linger --cleanup-tag --yes",+ );+ });++ it("refuses to publish when a required release asset is missing", () => {+ const { bin, log, notes } = setupPublish([+ "Linger-1.0.0-macos-arm64.dmg",+ "Linger-1.0.0-linux-x64.tar.gz",+ "SHA256SUMS.txt",+ ]);++ const result = run(["publish", "desktop-v1.0.0", "--notes-file", notes], {+ PATH: `${bin}:${process.env.PATH ?? ""}`,+ });++ expect(result.status).toBe(1);+ expect(result.stderr).toContain("Linger-1.0.0-windows-x64-setup.exe");+ expect(readFileSync(log, "utf8")).not.toContain("release edit");+ });++ it("refuses prerelease tags and empty notes files", () => {+ const { bin, notes } = setupPublish([]);+ const emptyNotes = join(folder(), "empty.md");+ writeFileSync(emptyNotes, " \n");++ const pre = run(["publish", "desktop-v1.0.0-rc.1", "--notes-file", notes], {+ PATH: `${bin}:${process.env.PATH ?? ""}`,+ });+ expect(pre.status).toBe(1);+ expect(pre.stderr).toContain("not prereleases");++ const empty = run(+ ["publish", "desktop-v1.0.0", "--notes-file", emptyNotes],+ {+ PATH: `${bin}:${process.env.PATH ?? ""}`,+ },+ );+ expect(empty.status).toBe(1);+ expect(empty.stderr).toContain("empty");+ });+});