Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat(cli): publish a Windows ARM64 agent build

Minh141120b96336233966
diff --git a/.github/workflows/jan-tauri-build-agent-nightly.yaml b/.github/workflows/jan-tauri-build-agent-nightly.yaml
index b0e729fb1..8520f840a 100644
--- a/.github/workflows/jan-tauri-build-agent-nightly.yaml
+++ b/.github/workflows/jan-tauri-build-agent-nightly.yaml
@@ -53,6 +53,15 @@ jobs:
new_version: ${{ needs.get-update-version.outputs.new_version }}
channel: agent-nightly
+ build-windows-arm64:
+ uses: ./.github/workflows/template-cli-build-windows-arm64.yml
+ needs: [get-update-version, resolve-ref]
+ secrets: inherit
+ with:
+ ref: ${{ needs.resolve-ref.outputs.ref }}
+ new_version: ${{ needs.get-update-version.outputs.new_version }}
+ channel: agent-nightly
+
build-linux-aarch64:
uses: ./.github/workflows/template-cli-build-linux-aarch64.yml
needs: [get-update-version, resolve-ref]
@@ -63,8 +72,25 @@ jobs:
channel: agent-nightly
sync-manifest:
- needs: [get-update-version, build-linux-x64, build-macos, build-windows-x64, build-linux-aarch64]
+ needs:
+ [
+ get-update-version,
+ build-linux-x64,
+ build-macos,
+ build-windows-x64,
+ build-windows-arm64,
+ build-linux-aarch64,
+ ]
runs-on: ubuntu-22.04
+ # build-windows-arm64 is here for its outputs, not as a gate -- see the
+ # ARM_SHA branch below. The four legs the published CLI updates from stay
+ # required.
+ if: >-
+ !cancelled()
+ && needs.build-linux-x64.result == 'success'
+ && needs.build-macos.result == 'success'
+ && needs.build-windows-x64.result == 'success'
+ && needs.build-linux-aarch64.result == 'success'
steps:
- uses: actions/checkout@v4
@@ -100,6 +126,21 @@ jobs:
}
}
MANIFEST
+
+ # Appended rather than inlined above: empty when the ARM64 leg failed
+ # or was skipped, and an entry with a blank url is one the CLI finds
+ # and then fails to download.
+ ARM_SHA="${{ needs.build-windows-arm64.outputs.SHA256 }}"
+ if [ -n "$ARM_SHA" ]; then
+ jq --arg url "https://delta.jan.ai/agent-nightly/${{ needs.build-windows-arm64.outputs.FILE_NAME }}" \
+ --arg sha "$ARM_SHA" \
+ '.platforms["windows-aarch64"] = {url: $url, sha256: $sha}' \
+ manifest.json > /tmp/m.json
+ mv /tmp/m.json manifest.json
+ else
+ echo "::warning::no ARM64 CLI build this run -- publishing manifest.json without windows-aarch64"
+ fi
+
cat manifest.json
- name: Upload manifest to S3
diff --git a/.github/workflows/template-cli-build-windows-arm64.yml b/.github/workflows/template-cli-build-windows-arm64.yml
new file mode 100644
index 000000000..a2dca3f3f
--- /dev/null
+++ b/.github/workflows/template-cli-build-windows-arm64.yml
@@ -0,0 +1,106 @@
+# Builds the Jan Agent CLI binary for Windows aarch64.
+# Runs natively on GitHub's windows-11-arm runner; no Tauri bundler, no
+# frontend, and none of the CUDA/Vulkan/signtool provisioning the desktop
+# ARM64 build needs -- this is a plain `cargo build` against the host triple.
+name: cli-build-windows-arm64
+on:
+ workflow_call:
+ inputs:
+ ref:
+ required: true
+ type: string
+ default: refs/heads/dev
+ new_version:
+ required: true
+ type: string
+ default: ''
+ channel:
+ required: true
+ type: string
+ default: agent-nightly
+ secrets:
+ DELTA_AWS_S3_BUCKET_NAME:
+ required: false
+ DELTA_AWS_ACCESS_KEY_ID:
+ required: false
+ DELTA_AWS_SECRET_ACCESS_KEY:
+ required: false
+ DELTA_AWS_REGION:
+ required: false
+ # Baked into the binary at compile time via option_env!; without it the
+ # released CLI falls back to the local-dev key and its signed requests
+ # are rejected.
+ JAN_SIGNING_KEY:
+ required: false
+ outputs:
+ FILE_NAME:
+ value: ${{ jobs.build-windows-arm64.outputs.FILE_NAME }}
+ SHA256:
+ value: ${{ jobs.build-windows-arm64.outputs.SHA256 }}
+
+jobs:
+ build-windows-arm64:
+ runs-on: windows-11-arm
+ outputs:
+ FILE_NAME: ${{ steps.package.outputs.FILE_NAME }}
+ SHA256: ${{ steps.package.outputs.SHA256 }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
+ with:
+ ref: ${{ inputs.ref }}
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
+ with:
+ toolchain: stable
+
+ - name: Cache cargo
+ uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
+
+ - name: Build CLI binary
+ env:
+ JAN_CLI_UPDATE_CHANNEL: ${{ inputs.channel }}
+ JAN_CLI_BUILD_VERSION: ${{ inputs.new_version }}
+ JAN_SIGNING_KEY: ${{ secrets.JAN_SIGNING_KEY }}
+ run: |
+ cd src-tauri
+ cargo build --no-default-features --features cli --bin jan --release
+
+ # The binary must be ARM64: the runner can run x64 under emulation, so a
+ # toolchain mix-up would produce a working but emulated build that this
+ # job would otherwise publish under the aarch64 key.
+ - name: Verify the binary is ARM64
+ shell: pwsh
+ run: |
+ $exe = 'src-tauri/target/release/jan.exe'
+ if (-not (Test-Path $exe)) { throw "$exe missing" }
+ # PE machine type sits at the COFF header, 4 bytes past the offset
+ # stored at 0x3C. 0xAA64 is ARM64.
+ $b = [IO.File]::ReadAllBytes((Resolve-Path $exe))
+ $machine = [BitConverter]::ToUInt16($b, [BitConverter]::ToInt32($b, 0x3C) + 4)
+ Write-Host ("machine: 0x{0:X4}" -f $machine)
+ if ($machine -ne 0xAA64) { throw ("not ARM64: 0x{0:X4}" -f $machine) }
+
+ - name: Package zip
+ id: package
+ shell: bash
+ run: |
+ VERSION="${{ inputs.new_version }}"
+ FILE_NAME="jan-agent-windows-aarch64-$VERSION.zip"
+ # Compress-Archive rather than the x64 template's 7z: it ships with
+ # PowerShell, so it needs nothing from the runner image.
+ powershell -Command "Compress-Archive -Path './src-tauri/target/release/jan.exe' -DestinationPath '$FILE_NAME' -Force"
+ echo "FILE_NAME=$FILE_NAME" >> "$GITHUB_OUTPUT"
+ echo "SHA256=$(sha256sum "$FILE_NAME" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
+
+ - name: Upload to S3
+ shell: bash
+ run: |
+ aws s3 cp "./${{ steps.package.outputs.FILE_NAME }}" \
+ "s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/${{ inputs.channel }}/${{ steps.package.outputs.FILE_NAME }}"
+ env:
+ AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
+ AWS_DEFAULT_REGION: ${{ secrets.DELTA_AWS_REGION }}
+ AWS_EC2_METADATA_DISABLED: 'true'
diff --git a/scripts/install-jan-agent.ps1 b/scripts/install-jan-agent.ps1
index 7b09a7a78..78cd498f0 100644
--- a/scripts/install-jan-agent.ps1
+++ b/scripts/install-jan-agent.ps1
@@ -33,7 +33,10 @@ $ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$BinaryName = 'jan.exe'
-$PlatformKey = 'windows-x86_64'
+# ARCHITEW6432 is what an emulated process sees; PROCESSOR_ARCHITECTURE alone
+# would report AMD64 for an x64 PowerShell on an ARM64 machine.
+$NativeArch = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }
+$PlatformKey = if ($NativeArch -eq 'ARM64') { 'windows-aarch64' } else { 'windows-x86_64' }
if (-not $Dir) {
if ($env:JAN_INSTALL_DIR) {
@@ -46,9 +49,6 @@ if (-not $Dir) {
if ([Environment]::Is64BitOperatingSystem -eq $false) {
throw 'no published build for 32-bit Windows; use -Source'
}
-if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') {
- Write-Warning 'no native ARM64 build is published; the x86_64 build runs under emulation'
-}
# PowerShell 5.1 defaults to TLS 1.0, which delta.jan.ai rejects.
if ([Net.ServicePointManager]::SecurityProtocol -notmatch 'Tls12') {
diff --git a/src-tauri/src/core/cli/updater.rs b/src-tauri/src/core/cli/updater.rs
index 1eb6d62c2..c618e15be 100644
--- a/src-tauri/src/core/cli/updater.rs
+++ b/src-tauri/src/core/cli/updater.rs
@@ -79,6 +79,7 @@ fn platform_key() -> Option<&'static str> {
("linux", "aarch64") => Some("linux-aarch64"),
("macos", _) => Some("darwin-universal"),
("windows", "x86_64") => Some("windows-x86_64"),
+ ("windows", "aarch64") => Some("windows-aarch64"),
_ => None,
}
}