Files
ogame-vue-ts/.github/workflows/build.yml
coolxitech fef38d40ee feat(electron): 引入 Electron 桌面应用支持
- 添加 Electron 主进程入口文件 main.ts
- 配置 Vite 插件以支持 Electron 构建
- 更新 package.json 添加 Electron 相关依赖和构建脚本
- 修改路由历史模式为 HashHistory 以兼容 Electron 环境
- 调整构建流程分离服务端与客户端打包任务
- 新增 Electron 应用图标和基础窗口配置
- 集成开发服务器 URL 加载逻辑与静态文件加载 fallback
- 更新构建日期并设置主进程入口点字段
- 添加 Windows 安装包构建目标及输出目录配置
- 优化依赖预构建列表以提升启动性能
- 分离 release 资源收集路径并增强跨平台兼容性
- 升级部分工具链版本以获得最新功能支持
2025-12-14 12:06:56 +08:00

117 lines
3.1 KiB
YAML

name: 构建多平台可执行程序
on:
push:
branches:
- main
jobs:
# 任务 1: 专门构建 Go 服务端程序
build-server:
name: Build Go Server for ${{ matrix.goos }}-${{ matrix.goarch }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: windows
goarch: amd64
executable: ogame-server-windows-amd64.exe
- goos: linux
goarch: amd64
executable: ogame-server-linux-amd64
- goos: linux
goarch: arm64
executable: ogame-server-linux-arm64
steps:
- uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
- name: Compile Server
run: |
if [ ! -f go.mod ]; then go mod init ogame-app; fi
go mod tidy
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o ${{ matrix.executable }} main.go
- name: Upload Server Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.executable }}
path: ${{ matrix.executable }}
# 任务 2: 专门构建 Electron 客户端
build-electron:
name: Build Electron for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
platform: win
- os: macos-latest
platform: mac
- os: ubuntu-latest
platform: linux
steps:
- uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Build Vue Frontend
run: bun run build
- name: Build Electron App
run: bun run build:electron --${{ matrix.platform }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Electron Artifact
uses: actions/upload-artifact@v4
with:
name: electron-${{ matrix.platform }}
# 仅上传 pkg 目录下的安装包产物
path: |
pkg/*.exe
pkg/*.dmg
pkg/*.AppImage
pkg/*.zip
# 任务 3: 汇总发布
release:
needs: [build-server, build-electron]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./release-assets
- name: Get version
id: get_version
run: |
# 假设版本号仍在 package.json 中
echo "VERSION=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
shell: bash
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
name: Release ${{ steps.get_version.outputs.VERSION }}
# 收集所有子目录下的文件
files: ./release-assets/**/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}