mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-11-01 03:12:37 +08:00
132 lines
5.8 KiB
YAML
132 lines
5.8 KiB
YAML
name: CLI native builds and npm packages
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
tags-ignore: ["cli-v*"]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- runner: macos-14
|
|
target: darwin-arm64
|
|
arch: arm64
|
|
- runner: macos-15-intel
|
|
target: darwin-x64
|
|
arch: x86_64
|
|
- runner: ubuntu-22.04
|
|
target: linux-x64
|
|
arch: x86_64
|
|
- runner: ubuntu-22.04-arm
|
|
target: linux-arm64
|
|
arch: arm64
|
|
- runner: windows-2022
|
|
target: win32-x64
|
|
arch: x64
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 120
|
|
env:
|
|
XMAKE_VERSION: "3.1.1"
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
submodules: recursive
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 22
|
|
package-manager-cache: false
|
|
# A runner label can receive compiler/SDK updates without changing its name.
|
|
- name: Set cache environment
|
|
id: runner-image
|
|
shell: bash
|
|
run: |
|
|
printf 'version=%s\n' "${ImageVersion:?Missing GitHub runner image version}" >> "$GITHUB_OUTPUT"
|
|
# Keep installed packages separate from the project's build/config state.
|
|
printf 'XMAKE_PKG_INSTALLDIR=%s/crossdesk-cli-packages\n' "$RUNNER_TEMP" >> "$GITHUB_ENV"
|
|
- uses: xmake-io/github-action-setup-xmake@v1
|
|
with:
|
|
xmake-version: ${{ env.XMAKE_VERSION }}
|
|
actions-cache-folder: ${{ runner.temp }}/crossdesk-cli-xmake-toolchain
|
|
actions-cache-key: cli-${{ matrix.runner }}-${{ matrix.target }}-image${{ steps.runner-image.outputs.version }}-xmake${{ env.XMAKE_VERSION }}
|
|
- name: Configure MSVC (x64)
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
|
|
$vsPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
|
if ($LASTEXITCODE -ne 0 -or -not $vsPath) {
|
|
throw 'Visual Studio C++ build tools were not found'
|
|
}
|
|
$previousEnv = @{}
|
|
Get-ChildItem Env: | ForEach-Object { $previousEnv[$_.Name] = $_.Value }
|
|
& (Join-Path $vsPath 'Common7\Tools\Launch-VsDevShell.ps1') -Arch amd64 -HostArch amd64 -SkipAutomaticLocation
|
|
Get-Command cl.exe -ErrorAction Stop | Out-Null
|
|
# Persist the compiler, SDK and PATH settings for subsequent steps.
|
|
Get-ChildItem Env: | Where-Object { $previousEnv[$_.Name] -cne $_.Value } | ForEach-Object {
|
|
"$($_.Name)=$($_.Value)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
}
|
|
- name: Linux build tools
|
|
if: runner.os == 'Linux'
|
|
shell: bash
|
|
run: |
|
|
missing=()
|
|
for package in build-essential pkg-config autoconf automake libtool nasm yasm zlib1g-dev python3-pip; do
|
|
if [[ "$(dpkg-query -W -f='${Status}' "$package" 2>/dev/null || true)" != "install ok installed" ]]; then
|
|
missing+=("$package")
|
|
fi
|
|
done
|
|
if (( ${#missing[@]} )); then
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends "${missing[@]}"
|
|
fi
|
|
- name: Prepare pinned dependency
|
|
run: sh apps/cli/scripts/prepare-deps.sh
|
|
# Exact matches only: changed local recipes/patches must not reuse old libraries.
|
|
# Source, README and npm metadata edits do not change this key.
|
|
- name: Restore native dependencies
|
|
id: native-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: ${{ env.XMAKE_PKG_INSTALLDIR }}
|
|
key: cli-deps-v1-${{ matrix.runner }}-${{ matrix.target }}-image${{ steps.runner-image.outputs.version }}-xmake${{ env.XMAKE_VERSION }}-${{ hashFiles('xmake.lua', 'apps/cli/xmake.lua', 'apps/desktop/xmake/options.lua', 'deps/thirdparty/openssl/**', 'deps/submodules/minirtc/xmake.lua', 'deps/submodules/minirtc/thirdparty/**', 'deps/patches/**', '.github/workflows/build-cli.yml') }}
|
|
- name: Configure macOS
|
|
if: runner.os == 'macOS'
|
|
run: xmake f -y -p macosx -a ${{ matrix.arch }} -m release --target_minver=13.0 --CROSSDESK_BUILD_DESKTOP=n --CROSSDESK_BUILD_CLI=y --USE_CUDA=n
|
|
- name: Configure Linux
|
|
if: runner.os == 'Linux'
|
|
run: xmake f -y -p linux -a ${{ matrix.arch }} -m release --CROSSDESK_BUILD_DESKTOP=n --CROSSDESK_BUILD_CLI=y --USE_CUDA=n
|
|
- name: Configure Windows
|
|
if: runner.os == 'Windows'
|
|
run: xmake f -y -p windows -a ${{ matrix.arch }} -m release --CROSSDESK_BUILD_DESKTOP=n --CROSSDESK_BUILD_CLI=y --USE_CUDA=n
|
|
# xmake f installs required packages. Save before compiling or packaging the CLI,
|
|
# so failures in those later steps do not discard successfully installed dependencies.
|
|
- name: Save native dependencies
|
|
if: steps.native-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v5
|
|
with:
|
|
path: ${{ env.XMAKE_PKG_INSTALLDIR }}
|
|
key: ${{ steps.native-cache.outputs.cache-primary-key }}
|
|
- name: Build
|
|
run: xmake build crossdesk-cli
|
|
- name: Sign macOS CLI
|
|
if: runner.os == 'macOS'
|
|
run: codesign --force --sign - build/macosx/${{ matrix.arch }}/release/crossdesk-cli
|
|
- name: Report native environment
|
|
run: xmake run crossdesk-cli doctor --json
|
|
- name: Package native program and npm entry
|
|
run: npm --prefix apps/cli run pack:npm
|
|
- uses: actions/upload-artifact@v6
|
|
with:
|
|
name: npm-${{ matrix.target }}
|
|
path: build/npm/*.tgz
|
|
if-no-files-found: error
|