Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 43 additions & 13 deletions .github/workflows/cd-rust-cua-driver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,22 @@ jobs:
path: libs/cua-driver-rs/release/cua-driver-rs-*-linux-x86_64*.tar.gz
if-no-files-found: error

# ── Windows x86_64 ───────────────────────────────────────────────────────────
# ── Windows (x86_64 + arm64) ─────────────────────────────────────────────────
# One matrixed job per Windows target. The arm64 build cross-compiles from
# the x86_64 windows-latest runner — Rust + MSVC have first-class support
# for that cross, so no separate arm64 runner is needed. install.ps1 picks
# the matching zip at install time based on the host's OS architecture.
build-windows:
name: windows-x86_64
name: windows-${{ matrix.arch }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
target: x86_64-pc-windows-msvc
- arch: arm64
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Determine version
Expand All @@ -99,28 +111,29 @@ jobs:
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
targets: ${{ matrix.target }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
libs/cua-driver-rs/target
key: rust-cua-driver-rs-windows-x86_64-${{ hashFiles('libs/cua-driver-rs/Cargo.lock', 'libs/cua-driver-rs/**/Cargo.toml') }}
key: rust-cua-driver-rs-windows-${{ matrix.arch }}-${{ hashFiles('libs/cua-driver-rs/Cargo.lock', 'libs/cua-driver-rs/**/Cargo.toml') }}
restore-keys: |
rust-cua-driver-rs-windows-x86_64-
rust-cua-driver-rs-windows-${{ matrix.arch }}-
- name: Build (release)
working-directory: libs/cua-driver-rs
run: cargo build -p cua-driver --release --target x86_64-pc-windows-msvc
run: cargo build -p cua-driver --release --target ${{ matrix.target }}
- name: Package
working-directory: libs/cua-driver-rs
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
$label = "windows-x86_64"
$label = "windows-${{ matrix.arch }}"
$target = "${{ matrix.target }}"
$stage = "cua-driver-rs-${version}-${label}"
New-Item -ItemType Directory -Force -Path "release/$stage" | Out-Null
Copy-Item "target/x86_64-pc-windows-msvc/release/cua-driver.exe" "release/$stage/"
Copy-Item "target/$target/release/cua-driver.exe" "release/$stage/"
if (Test-Path "../../LICENSE.md") { Copy-Item "../../LICENSE.md" "release/$stage/LICENSE" }
Compress-Archive -Path "release/$stage/*" -DestinationPath "release/$stage.zip" -Force
# Bare binary (cua-driver.exe by itself) — matches Swift's
Expand All @@ -130,8 +143,8 @@ jobs:
Get-ChildItem "release/$stage*.zip"
- uses: actions/upload-artifact@v4
with:
name: cua-driver-rs-windows-x86_64
path: libs/cua-driver-rs/release/cua-driver-rs-*-windows-x86_64*.zip
name: cua-driver-rs-windows-${{ matrix.arch }}
path: libs/cua-driver-rs/release/cua-driver-rs-*-windows-${{ matrix.arch }}*.zip
if-no-files-found: error

# ── macOS universal (arm64 + x86_64 → lipo) ─────────────────────────────────
Expand Down Expand Up @@ -357,6 +370,13 @@ jobs:
mkdir -p release-upload
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) \
-exec cp {} release-upload/ \;
# Ship the installer scripts as first-class release assets so the
# canonical one-liners hit
# github.com/trycua/cua/releases/latest/download/install.{sh,ps1}
# — that URL is stable across releases and survives a typo in
# the per-version tag.
cp libs/cua-driver-rs/scripts/install.sh release-upload/install.sh
cp libs/cua-driver-rs/scripts/install.ps1 release-upload/install.ps1
echo "Release files:"
ls -lh release-upload/

Expand Down Expand Up @@ -434,9 +454,13 @@ jobs:

### Install (Windows)

Download `cua-driver-rs-${{ steps.version.outputs.version }}-windows-x86_64-binary.zip` from the
assets below, unzip to a location on your PATH (`%LOCALAPPDATA%\Programs\cua-driver-rs\`
is the convention), then run `cua-driver.exe list-tools` to confirm.
```powershell
irm https://github.com/trycua/cua/releases/latest/download/install.ps1 | iex
```

The installer auto-detects host architecture (x86_64 / arm64) and uses
directory junctions for the install layout, so it runs without admin
and without Developer Mode.

### Artifacts

Expand All @@ -453,5 +477,11 @@ jobs:
**Windows**
- `cua-driver-rs-${{ steps.version.outputs.version }}-windows-x86_64.zip` — directory zip
- `cua-driver-rs-${{ steps.version.outputs.version }}-windows-x86_64-binary.zip` — bare `cua-driver.exe`
- `cua-driver-rs-${{ steps.version.outputs.version }}-windows-arm64.zip` — directory zip (Windows on ARM)
- `cua-driver-rs-${{ steps.version.outputs.version }}-windows-arm64-binary.zip` — bare `cua-driver.exe` (Windows on ARM)

**Installer scripts**
- `install.sh` — Linux / macOS one-liner installer
- `install.ps1` — Windows one-liner installer
generate_release_notes: false
make_latest: false
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,95 @@ rm -rf /Applications/CuaDriverRs.app
The second command rewires the `~/.local/bin/cua-driver` symlink back to the Swift bundle.
</Callout>

### Install `cua-driver-rs` directly (Linux / Windows / macOS)

The cross-platform Rust port ships its own one-liners. Pick the one for your shell — no `--experimental-rust` plumbing through the Swift installer needed.

**Linux / macOS**

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver-rs/scripts/install.sh)"
```

**Windows (PowerShell)**

```powershell
irm https://github.com/trycua/cua/releases/latest/download/install.ps1 | iex
```

The Windows installer auto-detects host architecture (x64 / arm64) via `[System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture` and downloads the matching `cua-driver-rs-<v>-windows-{x86_64,arm64}.zip` from GitHub Releases. It runs **without admin** and **without Developer Mode** — the install layout is wired with NTFS directory junctions, which any unprivileged user can create.

#### Versioned-dirs install layout

Linux and Windows installs land in a three-tier layout that makes upgrades and rollbacks an atomic retarget of one link, never a file overwrite. The macOS install intentionally stays on a different layout (`/Applications/CuaDriverRs.app`) — see the [macOS asymmetry note](#why-macos-uses-a-different-layout) below.

**Linux**

```
$CUA_DRIVER_RS_HOME/ (default: ~/.cua-driver-rs)
packages/
releases/
0.2.0-x86_64-unknown-linux-gnu/cua-driver (real binary, immutable)
0.2.1-x86_64-unknown-linux-gnu/cua-driver (real binary, immutable)
current/cua-driver -> ../releases/0.2.1-x86_64-unknown-linux-gnu/cua-driver (symlink — active version)
$CUA_DRIVER_RS_INSTALL_DIR/cua-driver -> $CUA_DRIVER_RS_HOME/packages/current/cua-driver
(default: ~/.local/bin/cua-driver)
Comment on lines +82 to +91

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix the Linux current symlink examples.

libs/cua-driver-rs/scripts/install.sh makes ~/.cua-driver-rs/packages/current itself the symlink to releases/<version>-<target>. The tree here and the rollback snippet both model current/cua-driver as the link, and ../releases/... from packages/.current.tmp resolves to the wrong directory, so the documented rollback command would create a broken link.

Suggested doc fix
-    current/cua-driver -> ../releases/0.2.1-x86_64-unknown-linux-gnu/cua-driver  (symlink — active version)
+    current -> releases/0.2.1-x86_64-unknown-linux-gnu  (symlink — active version)
 $CUA_DRIVER_RS_INSTALL_DIR/cua-driver -> $CUA_DRIVER_RS_HOME/packages/current/cua-driver
@@
-ln -sfn ../releases/0.2.0-x86_64-unknown-linux-gnu ~/.cua-driver-rs/packages/.current.tmp
+ln -sfn releases/0.2.0-x86_64-unknown-linux-gnu ~/.cua-driver-rs/packages/.current.tmp
 mv -Tf ~/.cua-driver-rs/packages/.current.tmp ~/.cua-driver-rs/packages/current
 cua-driver --version    # → 0.2.0

Also applies to: 114-117

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/content/docs/cua-driver/guide/getting-started/installation.mdx` around
lines 82 - 90, The docs show the wrong symlink layout: the installer makes
$CUA_DRIVER_RS_HOME/packages/current a symlink to releases/<version>-<target>,
not $CUA_DRIVER_RS_HOME/packages/current/cua-driver; update the example and
rollback snippet to show packages/current ->
../releases/0.2.1-x86_64-unknown-linux-gnu and the install link as
$CUA_DRIVER_RS_INSTALL_DIR/cua-driver ->
$CUA_DRIVER_RS_HOME/packages/current/cua-driver (with releases/.../cua-driver
remaining the real binary); adjust the examples referenced around the rollback
snippet and lines 114-117 accordingly so packages/.current.tmp resolution
matches the actual installer behavior.

```

**Windows**

```
%USERPROFILE%\.cua-driver-rs\ ($env:CUA_DRIVER_RS_HOME)
packages\
releases\
0.2.0-x86_64-pc-windows-msvc\cua-driver.exe (real binary, immutable)
0.2.1-x86_64-pc-windows-msvc\cua-driver.exe (real binary, immutable)
current\ (directory junction → releases\0.2.1-...)
%LOCALAPPDATA%\Programs\trycua\cua-driver-rs\bin\ ($env:CUA_DRIVER_RS_INSTALL_DIR)
(directory junction → packages\current)
```

Both junctions are NTFS reparse points (`IO_REPARSE_TAG_MOUNT_POINT`), so the whole PATH-resolution chain `bin\ → current\ → releases\<v>\cua-driver.exe` is two filesystem hops transparently served from whichever release the inner junction currently points at.

#### Atomic upgrades and rollback

Both platforms ship every release into its own per-version directory under `packages/releases/`. Older versions are kept on disk so you can roll back without re-downloading. The active version is whichever directory `packages/current` points at.

**Linux — roll back to a specific version**

```bash
ln -sfn ../releases/0.2.0-x86_64-unknown-linux-gnu ~/.cua-driver-rs/packages/.current.tmp
mv -Tf ~/.cua-driver-rs/packages/.current.tmp ~/.cua-driver-rs/packages/current
cua-driver --version # → 0.2.0
```

The `mv -Tf` is the rename(2) idiom: a concurrent `cua-driver` lookup sees either the old or new target, never an absent path.

**Windows — roll back to a specific version**

Re-run the install one-liner with `$env:CUA_DRIVER_RS_VERSION` pinned to the version you want active. The installer notices the per-version dir is already on disk, skips the download, and just retargets the `current` junction — so the round-trip is a single junction retarget under the hood.

```powershell
$env:CUA_DRIVER_RS_VERSION = "0.2.0"
irm https://github.com/trycua/cua/releases/latest/download/install.ps1 | iex
cua-driver --version # → 0.2.0
```

Clear `$env:CUA_DRIVER_RS_VERSION` and re-run to roll forward to the newest release.

#### Env-var overrides

| Env var | Default (Linux/macOS) | Default (Windows) | What it controls |
|---|---|---|---|
| `CUA_DRIVER_RS_VERSION` | unset → resolve latest | unset → resolve latest | Pin a specific release (e.g. `0.2.0`). |
| `CUA_DRIVER_RS_INSTALL_DIR` | `~/.local/bin` | `%LOCALAPPDATA%\Programs\trycua\cua-driver-rs\bin` | The visible PATH-entry directory. On Windows this is itself a junction. |
| `CUA_DRIVER_RS_HOME` | `~/.cua-driver-rs` | `%USERPROFILE%\.cua-driver-rs` | Package home — holds `packages/releases/<v>/` and `packages/current`. |
| `CUA_DRIVER_RS_NO_MODIFY_PATH` *(Linux/macOS only)* | `0` | n/a — Windows installer never auto-edits PATH | Skip the rc-file PATH append. |

<Callout type="info">
**Why macOS uses a different layout.** On macOS the install still drops `CuaDriverRs.app` into `/Applications` and symlinks `~/.local/bin/cua-driver` into the bundle. The `.app` placement is the anchor for both **TCC attribution** (cdhash + bundle id) and **LaunchServices** (`open -a CuaDriverRs`); symlinking the `.app` from `/Applications` to a versioned dir under `$CUA_DRIVER_RS_HOME` would break both. The asymmetry is intentional — rollback on macOS = reinstall an older release tag with `CUA_DRIVER_RS_VERSION=<x.y.z>`.
</Callout>

### Verify it worked

```bash
Expand Down
Loading
Loading