Skip to content

!248 merge dev into main #115

!248 merge dev into main

!248 merge dev into main #115

Workflow file for this run

name: Build Executables
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build on ${{ matrix.item.os }}
runs-on: ${{ matrix.item.os }}
strategy:
matrix:
item:
# Linux - 使用静态 Python
- os: ubuntu-22.04
arch: x64
platform: linux
package_lock_path: .github/workflows/package-lock.json
use_static_python: true # 添加此标志
# Windows
- os: windows-latest
arch: x64
platform: win32
package_lock_path: .github/workflows/package-lock.json
use_static_python: false
# macOS - ARM (Apple Silicon)
- os: macos-14
arch: arm64
platform: darwin
pyinstaller_arch: arm64
package_lock_path: .github/workflows/package-lock.json
use_static_python: false
# macOS - x86 (Intel)
- os: macos-13
arch: x86_64
platform: darwin
pyinstaller_arch: x86_64
package_lock_path: .github/workflows/package-lock.json
use_static_python: false
# 将 node-version 移到每个 item 中
include:
- node-version: 18.x
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Copy package-lock.json
run: |
echo "Copying ${{ matrix.item.package_lock_path }} to package-lock.json"
cp "${{ matrix.item.package_lock_path }}" package-lock.json
echo "File copied successfully"
shell: bash
# 设置静态 Python 环境(仅适用于 Ubuntu)
- name: Set up static Python (Ubuntu only)
if: ${{ matrix.item.use_static_python }}
run: |
# 下载预编译的静态Python
PYTHON_VERSION=3.10.17
BUILD_TAG=20250529
wget https://github.com/astral-sh/python-build-standalone/releases/download/${BUILD_TAG}/cpython-${PYTHON_VERSION}+${BUILD_TAG}-x86_64-unknown-linux-gnu-install_only.tar.gz
# 解压到 /opt/python-static
sudo mkdir -p /opt/python-static
sudo tar -xzf cpython-${PYTHON_VERSION}+${BUILD_TAG}-x86_64-unknown-linux-gnu-install_only.tar.gz -C /opt/python-static --strip-components=1
# 设置环境变量
echo "/opt/python-static/bin" >> $GITHUB_PATH
echo "PYTHON_STATIC=/opt/python-static" >> $GITHUB_ENV
# 验证安装
/opt/python-static/bin/python3 --version
/opt/python-static/bin/python3 -c "import sys; print(sys.executable)"
export PATH=/opt/python-static/bin/:$PATH
python3 --version
# 设置标准 Python 环境(非 Ubuntu 平台)
- name: Set up Python
if: ${{ !matrix.item.use_static_python }}
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: |
npm install --no-package-lock
- name: PyInstaller build
run: |
npm run release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ArkAnalyzer-HapRay-${{ matrix.item.platform }}-${{ matrix.item.arch }}
path: ArkAnalyzer-HapRay-*.zip