name: Build desktop # Builds the unsigned Linux x64 and ARM64 executables with their .deb and # .rpm packages, and the Windows x64 and ARM64 executables, from one commit, # named as the release service targets # (docs/plans/release-service.md). Release calls it for every release, Test # builds with test-build so every push to dev has downloadable builds that # never update themselves. # # These jobs run repository code (cargo, build.rs, scripts), so they have no # environment, no secrets, and no id-token. Each uploads one artifact through # .github/release/upload, which writes its SHA256SUMS, and reports that # manifest's digest as an output; the jobs that sign or publish the artifact # check it (.github/release/verify-artifacts.sh). on: workflow_call: inputs: sha: required: true type: string version: required: true type: string channel: description: The release channel this build is published on, compiled in as HEX_BUILD_CHANNEL (src/updater.rs); empty for test builds type: string default: "" test-build: type: boolean default: false artifact-prefix: type: string default: build retention-days: type: number default: 0 outputs: linux-x64-digest: value: ${{ jobs.linux-x64.outputs.digest }} linux-arm64-digest: value: ${{ jobs.linux-arm64.outputs.digest }} windows-x64-digest: value: ${{ jobs.windows-x64.outputs.digest }} windows-arm64-digest: value: ${{ jobs.windows-arm64.outputs.digest }} permissions: contents: read jobs: # Both architectures build natively in a Debian 12 container # (scripts/build-linux-release.sh), so the executable and packages need only # glibc 2.36 (Debian 12, Ubuntu 23.04, Fedora 37, and newer; issue #1026). # ARM64 decodes on the GPU through Vulkan like x64 (Mesa's drivers on ARM # boards and Asahi), falling back to the CPU without a Vulkan device. linux-x64: name: Linux x86_64 runs-on: ubuntu-24.04 timeout-minutes: 90 env: HEX_VERSION: ${{ inputs.version }} HEX_BUILD_CHANNEL: ${{ inputs.channel }} HEX_LINUX_ARCH: x86_64 HEX_LINUX_LABEL: x64 NFPM_ARCHIVE: nfpm_2.48.0_Linux_x86_64.tar.gz NFPM_SHA256: 6d7f9a28b2f397934403950fcbba83f598b08d02edbe79a0815b3b4897341750 outputs: digest: ${{ steps.upload.outputs.digest }} steps: &linux-steps - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ inputs.sha }} persist-credentials: false - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: toolchain: stable - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 if: inputs.test-build with: key: test-build-${{ hashFiles('packaging/linux/build.Dockerfile') }} cache-on-failure: true - name: Install nfpm # The build dependencies live in the build image # (packaging/linux/build.Dockerfile). run: | curl -fsSL --retry 3 -o "$RUNNER_TEMP/nfpm.tar.gz" \ "https://github.com/goreleaser/nfpm/releases/download/v2.48.0/$NFPM_ARCHIVE" echo "$NFPM_SHA256 $RUNNER_TEMP/nfpm.tar.gz" | sha256sum -c - mkdir -p "$RUNNER_TEMP/bin" tar -xzf "$RUNNER_TEMP/nfpm.tar.gz" -C "$RUNNER_TEMP/bin" nfpm echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH" - name: Build env: HEX_RELEASE_DIST: ${{ runner.temp }}/dist CARGO_BUILD_JOBS: 4 OPENSSL_NO_VENDOR: 1 CC: clang CXX: clang++ run: | executable=$(scripts/build-linux-release.sh) scripts/package-linux.sh "$executable" "$HEX_VERSION" "$HEX_LINUX_LABEL" "$HEX_RELEASE_DIST" - name: Check the glibc floor shell: bash run: | bash .github/release/check-glibc-floor.sh "$RUNNER_TEMP/dist/hex-$HEX_VERSION-linux-$HEX_LINUX_LABEL" \ | tee -a "$GITHUB_STEP_SUMMARY" - name: Install the .deb here and on Debian 12, and the .rpm on Fedora run: | base="$RUNNER_TEMP/dist/hex-$HEX_VERSION-linux-$HEX_LINUX_LABEL" dpkg-deb --info "$base.deb" sudo apt-get update sudo apt-get install -y "$base.deb" test "$(/usr/bin/hex --version | awk 'NF { value=$NF } END { print value }')" = "$HEX_VERSION" dpkg-query -S /usr/bin/hex /usr/lib/systemd/user/hex.service /usr/share/applications/anomaly.hex.desktop /usr/share/icons/hicolor/256x256/apps/anomaly.hex.png sudo apt-get remove -y hex docker run --rm -v "$RUNNER_TEMP/dist:/dist:ro" -e HEX_VERSION -e HEX_LINUX_LABEL fedora:42 sh -euc ' dnf install -y -q "/dist/hex-$HEX_VERSION-linux-$HEX_LINUX_LABEL.rpm" test "$(hex --version | awk "NF { value=\$NF } END { print value }")" = "$HEX_VERSION" rpm -qf /usr/bin/hex /usr/lib/systemd/user/hex.service /usr/share/applications/anomaly.hex.desktop /usr/share/icons/hicolor/256x256/apps/anomaly.hex.png' # The oldest supported distribution: the packaged and bare # executables start and answer model-free commands. docker run --rm -v "$RUNNER_TEMP/dist:/dist:ro" -e HEX_VERSION -e HEX_LINUX_LABEL debian:12 sh -euc ' apt-get update -qq apt-get install -y -qq "/dist/hex-$HEX_VERSION-linux-$HEX_LINUX_LABEL.deb" > /dev/null for hex in /usr/bin/hex "/dist/hex-$HEX_VERSION-linux-$HEX_LINUX_LABEL"; do test "$("$hex" --version | awk "NF { value=\$NF } END { print value }")" = "$HEX_VERSION" "$hex" history > /dev/null status=0; "$hex" status > /dev/null 2>&1 || status=$? test "$status" = 3 done' - name: Check the x86_64 CPU floor if: env.HEX_LINUX_ARCH == 'x86_64' run: | mapfile -t ggml < <(find target/release/build -path '*transcribe-cpp-sys*/out/lib*' -name 'libggml*.a' -type f) [ "${#ggml[@]}" -gt 0 ] || { echo "::error::no ggml archives under target/release/build" >&2; exit 1; } bash .github/release/check-x86-baseline.sh "$RUNNER_TEMP/dist/hex-$HEX_VERSION-linux-$HEX_LINUX_LABEL" \ "${ggml[@]}" - id: upload uses: ./.github/release/upload with: name: ${{ inputs.artifact-prefix }}-linux-${{ env.HEX_LINUX_ARCH }} path: ${{ runner.temp }}/dist retention-days: ${{ inputs.retention-days }} linux-arm64: name: Linux aarch64 runs-on: ubuntu-24.04-arm timeout-minutes: 90 env: HEX_VERSION: ${{ inputs.version }} HEX_BUILD_CHANNEL: ${{ inputs.channel }} HEX_LINUX_ARCH: aarch64 HEX_LINUX_LABEL: arm64 NFPM_ARCHIVE: nfpm_2.48.0_Linux_arm64.tar.gz NFPM_SHA256: a9a75213763783b7669719e505474c748c5ad7dc66591a195619deb50f85c2f4 outputs: digest: ${{ steps.upload.outputs.digest }} steps: *linux-steps windows-x64: name: Windows x86_64 runs-on: windows-latest timeout-minutes: 120 env: HEX_VERSION: ${{ inputs.version }} HEX_BUILD_CHANNEL: ${{ inputs.channel }} HEX_WINDOWS_ARCH: x86_64 HEX_WINDOWS_LABEL: x64 DUMPBIN_HOST: Hostx64\\x64 # Compiled into src/updater.rs: test builds never self-update. HEX_TEST_BUILD: ${{ inputs.test-build && '1' || '' }} outputs: digest: ${{ steps.upload.outputs.digest }} steps: &windows-steps # In a subdirectory: the Vulkan SDK installs into the workspace, and a # release build needs a clean tree. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ inputs.sha }} path: source persist-credentials: false - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable with: toolchain: stable targets: ${{ env.HEX_WINDOWS_ARCH }}-pc-windows-msvc # target/ holds C++ objects (transcribe.cpp via clang-cl) built against # one MSVC STL and CRT; an object cached from a newer toolset fails to link # against an older one (__std_replace_2, LNK2019), so the key names it. - name: Find the MSVC toolset if: inputs.test-build id: msvc shell: pwsh run: | $vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe" if (-not (Test-Path -LiteralPath $vswhere)) { throw "vswhere.exe was not found" } $installation = & $vswhere -latest -products * ` -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath # The ARM64 images install the ARM64 tools, not the x86_64 ones. if (-not $installation) { $installation = & $vswhere -latest -products * -property installationPath } $default = "$installation\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" if (-not $installation -or -not (Test-Path -LiteralPath $default)) { throw "no MSVC tools version under $installation" } $version = (Get-Content -LiteralPath $default).Trim() Add-Content $env:GITHUB_OUTPUT "version=$version" Write-Host "MSVC toolset $version" - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 if: inputs.test-build with: workspaces: source -> target key: test-build-msvc-${{ steps.msvc.outputs.version }} cache-on-failure: true - name: Install the Vulkan SDK if: env.HEX_WINDOWS_ARCH == 'x86_64' uses: humbletim/install-vulkan-sdk@30ba978f977e81b72d091fc8888feb1fb26f9aff # v1.2 with: version: 1.4.309.0 cache: true - name: Install SPIRV-Headers for the Vulkan backend if: env.HEX_WINDOWS_ARCH == 'x86_64' shell: pwsh run: | vcpkg install spirv-headers:x64-windows if ($LASTEXITCODE -ne 0) { throw "vcpkg install spirv-headers failed" } $prefix = "$env:VCPKG_INSTALLATION_ROOT/installed/x64-windows" -replace '\\','/' $combined = if ($env:CMAKE_PREFIX_PATH) { "$prefix;$env:CMAKE_PREFIX_PATH" } else { $prefix } Add-Content $env:GITHUB_ENV "CMAKE_PREFIX_PATH=$combined" - name: Configure clang-cl for ARM64 if: env.HEX_WINDOWS_ARCH == 'aarch64' shell: pwsh run: | @( "CMAKE_C_COMPILER=clang-cl", "CMAKE_CXX_COMPILER=clang-cl", "CMAKE_C_COMPILER_TARGET=aarch64-pc-windows-msvc", "CMAKE_CXX_COMPILER_TARGET=aarch64-pc-windows-msvc", "CL=/EHsc" ) | Out-File -FilePath $env:GITHUB_ENV -Append - name: Build shell: bash run: | # Git Bash would rewrite CL=/EHsc into a path that clang-cl reads as # a second source file. export MSYS2_ENV_CONV_EXCL=CL export HEX_RELEASE_DIST="$(cygpath -u "$RUNNER_TEMP")/dist" source/scripts/build-windows.sh - name: Check the x86_64 CPU floor if: env.HEX_WINDOWS_ARCH == 'x86_64' shell: bash run: | mapfile -t ggml < <(find source/target/x86_64-pc-windows-msvc/release/build -path '*transcribe-cpp-sys*/out/lib*' -name 'ggml*.lib' -type f) [ "${#ggml[@]}" -gt 0 ] || { echo "::error::no ggml archives under source/target/x86_64-pc-windows-msvc/release/build" >&2; exit 1; } OBJDUMP="$(cygpath -u "$PROGRAMFILES")/LLVM/bin/llvm-objdump.exe" \ bash source/.github/release/check-x86-baseline.sh \ "$(cygpath -u "$RUNNER_TEMP")/dist/hex-$HEX_VERSION-windows-$HEX_WINDOWS_LABEL.exe" \ "${ggml[@]}" - name: Check the executables need no Visual C++ Redistributable or Vulkan loader, hex.exe is a GUI program and hex.com a console one shell: pwsh run: | $dumpbin = Get-ChildItem "${env:ProgramFiles}\Microsoft Visual Studio" -Recurse -Filter dumpbin.exe -ErrorAction SilentlyContinue | Where-Object { $_.FullName -match $env:DUMPBIN_HOST } | Select-Object -First 1 if (-not $dumpbin) { throw "dumpbin.exe was not found" } $imports = & $dumpbin.FullName /dependents "$env:RUNNER_TEMP/dist/hex-$env:HEX_VERSION-windows-$env:HEX_WINDOWS_LABEL.exe" $imports $redist = $imports | Select-String -Pattern 'VCRUNTIME|MSVCP|vcomp' if ($redist) { throw "hex.exe imports Visual C++ runtime DLLs: $redist" } # The Vulkan loader comes with the graphics driver: imported at load # time, a missing or Vulkan 1.0 one stops Hex before main (#1240). $static = ($imports -join "`n") -split 'delay load dependencies' | Select-Object -First 1 if ($static -match 'vulkan-1\.dll') { throw "hex.exe imports vulkan-1.dll at load time instead of delay-loading it" } # A GUI program, so opening Hex shows no console window (#850). $headers = & $dumpbin.FullName /headers "$env:RUNNER_TEMP/dist/hex-$env:HEX_VERSION-windows-$env:HEX_WINDOWS_LABEL.exe" if (-not ($headers | Select-String -SimpleMatch 'subsystem (Windows GUI)')) { throw "hex.exe is not a Windows GUI program" } # hex.com, its console entry point, is a console program that shells wait for. $console = "$env:RUNNER_TEMP/dist/hex-$env:HEX_VERSION-windows-$env:HEX_WINDOWS_LABEL.com" $consoleImports = & $dumpbin.FullName /dependents $console if ($consoleImports | Select-String -Pattern 'VCRUNTIME|MSVCP|vcomp') { throw "hex.com imports Visual C++ runtime DLLs" } $consoleHeaders = & $dumpbin.FullName /headers $console if (-not ($consoleHeaders | Select-String -SimpleMatch 'subsystem (Windows CUI)')) { throw "hex.com is not a console program" } - id: upload uses: ./source/.github/release/upload with: name: ${{ inputs.artifact-prefix }}-windows-${{ env.HEX_WINDOWS_ARCH }} path: ${{ runner.temp }}/dist retention-days: ${{ inputs.retention-days }} windows-arm64: name: Windows aarch64 runs-on: windows-11-arm timeout-minutes: 120 env: HEX_VERSION: ${{ inputs.version }} HEX_BUILD_CHANNEL: ${{ inputs.channel }} HEX_WINDOWS_ARCH: aarch64 HEX_WINDOWS_LABEL: arm64 DUMPBIN_HOST: Hostarm64\\arm64 HEX_TEST_BUILD: ${{ inputs.test-build && '1' || '' }} outputs: digest: ${{ steps.upload.outputs.digest }} steps: *windows-steps