Skip to content

fix: 修复 CI 构建错误 #56

fix: 修复 CI 构建错误

fix: 修复 CI 构建错误 #56

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-macos:
name: Build macOS
runs-on: macos-latest
strategy:
matrix:
arch: [arm64, amd64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install Wails
run: go install github.com/wailsapp/wails/v3/cmd/wails3@latest
- name: Install frontend dependencies
run: cd frontend && npm install
- name: Update build assets
run: wails3 task common:update:build-assets
- name: Generate bindings
run: wails3 task common:generate:bindings
- name: Build macOS ${{ matrix.arch }}
run: env ARCH=${{ matrix.arch }} wails3 task package
- name: Find app bundle
id: find-app
run: |
if [ -d "bin/codeswitch.app" ]; then
echo "app_path=bin/codeswitch.app" >> $GITHUB_OUTPUT
elif [ -d "bin/CodeSwitch.app" ]; then
echo "app_path=bin/CodeSwitch.app" >> $GITHUB_OUTPUT
else
echo "App bundle not found" >&2
exit 1
fi
- name: Archive macOS app
run: |
cd bin
ditto -c -k --sequesterRsrc --keepParent "$(basename ${{ steps.find-app.outputs.app_path }})" codeswitch-macos-${{ matrix.arch }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: macos-${{ matrix.arch }}
path: bin/codeswitch-macos-${{ matrix.arch }}.zip
build-windows:
name: Build Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install Wails
run: go install github.com/wailsapp/wails/v3/cmd/wails3@latest
- name: Install frontend dependencies
run: cd frontend && npm install
- name: Install NSIS
run: choco install nsis -y
- name: Update build assets
run: wails3 task common:update:build-assets
- name: Generate bindings
run: wails3 task common:generate:bindings
- name: Build Windows Binary
run: |
$env:ARCH = "amd64"
wails3 task windows:build
env:
PRODUCTION: "true"
- name: Verify Binary
run: |
if (Test-Path "bin\CodeSwitch.exe") {
Write-Host "✓ Binary found: bin\CodeSwitch.exe"
Get-Item "bin\CodeSwitch.exe" | Format-List Name,Length,LastWriteTime
} else {
Write-Host "✗ Binary not found!"
Write-Host "Listing bin directory:"
Get-ChildItem bin -ErrorAction SilentlyContinue
exit 1
}
- name: Create NSIS Installer
run: |
$env:PATH += ";C:\Program Files (x86)\NSIS"
Push-Location build\windows\nsis
wails3 generate webview2bootstrapper
$binaryPath = (Resolve-Path "..\..\..\bin\CodeSwitch.exe").Path
Write-Host "Binary path: $binaryPath"
makensis -DARG_WAILS_AMD64_BINARY="$binaryPath" project.nsi
Pop-Location
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-amd64
path: |
bin/CodeSwitch-amd64-installer.exe
bin/CodeSwitch.exe
create-release:
name: Create Release
needs: [build-macos, build-windows]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure
run: ls -R artifacts
- name: Prepare release assets
run: |
mkdir -p release-assets
cp artifacts/macos-arm64/codeswitch-macos-arm64.zip release-assets/
cp artifacts/macos-amd64/codeswitch-macos-amd64.zip release-assets/
cp artifacts/windows-amd64/CodeSwitch-amd64-installer.exe release-assets/
cp artifacts/windows-amd64/CodeSwitch.exe release-assets/
ls -lh release-assets/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: release-assets/*
body: |
## ✨ 新功能
### 应用自动更新
- 新增自动更新功能,支持一键更新到最新版本
- 每天 8:00 AM 自动检查 GitHub Release 更新
- 网络异常时自动重试 3 次(每次间隔 5 分钟)
- 智能重启机制:下载更新后在下次启动时自动应用
### 设置界面增强
- 设置页面新增"应用更新"板块
- 可查看当前版本、最新版本和上次检查时间
- 支持手动检查更新和立即下载安装
- 提供自动更新开关,状态持久化保存
### UI 改进
- 主页 GitHub 图标显示更新状态徽章
- 🔵 蓝色 "New" 徽章:有新版本可用
- 🟡 黄色进度徽章:正在下载更新
- 🟢 绿色 "Ready" 徽章(脉冲动画):更新已就绪,点击重启
- 完善中英文国际化翻译
## 🔧 技术改进
- 新增 UpdateService 后端服务(400+ 行)
- 版本号管理服务,当前版本 v0.2.6
- 状态持久化到 ~/.code-switch/update-state.json
- 依赖更新:github.com/hashicorp/go-version v1.7.0
## 🐛 Bug 修复
- 修复"立即检查"按钮文字换行问题
- 修复 copyFile 函数重名冲突
## ✨ UI 改进
- 新增主页刷新按钮(一键刷新所有数据)
- 添加刷新按钮旋转动画效果
- 完善按钮样式和禁用状态
## 📦 安装说明
- **Windows**:下载 `CodeSwitch-amd64-installer.exe` 运行安装,或下载 `CodeSwitch.exe` 直接运行
- **macOS (Apple Silicon)**:下载 `codeswitch-macos-arm64.zip`,解压后拖入 Applications 文件夹
- **macOS (Intel)**:下载 `codeswitch-macos-amd64.zip`,解压后拖入 Applications 文件夹
**完整更新日志**: https://github.com/Rogers-F/code-switch-R/compare/v0.2.4...v0.2.6
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}