Skip to content

perf: change windows app build #30

perf: change windows app build

perf: change windows app build #30

Workflow file for this run

# build.yml
name: Auto Build
on:
workflow_dispatch:
push:
branches:
- master
tags:
- "v*" # 只有正式版本标签才触发构建
env:
# Tauri 自动更新签名密钥
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
# macOS 代码签名 (保留原有的 Xcode 参数)
XCODE_APP_TEAM_ID: ${{ secrets.XCODE_APP_TEAM_ID }}
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
BUILD_CERTIFICATE_BASE64: ${{ secrets.CSC_LINK }}
P12_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
# Windows 代码签名
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
jobs:
pre-build:
name: pre-build go client
runs-on: ubuntu-latest
outputs:
go-client-artifacts: ${{ steps.upload-go-client.outputs.artifact-name }}
steps:
- name: Check out git repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
- name: Build Go client for all platforms
run: make build-all
working-directory: go-client
- name: Upload Go client artifacts
id: upload-go-client
uses: actions/upload-artifact@v4
with:
name: go-client-binaries
path: go-client/build/
retention-days: 1
build:
name: build tauri app
runs-on: ${{ matrix.os }}
needs: pre-build
strategy:
fail-fast: false
matrix:
os: [macos-14, windows-latest]
steps:
- name: Check out git repository
uses: actions/checkout@v4
- name: Download Go client artifacts
uses: actions/download-artifact@v4
with:
name: go-client-binaries
path: go-client/build/
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.25"
- name: Install Go client for current platform
run: make install
working-directory: go-client
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "23"
cache: "pnpm"
- name: Install system dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
- name: Install system dependencies (macOS)
if: matrix.os == 'macos-14'
run: |
brew install create-dmg
- name: Install Chocolatey (Windows)
if: matrix.os == 'windows-latest'
run: |
# Install Chocolatey package manager
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Refresh environment variables
refreshenv
# Verify Chocolatey installation
choco --version
- name: Install WiX Toolset via Chocolatey (Windows)
if: matrix.os == 'windows-latest'
run: |
# Install WiX Toolset using Chocolatey
choco install wixtoolset --version=3.14.1 -y
# Refresh environment variables
refreshenv
# Verify installation
candle.exe -?
light.exe -?
# Get WiX installation path
$wixPath = (Get-Command candle.exe).Source | Split-Path -Parent
echo "WiX installed at: $wixPath"
# Set environment variables
echo "WIX=$wixPath" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "WIX_ROOT=$wixPath" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "TAURI_WIX_PATH=$wixPath" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "WIX_BIN_PATH=$wixPath" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "TAURI_SKIP_WIX_DOWNLOAD=true" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Tauri CLI
run: cargo install tauri-cli@^2.0
env:
# Ensure WiX is available for Tauri CLI
WIX: C:\WixTools
WIX_ROOT: C:\WixTools
- name: Install frontend dependencies
run: pnpm install
- name: Build frontend
run: pnpm generate
- name: Verify WiX installation (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "Verifying WiX installation..."
candle.exe -?
light.exe -?
echo "WiX tools are working correctly"
# Get WiX path and create symlink for Tauri
$wixPath = (Get-Command candle.exe).Source | Split-Path -Parent
echo "WiX path: $wixPath"
# Clean any existing Tauri WiX cache
if (Test-Path "C:\Users\runneradmin\AppData\Local\tauri\WixTools314") {
Remove-Item -Recurse -Force "C:\Users\runneradmin\AppData\Local\tauri\WixTools314"
}
# Create symlink for Tauri
New-Item -ItemType Directory -Force -Path "C:\Users\runneradmin\AppData\Local\tauri"
New-Item -ItemType SymbolicLink -Force -Path "C:\Users\runneradmin\AppData\Local\tauri\WixTools314" -Target $wixPath
- name: Build Tauri app (Windows)
if: matrix.os == 'windows-latest'
run: pnpm tauri:build
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
XCODE_APP_TEAM_ID: ${{ secrets.XCODE_APP_TEAM_ID }}
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
BUILD_CERTIFICATE_BASE64: ${{ secrets.CSC_LINK }}
P12_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
# Windows-specific environment variables
WIX: C:\WixTools
WIX_ROOT: C:\WixTools
# Tell Tauri to use our WiX installation
TAURI_WIX_PATH: C:\WixTools
WIX_BIN_PATH: C:\WixTools
# Disable Tauri's automatic WiX download
TAURI_SKIP_WIX_DOWNLOAD: true
WIX_DOWNLOAD_URL: ""
- name: Build Tauri app (macOS)
if: matrix.os == 'macos-14'
run: pnpm tauri:build
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
XCODE_APP_TEAM_ID: ${{ secrets.XCODE_APP_TEAM_ID }}
XCODE_APP_LOADER_EMAIL: ${{ secrets.XCODE_APP_LOADER_EMAIL }}
XCODE_APP_LOADER_PASSWORD: ${{ secrets.XCODE_APP_LOADER_PASSWORD }}
BUILD_CERTIFICATE_BASE64: ${{ secrets.CSC_LINK }}
P12_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
# Windows-specific environment variables
WIX: C:\WixTools
WIX_ROOT: C:\WixTools
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-app
path: |
src-tauri/target/release/bundle/deb/*.deb
src-tauri/target/release/bundle/rpm/*.rpm
src-tauri/target/release/bundle/appimage/*.AppImage
src-tauri/target/release/bundle/dmg/*.dmg
src-tauri/target/release/bundle/macos/*.app
src-tauri/target/release/bundle/nsis/*.exe
src-tauri/target/release/bundle/msi/*.msi
release:
name: create release
runs-on: ubuntu-latest
needs: [pre-build, build]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Check out git repository
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate latest.json
run: |
echo '{
"version": "${{ github.ref_name }}",
"notes": "Release ${{ github.ref_name }}",
"pub_date": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
"platforms": {
"darwin-x86_64": {
"signature": "",
"url": "https://github.com/jumpserver/clients/releases/download/${{ github.ref_name }}/JumpServerClient_${{ github.ref_name }}_x86_64.dmg"
},
"darwin-aarch64": {
"signature": "",
"url": "https://github.com/jumpserver/clients/releases/download/${{ github.ref_name }}/JumpServerClient_${{ github.ref_name }}_aarch64.dmg"
},
"windows-x86_64": {
"signature": "",
"url": "https://github.com/jumpserver/clients/releases/download/${{ github.ref_name }}/JumpServerClient_${{ github.ref_name }}_x64.exe"
},
"windows-x86_64-msi": {
"signature": "",
"url": "https://github.com/jumpserver/clients/releases/download/${{ github.ref_name }}/JumpServerClient_${{ github.ref_name }}_x64.msi"
}
}
}' > latest.json
- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
latest.json
artifacts/macos-14-app/*.dmg
artifacts/macos-14-app/*.app
artifacts/windows-latest-app/*.msi
artifacts/windows-latest-app/*.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}