Computer use CLI for AI agents
Rust accessibilityaccessibility-apiai-agentsautomationclicomputer-usecomputer-use-agentcomputer-use-agentsdesktop-automationmacosmcprust
fix: publish releases automatically and retire the custom package catalogs (#320)
Lahfir42170d8df93a
diff --git a/.github/workflows/homebrew.yml b/.github/workflows/homebrew.ymldeleted file mode 100644index f4f6884f8..000000000--- a/.github/workflows/homebrew.yml+++ /dev/null@@ -1,36 +0,0 @@-name: Homebrew--on:- push:- branches: [main]- paths: ["Formula/**", "tests/native-install/homebrew.sh", ".github/workflows/homebrew.yml"]- pull_request:- paths: ["Formula/**", "tests/native-install/homebrew.sh", ".github/workflows/homebrew.yml"]- workflow_dispatch:--permissions:- contents: read--jobs:- install:- name: Fresh Homebrew install (${{ matrix.os }})- strategy:- fail-fast: false- matrix:- os: [macos-latest, ubuntu-24.04, ubuntu-24.04-arm]- runs-on: ${{ matrix.os }}- timeout-minutes: 15- env:- HOMEBREW_NO_AUTO_UPDATE: "1"- HOMEBREW_NO_INSTALL_CLEANUP: "1"- steps:- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1- with:- persist-credentials: false- - name: Enable runner Homebrew- run: |- if [ "$RUNNER_OS" = Linux ]; then- echo /home/linuxbrew/.linuxbrew/bin >> "$GITHUB_PATH"- fi- - name: Install and test native formula- run: bash tests/native-install/homebrew.shdiff --git a/.github/workflows/release-packages.yml b/.github/workflows/release-packages.ymldeleted file mode 100644index e7ea941af..000000000--- a/.github/workflows/release-packages.yml+++ /dev/null@@ -1,48 +0,0 @@-name: Update release packages--on:- workflow_call:- inputs:- version:- required: true- type: string--permissions: {}--jobs:- update:- if: github.ref == 'refs/heads/main'- runs-on: ubuntu-latest- timeout-minutes: 15- permissions:- contents: write- pull-requests: write- actions: write- attestations: read- steps:- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1- with:- ref: main- persist-credentials: false- - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020- with:- node-version: '24'- package-manager-cache: false- - name: Verify published release and generate package metadata- env:- GH_TOKEN: ${{ github.token }}- GH_REPO: ${{ github.repository }}- VERSION: ${{ inputs.version }}- run: |- test "$(node scripts/release-version.js)" = "$VERSION"- archives="$RUNNER_TEMP/release-packages"- gh release download "v$VERSION" --dir "$archives" --pattern 'checksums.txt' --pattern 'agent-desktop-v*.tar.gz'- gh attestation verify "$archives/checksums.txt" --repo "$GH_REPO" \- --signer-workflow "$GH_REPO/.github/workflows/release.yml" \- --source-ref refs/heads/main --deny-self-hosted-runners- node scripts/update-release-packages.js "$archives"- - name: Open package update PR and run checks- env:- GH_TOKEN: ${{ github.token }}- GH_REPO: ${{ github.repository }}- run: bash scripts/open-release-package-pr.shdiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 9b920679d..1d8eba031 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -1,6 +1,9 @@name: Releaseon:+ push:+ branches: [main]+ paths: [Cargo.toml]workflow_dispatch:concurrency:@@ -831,19 +834,3 @@ jobs:- name: Publish to npmrun: npm publish --access publicworking-directory: npm-- update-packages:- needs: [check-release, publish-github]- if: >-- !cancelled() && needs.check-release.result == 'success' &&- (needs.publish-github.result == 'success' ||- (needs.check-release.outputs.should_release == 'false' &&- needs.check-release.outputs.needs_github_release == 'false'))- permissions:- contents: write- pull-requests: write- actions: write- attestations: read- uses: ./.github/workflows/release-packages.yml- with:- version: ${{ needs.check-release.outputs.version }}diff --git a/.github/workflows/scoop.yml b/.github/workflows/scoop.ymldeleted file mode 100644index ee3819bc6..000000000--- a/.github/workflows/scoop.yml+++ /dev/null@@ -1,36 +0,0 @@-name: Scoop--on:- push:- branches: [main]- paths: ["bucket/**", "tests/native-install/scoop.ps1", ".github/workflows/scoop.yml"]- pull_request:- paths: ["bucket/**", "tests/native-install/scoop.ps1", ".github/workflows/scoop.yml"]- workflow_dispatch:--permissions:- contents: read--jobs:- install:- name: Fresh Scoop install (${{ matrix.os }})- strategy:- fail-fast: false- matrix:- os: [windows-latest, windows-11-arm]- runs-on: ${{ matrix.os }}- timeout-minutes: 15- steps:- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1- with:- persist-credentials: false- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1- with:- repository: ScoopInstaller/Scoop- ref: e6aa3b366bdee8ed138c1e0f7b85192ebdd35d0f- path: .test-scoop/apps/scoop/current- persist-credentials: false- - name: Install and test native manifest- shell: powershell- run: |- & tests/native-install/scoop.ps1 -ScoopRoot "$PWD/.test-scoop" -Manifest "$PWD/bucket/agent-desktop.json"diff --git a/.gitignore b/.gitignoreindex 5fd7263b5..a6afdfcbd 100644--- a/.gitignore+++ b/.gitignore@@ -70,6 +70,7 @@ docs/*!docs/faq.md!docs/install.md!docs/json-output.md+!docs/releasing.md!docs/solutions/# Windows probe scratch builds, regenerated by their build scriptsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 055cef07c..ae2cac975 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,8 @@### Bug Fixes* Preserve macOS applications with missing localized display names in the complete inventory, using their executable name or bundle identifier. Such applications no longer block unrelated app-scoped snapshots, window lists, and screenshots.+* Publish npm and GitHub releases automatically when the Cargo workspace version changes on main.+* Remove the custom Homebrew tap, the Scoop bucket, and their package-update pull requests.* Remove the `version` line from the skills. In 1.0.0 it still said 0.11.1; `agent-desktop version` reports the version.## [1.0.0](https://github.com/lahfir/agent-desktop/compare/v0.11.1...v1.0.0) (2026-10-27)diff --git a/Formula/agent-desktop.rb b/Formula/agent-desktop.rbdeleted file mode 100644index ca4b42f67..000000000--- a/Formula/agent-desktop.rb+++ /dev/null@@ -1,47 +0,0 @@-class AgentDesktop < Formula- desc "Native accessibility-based desktop automation for agents"- homepage "https://github.com/lahfir/agent-desktop"- version "0.11.1"- license "Apache-2.0"-- on_macos do- depends_on macos: :ventura-- on_arm do- url "https://github.com/lahfir/agent-desktop/releases/download/v0.11.1/agent-desktop-v0.11.1-aarch64-apple-darwin.tar.gz"- sha256 "666671bd944fb88bf5b5668589f2bd653cd3a01942035260b454736879ff8779"- end-- on_intel do- url "https://github.com/lahfir/agent-desktop/releases/download/v0.11.1/agent-desktop-v0.11.1-x86_64-apple-darwin.tar.gz"- sha256 "32aedc30a787e8ec71ddec758128b30762a31a6ae9833099a5bc1288be302cf9"- end- end-- on_linux do- on_arm do- url "https://github.com/lahfir/agent-desktop/releases/download/v0.11.1/agent-desktop-v0.11.1-aarch64-unknown-linux-gnu.tar.gz"- sha256 "cdf02e3b3b08f812af28ea477fee9bd72f78fe87a9888768a0750d60bb4dd509"- end-- on_intel do- url "https://github.com/lahfir/agent-desktop/releases/download/v0.11.1/agent-desktop-v0.11.1-x86_64-unknown-linux-gnu.tar.gz"- sha256 "89674d626b3e15536e8084ac883d2507ca2f67d187f7e0b138305f371fb25138"- end- end-- def install- bin.install "agent-desktop"- bin.install "agent-desktop-macos-helper" if OS.mac?- bin.install "agent-desktop-linux-clipboard-owner" if OS.linux?- end-- test do- require "json"- response = JSON.parse(shell_output("#{bin}/agent-desktop version"))- assert_equal true, response.fetch("ok")- assert_equal version.to_s, response.fetch("data").fetch("version")- assert_equal OS.mac? ? "macos" : "linux", response.fetch("data").fetch("os")- assert_path_exists bin/(OS.mac? ? "agent-desktop-macos-helper" : "agent-desktop-linux-clipboard-owner")- end-enddiff --git a/README.md b/README.mdindex 57f9c619f..26fcdca14 100644--- a/README.md+++ b/README.md@@ -17,39 +17,25 @@ Snapshots, clipboard reads, screenshots, command output and debug artifacts can## Installation-Use a native package manager for a direct executable with no runtime wrapper or npm postinstall step.--**macOS and Linux** ([Homebrew](https://brew.sh)):+Install on macOS, Windows or Linux with npm:```bash-brew tap lahfir/agent-desktop https://github.com/lahfir/agent-desktop.git-brew install lahfir/agent-desktop/agent-desktop+npm install -g agent-desktop+agent-desktop version```-**Windows** ([Scoop](https://scoop.sh)):+Bun, Yarn and pnpm can install the same package. It includes native binaries and platform helpers for x64 and ARM64.+For direct execution without a JavaScript launcher, download the matching native archive from+[GitHub Releases](https://github.com/lahfir/agent-desktop/releases) and keep its helper beside the executable.-```powershell-scoop bucket add agent-desktop https://github.com/lahfir/agent-desktop.git-scoop install agent-desktop/agent-desktop-```--Homebrew links the native executable; Scoop adds its native executable directory to PATH without creating a shim.-Both select the matching x64 or ARM64 release and verify its pinned SHA-256. Run `agent-desktop version` to check-installation. If an older npm install appears first on PATH, uninstall it with its original package manager.+Official Homebrew and Scoop packages are being submitted; they are not yet available in the default catalogs.+The repository no longer maintains a custom Homebrew tap or Scoop bucket.- **macOS** needs Accessibility permission: `agent-desktop permissions --guide`.- **Windows** needs no grant for apps at your terminal's integrity level.- **Linux** needs the user's graphical session with `at-spi2-core`.-See [installation and permissions](docs/install.md) for upgrades, release archives, and building from source.-**npm** remains supported on all three platforms:--```bash-npm install -g agent-desktop-```--Bun, Yarn and pnpm can install the same `agent-desktop` package. Some npm-family paths retain their package-manager's launcher; the native packages above provide direct execution.+See [installation and permissions](docs/install.md) for package-manager behavior, release archives, and building from source.## Quick startdiff --git a/bucket/agent-desktop.json b/bucket/agent-desktop.jsondeleted file mode 100644index 8b9a05b22..000000000--- a/bucket/agent-desktop.json+++ /dev/null@@ -1,17 +0,0 @@-{- "version": "0.11.1",- "description": "Native accessibility-based desktop automation for agents",- "homepage": "https://github.com/lahfir/agent-desktop",- "license": "Apache-2.0",- "architecture": {- "64bit": {- "url": "https://github.com/lahfir/agent-desktop/releases/download/v0.11.1/agent-desktop-v0.11.1-x86_64-pc-windows-msvc.tar.gz",- "hash": "524c378e1afc7762f6e49b61cf58d45cbf0d54fecec618b2a1fd0d6fb282afe2"- },- "arm64": {- "url": "https://github.com/lahfir/agent-desktop/releases/download/v0.11.1/agent-desktop-v0.11.1-aarch64-pc-windows-msvc.tar.gz",- "hash": "d879c4130015d5d8a6d0c2c3935ca0d04c58624dc65259788785e6dd07f0fd8e"- }- },- "env_add_path": "."-}diff --git a/docs/install.md b/docs/install.mdindex 77fad1674..85e846f37 100644--- a/docs/install.md+++ b/docs/install.md@@ -1,41 +1,29 @@# Installing agent-desktop-Native packages are the default on macOS, Windows and Linux, on x64 and ARM64. They install the released-executable without a JavaScript launcher or an agent-desktop postinstall script.--## macOS and Linux: Homebrew--With [Homebrew](https://brew.sh) installed:+Install the `agent-desktop` npm package with npm, pnpm, Yarn or Bun. It bundles native executables and platform+helpers for macOS, Windows and Linux, on x64 and ARM64:```bash-brew tap lahfir/agent-desktop https://github.com/lahfir/agent-desktop.git-brew install lahfir/agent-desktop/agent-desktop+npm install -g agent-desktopagent-desktop version```-Homebrew creates a symlink to the native executable and installs its platform helper beside it. Upgrade with-`brew update && brew upgrade lahfir/agent-desktop/agent-desktop`; uninstall with-`brew uninstall lahfir/agent-desktop/agent-desktop`.--## Windows: Scoop+For a direct native executable without a JavaScript launcher, download the archive for your OS and architecture+from [GitHub Releases](https://github.com/lahfir/agent-desktop/releases). Extract the executable and its platform+helper together into a directory on PATH. Upgrade by replacing both with files from the same release.-With [Scoop](https://scoop.sh) installed, run in a non-administrator PowerShell:+## Homebrew and Scoop-```powershell-scoop bucket add agent-desktop https://github.com/lahfir/agent-desktop.git-scoop install agent-desktop/agent-desktop-agent-desktop version-(Get-Command agent-desktop).Source-```+Official packages are being submitted to `Homebrew/homebrew-core` and `ScoopInstaller/Main`. They are not yet+available through the default catalogs. This repository no longer maintains a custom tap or bucket; existing+custom installations remain pinned to their installed version.-The command resolves to `apps\agent-desktop\current\agent-desktop.exe`. Scoop manages the `current` directory-junction and adds it to PATH. This package creates no `.cmd`, `.ps1`, or executable shim and has no install hooks.-Upgrade with `scoop update; scoop update agent-desktop`; uninstall with `scoop uninstall agent-desktop`.+Once accepted, Homebrew builds from the tagged source and manages its own bottles. Scoop installs the Windows+release archive and checks GitHub releases for updates. Catalog updates and approvals are managed by those+projects, separately from our npm and GitHub release workflow.-Both managers check the archive against a SHA-256 pinned in the repository. The manual release workflow reads-`Cargo.toml` and opens a package-update PR using the published archives and their verified checksums. If a prior npm-family installation shadows the native command, uninstall-it through the manager that installed it, then open a new terminal. Check resolution with `command -v agent-desktop`-on macOS/Linux or `Get-Command agent-desktop` on Windows.+If an older installation shadows the command, uninstall it through its original package manager. Check resolution+with `command -v agent-desktop` on macOS/Linux or `Get-Command agent-desktop` on Windows.## Blocked install scriptsdiff --git a/docs/releasing.md b/docs/releasing.mdnew file mode 100644index 000000000..c6adda20d--- /dev/null+++ b/docs/releasing.md@@ -0,0 +1,14 @@+# Releasing++Update the Cargo workspace version, lockfile, npm source version, and changelog in one pull request.+After it merges to `main`, changes to `Cargo.toml` trigger the existing Release workflow.+An unchanged published version skips publication. Manual dispatch remains available for retries.++The workflow builds and checks the native CLI and FFI archives, bundles the CLI executables into npm,+publishes npm through trusted publishing (OIDC), and publishes GitHub archives, checksums, and provenance+with the built-in `GITHUB_TOKEN`. No extra release token or package-update commit is required.++Homebrew and Scoop package definitions belong in `Homebrew/homebrew-core` and `ScoopInstaller/Main`.+Their maintainers and update automation manage those catalogs after the initial submissions are accepted.+Homebrew builds from source; Scoop downloads the Windows release archives. Catalog availability can lag+behind npm and GitHub publication. Do not advertise default-catalog installation before acceptance.diff --git a/scripts/open-release-package-pr.sh b/scripts/open-release-package-pr.shdeleted file mode 100644index a925b591e..000000000--- a/scripts/open-release-package-pr.sh+++ /dev/null@@ -1,32 +0,0 @@-#!/usr/bin/env bash-set -euo pipefail--VERSION=$(node scripts/release-version.js)-BRANCH="release/packages-v${VERSION}"-git add -- Formula/agent-desktop.rb bucket/agent-desktop.json npm/package.json-if git diff --cached --quiet; then- exit 0-fi--git switch -c "$BRANCH"-git config user.name "$(gh api "users/${GITHUB_ACTOR}" --jq '.name // .login')"-git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"-git commit -m "chore: update packages to ${VERSION}"-gh auth setup-git-REMOTE_SHA=$(git ls-remote --heads origin "refs/heads/$BRANCH" | cut -f1)-git push --force-with-lease="refs/heads/$BRANCH:$REMOTE_SHA" origin "HEAD:refs/heads/$BRANCH"--PR=$(gh pr list --head "$BRANCH" --base main --state open --json number --jq '.[0].number // empty')-if [ -z "$PR" ]; then- BODY=$(mktemp)- cat > "$BODY" <<'EOF'-Update native package definitions and npm source metadata from the published release.-All CLI archive hashes and the checksum manifest's release-workflow attestation were verified.-Repository and native installation checks run on this branch. Merge after review and green checks.-EOF- gh pr create --base main --head "$BRANCH" \- --title "chore: update packages to ${VERSION}" --body-file "$BODY"-fi-for workflow in ci.yml supply-chain.yml codeql.yml homebrew.yml scoop.yml; do- gh workflow run "$workflow" --ref "$BRANCH"-donediff --git a/scripts/update-release-packages.js b/scripts/update-release-packages.jsdeleted file mode 100644index a2553adc4..000000000--- a/scripts/update-release-packages.js+++ /dev/null@@ -1,52 +0,0 @@-const { createHash } = require('node:crypto');-const { readFileSync, writeFileSync } = require('node:fs');-const { join } = require('node:path');-const { PLATFORMS, tarballName } = require('../npm/lib/platform');-const { checksumFor } = require('../npm/scripts/postinstall');-const { releaseVersion } = require('./release-version');--function updateReleasePackages(root, archives) {- const version = releaseVersion(readFileSync(join(root, 'Cargo.toml'), 'utf8'));- const npmPath = join(root, 'npm/package.json');- const npm = JSON.parse(readFileSync(npmPath, 'utf8'));- const repository = npm.repository.url.replace(/^git\+/, '').replace(/\.git$/, '');- const checksums = readFileSync(join(archives, 'checksums.txt'), 'utf8');- const packages = {};- for (const [key, platform] of Object.entries(PLATFORMS)) {- if (!platform.released) continue;- const name = tarballName(version, platform.target);- const hash = createHash('sha256').update(readFileSync(join(archives, name))).digest('hex');- if (hash !== checksumFor(checksums, name)) throw new Error(`Checksum mismatch for ${name}`);- packages[key] = { url: `${repository}/releases/download/v${version}/${name}`, hash };- }-- const formulaPath = join(root, 'Formula/agent-desktop.rb');- let formula = readFileSync(formulaPath, 'utf8').replace(/\r\n/g, '\n');- if ((formula.match(/^ version "[^"\n]+"$/gm) || []).length !== 1) {- throw new Error('Expected one Homebrew version');- }- formula = formula.replace(/^ version "[^"\n]+"$/m, ` version "${version}"`);- for (const [key, platform] of Object.entries(PLATFORMS)) {- if (!platform.released || key.startsWith('win32-')) continue;- const pattern = new RegExp(`url "[^"\\n]+-${platform.target}\\.tar\\.gz"\\r?\\n( +)sha256 "[0-9a-f]{64}"`, 'g');- if ([...formula.matchAll(pattern)].length !== 1) throw new Error(`Expected one Homebrew archive for ${key}`);- const { url, hash } = packages[key];- formula = formula.replace(pattern, (_, indent) => `url "${url}"\n${indent}sha256 "${hash}"`);- }-- const scoopPath = join(root, 'bucket/agent-desktop.json');- const scoop = JSON.parse(readFileSync(scoopPath, 'utf8'));- scoop.version = version;- scoop.architecture = { '64bit': packages['win32-x64'], arm64: packages['win32-arm64'] };- npm.version = version;-- writeFileSync(formulaPath, formula);- writeFileSync(scoopPath, `${JSON.stringify(scoop, null, 4)}\n`);- writeFileSync(npmPath, `${JSON.stringify(npm, null, 2)}\n`);-}--if (require.main === module) {- if (!process.argv[2]) throw new Error('Usage: node scripts/update-release-packages.js ARCHIVE_DIRECTORY');- updateReleasePackages(process.cwd(), process.argv[2]);-}-module.exports = { updateReleasePackages };diff --git a/tests/native-install/homebrew.sh b/tests/native-install/homebrew.shindex 70ce72e71..bc7cb64bb 100644--- a/tests/native-install/homebrew.sh+++ b/tests/native-install/homebrew.sh@@ -1,6 +1,8 @@#!/usr/bin/env bashset -euo pipefail+FORMULA=${1:?Usage: homebrew.sh FORMULA_PATH}+test -f "$FORMULA"TAP=lahfir/agent-desktop-ciTAP_PATH="$(brew --repository)/Library/Taps/lahfir/homebrew-agent-desktop-ci"test ! -e "$TAP_PATH"@@ -9,7 +11,7 @@ mkdir -p "$TAP_PATH/Formula"git -C "$TAP_PATH" initgit -C "$TAP_PATH" -c user.name=Lahfir -c [email protected] \commit --allow-empty -m 'test: initialize native installation tap'-cp Formula/agent-desktop.rb "$(brew --repo "$TAP")/Formula/agent-desktop.rb"+cp "$FORMULA" "$(brew --repo "$TAP")/Formula/agent-desktop.rb"brew install "$TAP/agent-desktop"brew test "$TAP/agent-desktop"PREFIX=$(brew --prefix)diff --git a/tests/release/package-pr.test.js b/tests/release/package-pr.test.jsdeleted file mode 100644index 7819227c0..000000000--- a/tests/release/package-pr.test.js+++ /dev/null@@ -1,73 +0,0 @@-const assert = require('node:assert/strict');-const { execFileSync, spawnSync } = require('node:child_process');-const { copyFileSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } = require('node:fs');-const { tmpdir } = require('node:os');-const { join, resolve } = require('node:path');-const { test } = require('node:test');--const source = resolve(__dirname, '../..');-const files = ['Formula/agent-desktop.rb', 'bucket/agent-desktop.json', 'npm/package.json'];--test('package PR creation is repeatable, excludes unrelated files, and stops on push failure', { skip: process.platform === 'win32' }, () => {- const root = mkdtempSync(join(tmpdir(), 'ad-package-pr-'));- const remote = join(root, 'origin.git');- const tools = join(root, 'tools');- const calls = join(root, 'gh.log');- const marker = join(root, 'pr-created');- mkdirSync(tools);- writeFileSync(calls, '');- writeFileSync(join(tools, 'gh'), `#!/bin/sh-set -eu-printf '%s\\n' "$*" >> "$TEST_GH_LOG"-case "$1 $2" in- 'api users/'*) printf 'Release Actor\\n' ;;- 'auth setup-git') ;;- 'pr list') if [ -f "$TEST_PR_MARKER" ]; then printf '42\\n'; fi ;;- 'pr create') touch "$TEST_PR_MARKER" ;;- 'workflow run') ;;- *) exit 99 ;;-esac-`, { mode: 0o755 });- const runGit = (cwd, ...args) => execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();- runGit(root, 'init', '--bare', '-q', remote);- const main = join(root, 'main');- runGit(root, 'clone', '-q', remote, main);- runGit(main, 'switch', '-c', 'main');- for (const directory of ['scripts', 'Formula', 'bucket', 'npm']) mkdirSync(join(main, directory));- for (const script of ['release-version.js', 'open-release-package-pr.sh']) copyFileSync(join(source, 'scripts', script), join(main, 'scripts', script));- writeFileSync(join(main, 'Cargo.toml'), '[workspace.package]\nversion = "1.2.3"\n');- for (const file of files) writeFileSync(join(main, file), 'previous release\n');- runGit(main, 'add', '.');- runGit(main, '-c', 'user.name=Lahfir', '-c', '[email protected]', 'commit', '-qm', 'test: release fixture');- runGit(main, 'push', '-q', 'origin', 'main');- const branch = 'release/packages-v1.2.3';- const execute = (name, changed) => {- const checkout = join(root, name);- runGit(root, 'clone', '-q', '--branch', 'main', remote, checkout);- if (changed) for (const file of files) writeFileSync(join(checkout, file), `new release ${name}\n`);- writeFileSync(join(checkout, 'unrelated.txt'), 'leave untouched\n');- return spawnSync('bash', ['scripts/open-release-package-pr.sh'], {- cwd: checkout, encoding: 'utf8', env: { ...process.env,- PATH: `${tools}:${process.env.PATH}`, GITHUB_ACTOR: 'release-actor', GITHUB_ACTOR_ID: '123',- TEST_GH_LOG: calls, TEST_PR_MARKER: marker },- });- };- for (const name of ['first', 'repeat']) {- const result = execute(name, true);- assert.equal(result.status, 0, result.stderr);- assert.deepEqual(runGit(remote, 'diff-tree', '--no-commit-id', '--name-only', '-r', branch).split('\n'), files);- assert.equal(runGit(remote, 'show', '-s', '--format=%an <%ae>', branch), 'Release Actor <[email protected]>');- }- const log = readFileSync(calls, 'utf8');- assert.equal(log.split('\n').filter((line) => line.startsWith('pr create ')).length, 1);- assert.equal(log.split('\n').filter((line) => line.startsWith('workflow run ')).length, 10);- const before = runGit(remote, 'rev-parse', branch);- assert.equal(execute('unchanged', false).status, 0);- assert.equal(readFileSync(calls, 'utf8'), log);- writeFileSync(join(remote, 'hooks/pre-receive'), '#!/bin/sh\nexit 1\n', { mode: 0o755 });- const rejected = execute('rejected', true);- assert.notEqual(rejected.status, 0);- assert.match(rejected.stderr, /pre-receive hook declined/);- assert.equal(runGit(remote, 'rev-parse', branch), before);- assert.equal(readFileSync(calls, 'utf8').split('\n').filter((line) => /^(pr|workflow) /.test(line)).join('\n'), log.split('\n').filter((line) => /^(pr|workflow) /.test(line)).join('\n'));-});diff --git a/tests/release/packages.test.js b/tests/release/packages.test.jsdeleted file mode 100644index 122788a28..000000000--- a/tests/release/packages.test.js+++ /dev/null@@ -1,90 +0,0 @@-const assert = require('node:assert/strict');-const { createHash } = require('node:crypto');-const { copyFileSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } = require('node:fs');-const { tmpdir } = require('node:os');-const { join, resolve } = require('node:path');-const { test } = require('node:test');-const { PLATFORMS, tarballName } = require('../../npm/lib/platform');-const { releaseVersion } = require('../../scripts/release-version');-const { updateReleasePackages } = require('../../scripts/update-release-packages');--const files = ['Formula/agent-desktop.rb', 'bucket/agent-desktop.json', 'npm/package.json'];-function fixture() {- const root = mkdtempSync(join(tmpdir(), 'ad-release-packages-'));- for (const name of ['Formula', 'bucket', 'npm', 'archives']) mkdirSync(join(root, name));- for (const file of files) copyFileSync(resolve(__dirname, '../..', file), join(root, file));- writeFileSync(join(root, 'Cargo.toml'), '[workspace.package]\nversion = "0.12.3"\n');- const archives = join(root, 'archives');- const expected = {};- for (const [key, platform] of Object.entries(PLATFORMS)) {- const name = tarballName('0.12.3', platform.target);- const content = Buffer.from(`release artifact for ${key}`);- const hash = createHash('sha256').update(content).digest('hex');- writeFileSync(join(archives, name), content);- expected[key] = { name, hash };- }- writeFileSync(join(archives, 'checksums.txt'), Object.values(expected).map(({ name, hash }) => `${hash} ${name}`).join('\n'));- return { root, archives, expected };-}-const contents = (root) => files.map((file) => readFileSync(join(root, file), 'utf8'));--test('one Cargo version updates all six archives and npm; regeneration is a no-op', () => {- const { root, archives, expected } = fixture();- const packagePath = join(root, 'npm/package.json');- const metadata = JSON.parse(readFileSync(packagePath, 'utf8'));- metadata.repository.url = 'git+https://github.com/release-owner/desktop-tool.git';- writeFileSync(packagePath, JSON.stringify(metadata));- updateReleasePackages(root, archives);- const [formula, scoopText, npmText] = contents(root);- const scoop = JSON.parse(scoopText);- assert.equal(JSON.parse(npmText).version, '0.12.3');- assert.equal(scoop.version, '0.12.3');- assert.match(formula, /version "0\.12\.3"/);- for (const [key, { name, hash }] of Object.entries(expected)) {- const url = `https://github.com/release-owner/desktop-tool/releases/download/v0.12.3/${name}`;- if (key.startsWith('win32-')) {- assert.deepEqual(scoop.architecture[key.endsWith('x64') ? '64bit' : 'arm64'], { url, hash });- } else {- assert.ok(formula.includes(`url "${url}"\n sha256 "${hash}"`));- }- }- assert.equal(scoop.env_add_path, '.');- assert.equal(scoop.bin, undefined);- assert.equal(scoop.post_install, undefined);- assert.match(formula, /bin\.install "agent-desktop-macos-helper"/);- assert.match(formula, /bin\.install "agent-desktop-linux-clipboard-owner"/);- const once = contents(root);- updateReleasePackages(root, archives);- assert.deepEqual(contents(root), once);-});--test('metadata generation accepts a Windows checkout with CRLF', () => {- const { root, archives } = fixture();- const formula = join(root, files[0]);- writeFileSync(formula, readFileSync(formula, 'utf8').replace(/\r?\n/g, '\r\n'));- updateReleasePackages(root, archives);- assert.match(readFileSync(formula, 'utf8'), /version "0\.12\.3"/);-});--for (const problem of ['corrupt archive', 'missing checksum', 'changed formula', 'invalid version']) {- test(`${problem} fails before any package file is updated`, () => {- const { root, archives, expected } = fixture();- if (problem === 'corrupt archive') writeFileSync(join(archives, expected['win32-x64'].name), 'tampered');- if (problem === 'missing checksum') writeFileSync(join(archives, 'checksums.txt'), '');- if (problem === 'changed formula') writeFileSync(join(root, files[0]), 'unrecognized formula');- if (problem === 'invalid version') writeFileSync(join(root, 'Cargo.toml'), '[workspace.package]\nversion = "../../bad"\n');- const before = contents(root);- assert.throws(() => updateReleasePackages(root, archives));- assert.deepEqual(contents(root), before);- });-}--test('version comes only from the workspace package section', () => {- const toml = '[package]\nversion = "9.9.9"\n[workspace.package]\nversion = "1.2.3"\n[dependencies]\nversion = "8.8.8"\n';- assert.equal(releaseVersion(toml), '1.2.3');- assert.equal(releaseVersion(toml.replaceAll('\n', '\r\n')), '1.2.3');- for (const version of ['', '1.2', 'v1.2.3', '1.2.3;echo bad', '01.2.3']) {- assert.throws(() => releaseVersion(`[workspace.package]\nversion = "${version}"\n`));- }- assert.throws(() => releaseVersion('[package]\nversion = "1.2.3"\n'));-});diff --git a/tests/release/prepare.test.js b/tests/release/prepare.test.jsindex 8e3757c0e..97e71c344 100644--- a/tests/release/prepare.test.js+++ b/tests/release/prepare.test.js@@ -4,6 +4,7 @@ const { mkdirSync, mkdtempSync, readFileSync, writeFileSync } = require('node:fsconst { tmpdir } = require('node:os');const { join, resolve } = require('node:path');const { test } = require('node:test');+const { releaseVersion } = require('../../scripts/release-version');function fixture() {const root = mkdtempSync(join(tmpdir(), 'ad-release-gate-'));@@ -82,3 +83,13 @@ test('release checkout accepts only commits in the triggering history', { skip:assert.equal(git('rev-parse', 'HEAD'), source === ancestor ? ancestor : workflow);}});++test('version comes only from the workspace package section', () => {+ const toml = '[package]\nversion = "9.9.9"\n[workspace.package]\nversion = "1.2.3"\n[dependencies]\nversion = "8.8.8"\n';+ assert.equal(releaseVersion(toml), '1.2.3');+ assert.equal(releaseVersion(toml.replaceAll('\n', '\r\n')), '1.2.3');+ for (const version of ['', '1.2', 'v1.2.3', '1.2.3;echo bad', '01.2.3']) {+ assert.throws(() => releaseVersion(`[workspace.package]\nversion = "${version}"\n`));+ }+ assert.throws(() => releaseVersion('[package]\nversion = "1.2.3"\n'));+});