🚀 Update build and release workflows
This commit is contained in:
119
.github/workflows/build-release.yml
vendored
119
.github/workflows/build-release.yml
vendored
@@ -50,19 +50,19 @@ jobs:
|
||||
MATRIX='{"include":[]}'
|
||||
|
||||
if [[ "$PLATFORMS" == *"windows"* ]]; then
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"windows-latest","os":"windows","arch":"amd64","output_name":"voidraft-windows-amd64.exe","id":"windows"}]')
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"windows-latest","os":"windows","arch":"amd64","platform_dir":"windows","id":"windows"}]')
|
||||
fi
|
||||
|
||||
if [[ "$PLATFORMS" == *"linux"* ]]; then
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"ubuntu-22.04","os":"linux","arch":"amd64","output_name":"voidraft-linux-amd64","id":"linux"}]')
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"ubuntu-22.04","os":"linux","arch":"amd64","platform_dir":"linux","id":"linux"}]')
|
||||
fi
|
||||
|
||||
if [[ "$PLATFORMS" == *"macos-intel"* ]]; then
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"macos-latest","os":"darwin","arch":"amd64","output_name":"voidraft-darwin-amd64","id":"macos-intel"}]')
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"macos-latest","os":"darwin","arch":"amd64","platform_dir":"darwin","id":"macos-intel"}]')
|
||||
fi
|
||||
|
||||
if [[ "$PLATFORMS" == *"macos-arm"* ]]; then
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"macos-latest","os":"darwin","arch":"arm64","output_name":"voidraft-darwin-arm64","id":"macos-arm"}]')
|
||||
MATRIX=$(echo "$MATRIX" | jq -c '.include += [{"platform":"macos-latest","os":"darwin","arch":"arm64","platform_dir":"darwin","id":"macos-arm"}]')
|
||||
fi
|
||||
|
||||
# 使用 -c 确保输出紧凑的单行 JSON,符合 GitHub Actions 输出格式
|
||||
@@ -116,17 +116,41 @@ jobs:
|
||||
if: matrix.os == 'linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
# Wails 3 + 项目特定依赖
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
pkg-config \
|
||||
libgtk-3-dev \
|
||||
libwebkit2gtk-4.0-dev \
|
||||
pkg-config
|
||||
libwebkit2gtk-4.1-dev \
|
||||
libayatana-appindicator3-dev \
|
||||
librsvg2-dev \
|
||||
patchelf \
|
||||
libx11-dev \
|
||||
rpm \
|
||||
fuse \
|
||||
file
|
||||
|
||||
# 依赖说明:
|
||||
# - build-essential: C/C++ 编译工具链
|
||||
# - pkg-config: 包配置工具
|
||||
# - libgtk-3-dev: GTK3 GUI 框架
|
||||
# - libwebkit2gtk-4.1-dev: WebKit2GTK 4.1 (Wails 3 要求)
|
||||
# - libayatana-appindicator3-dev: 系统托盘支持
|
||||
# - librsvg2-dev: SVG 图标支持
|
||||
# - patchelf: 修改 ELF 二进制文件
|
||||
# - libx11-dev: X11 库 (热键服务依赖)
|
||||
# - rpm: RPM 打包工具
|
||||
# - fuse: AppImage 运行依赖
|
||||
# - file: 文件类型检测工具
|
||||
|
||||
# Windows 平台依赖(GitHub Actions 的 Windows runner 已包含 MinGW)
|
||||
# Windows 平台依赖
|
||||
- name: 设置 Windows 构建环境
|
||||
if: matrix.os == 'windows'
|
||||
run: |
|
||||
echo "Windows runner 已包含构建工具"
|
||||
# 安装 NSIS (用于创建安装程序)
|
||||
choco install nsis -y
|
||||
# 将 NSIS 添加到 PATH
|
||||
echo "C:\Program Files (x86)\NSIS" >> $GITHUB_PATH
|
||||
shell: bash
|
||||
|
||||
# macOS 平台依赖
|
||||
@@ -150,52 +174,67 @@ jobs:
|
||||
working-directory: frontend
|
||||
run: npm run build
|
||||
|
||||
# 构建 Wails 应用
|
||||
- name: 构建 Wails 应用
|
||||
# 使用 Wails Task 构建和打包应用
|
||||
- name: 构建和打包 Wails 应用
|
||||
run: |
|
||||
wails3 build -platform ${{ matrix.os }}/${{ matrix.arch }}
|
||||
# 使用 wails3 task 执行平台特定的打包任务
|
||||
cd build/${{ matrix.platform_dir }}
|
||||
wails3 task package PRODUCTION=true ARCH=${{ matrix.arch }}
|
||||
env:
|
||||
CGO_ENABLED: 1
|
||||
APP_NAME: voidraft
|
||||
BIN_DIR: ../../bin
|
||||
ROOT_DIR: ../..
|
||||
shell: bash
|
||||
|
||||
# 查找构建产物
|
||||
- name: 查找构建产物
|
||||
id: find_binary
|
||||
shell: bash
|
||||
# 整理构建产物
|
||||
- name: 整理构建产物
|
||||
id: organize_artifacts
|
||||
run: |
|
||||
echo "=== 构建产物列表 ==="
|
||||
ls -lhR bin/ || echo "bin 目录不存在"
|
||||
|
||||
# 创建输出目录
|
||||
mkdir -p artifacts
|
||||
|
||||
# 根据平台复制产物
|
||||
if [ "${{ matrix.os }}" = "windows" ]; then
|
||||
BINARY=$(find build/bin -name "*.exe" -type f | head -n 1)
|
||||
echo "Windows 平台:查找 NSIS 安装程序"
|
||||
find . -name "*.exe" -type f
|
||||
cp bin/*.exe artifacts/ 2>/dev/null || echo "未找到 .exe 文件"
|
||||
|
||||
elif [ "${{ matrix.os }}" = "linux" ]; then
|
||||
echo "Linux 平台:查找 AppImage, deb, rpm, archlinux 包"
|
||||
find bin -type f
|
||||
cp bin/*.AppImage artifacts/ 2>/dev/null || echo "未找到 AppImage"
|
||||
cp bin/*.deb artifacts/ 2>/dev/null || echo "未找到 deb"
|
||||
cp bin/*.rpm artifacts/ 2>/dev/null || echo "未找到 rpm"
|
||||
cp bin/*.pkg.tar.zst artifacts/ 2>/dev/null || echo "未找到 archlinux 包"
|
||||
|
||||
elif [ "${{ matrix.os }}" = "darwin" ]; then
|
||||
# macOS 可能生成 .app 包或二进制文件
|
||||
BINARY=$(find build/bin -type f \( -name "*.app" -o ! -name ".*" \) | head -n 1)
|
||||
else
|
||||
BINARY=$(find build/bin -type f ! -name ".*" | head -n 1)
|
||||
fi
|
||||
echo "binary_path=$BINARY" >> $GITHUB_OUTPUT
|
||||
echo "找到的二进制文件: $BINARY"
|
||||
|
||||
# 重命名构建产物
|
||||
- name: 重命名构建产物
|
||||
shell: bash
|
||||
run: |
|
||||
BINARY_PATH="${{ steps.find_binary.outputs.binary_path }}"
|
||||
if [ -n "$BINARY_PATH" ]; then
|
||||
# 对于 macOS .app 包,打包为 zip
|
||||
if [[ "$BINARY_PATH" == *.app ]]; then
|
||||
cd "$(dirname "$BINARY_PATH")"
|
||||
zip -r "${{ matrix.output_name }}.zip" "$(basename "$BINARY_PATH")"
|
||||
echo "ARTIFACT_PATH=$(pwd)/${{ matrix.output_name }}.zip" >> $GITHUB_ENV
|
||||
echo "macOS 平台:查找 .app bundle"
|
||||
find bin -name "*.app" -type d
|
||||
# macOS: .app bundle,打包成 zip
|
||||
if [ -d "bin/voidraft.app" ]; then
|
||||
cd bin
|
||||
zip -r ../artifacts/voidraft-darwin-${{ matrix.arch }}.app.zip voidraft.app
|
||||
cd ..
|
||||
else
|
||||
cp "$BINARY_PATH" "${{ matrix.output_name }}"
|
||||
echo "ARTIFACT_PATH=$(pwd)/${{ matrix.output_name }}" >> $GITHUB_ENV
|
||||
echo "未找到 .app bundle"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "=== 最终产物 ==="
|
||||
ls -lh artifacts/ || echo "artifacts 目录为空"
|
||||
shell: bash
|
||||
|
||||
# 上传构建产物到 Artifacts
|
||||
- name: 上传构建产物
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.output_name }}
|
||||
path: ${{ env.ARTIFACT_PATH }}
|
||||
if-no-files-found: error
|
||||
name: voidraft-${{ matrix.id }}
|
||||
path: artifacts/*
|
||||
if-no-files-found: warn
|
||||
|
||||
# 创建 GitHub Release 并上传所有构建产物
|
||||
release:
|
||||
|
||||
Reference in New Issue
Block a user