chore: bump version to v1.5.4 with release notes #132
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| - name: Update version from tag | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Updating version to: $VERSION" | |
| sed -i '' "s/const AppVersion = \"v[^\"]*\"/const AppVersion = \"v$VERSION\"/" version_service.go | |
| echo "Updated version_service.go:" | |
| grep "AppVersion" version_service.go | |
| - 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 | |
| - name: Update version from tag | |
| shell: pwsh | |
| run: | | |
| $VERSION = "${{ github.ref_name }}".TrimStart('v') | |
| Write-Host "Updating version to: $VERSION" | |
| # Update version_service.go | |
| $content = Get-Content version_service.go -Raw | |
| $content = $content -replace 'const AppVersion = "v[^"]*"', "const AppVersion = `"v$VERSION`"" | |
| Set-Content version_service.go $content | |
| Write-Host "Updated version_service.go:" | |
| Select-String "AppVersion" version_service.go | |
| # Update build/windows/info.json | |
| $json = Get-Content build/windows/info.json -Raw | ConvertFrom-Json | |
| $json.fixed.file_version = $VERSION | |
| $json.info.'0000'.ProductVersion = $VERSION | |
| $json | ConvertTo-Json -Depth 10 | Set-Content build/windows/info.json | |
| Write-Host "Updated build/windows/info.json:" | |
| Get-Content build/windows/info.json | |
| - 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: Build Updater | |
| run: | | |
| go install github.com/akavel/rsrc@latest | |
| rsrc -manifest cmd/updater/updater.exe.manifest -o cmd/updater/rsrc_windows_amd64.syso | |
| $env:GOOS = "windows" | |
| $env:GOARCH = "amd64" | |
| $env:CGO_ENABLED = "0" | |
| go build -ldflags="-w -s -H windowsgui" -o bin/updater.exe ./cmd/updater | |
| Remove-Item cmd/updater/*.syso -ErrorAction SilentlyContinue | |
| - name: Generate SHA256 Checksums | |
| run: | | |
| Push-Location bin | |
| Get-FileHash -Algorithm SHA256 CodeSwitch.exe | ForEach-Object { "$($_.Hash.ToLower()) CodeSwitch.exe" } | Out-File -Encoding ascii CodeSwitch.exe.sha256 | |
| Get-FileHash -Algorithm SHA256 updater.exe | ForEach-Object { "$($_.Hash.ToLower()) updater.exe" } | Out-File -Encoding ascii updater.exe.sha256 | |
| Write-Host "SHA256 checksums generated:" | |
| Get-Content *.sha256 | |
| Pop-Location | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-amd64 | |
| path: | | |
| bin/CodeSwitch-amd64-installer.exe | |
| bin/CodeSwitch.exe | |
| bin/CodeSwitch.exe.sha256 | |
| bin/updater.exe | |
| bin/updater.exe.sha256 | |
| build-linux: | |
| name: Build Linux | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Update version from tag | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Updating version to: $VERSION" | |
| sed -i "s/const AppVersion = \"v[^\"]*\"/const AppVersion = \"v$VERSION\"/" version_service.go | |
| echo "Updated version_service.go:" | |
| grep "AppVersion" version_service.go | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Install Linux Build Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| pkg-config \ | |
| libgtk-3-dev \ | |
| libwebkit2gtk-4.1-dev | |
| - 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 Linux Binary | |
| run: wails3 task linux:build | |
| env: | |
| PRODUCTION: "true" | |
| - name: Generate Desktop File | |
| run: wails3 task linux:generate:dotdesktop | |
| - name: Create AppImage | |
| run: wails3 task linux:create:appimage | |
| - name: Rename AppImage | |
| run: | | |
| cd bin | |
| echo "Files in bin/:" | |
| ls -la | |
| # linuxdeploy creates AppImage with lowercase name and arch suffix | |
| for f in *-x86_64.AppImage *-aarch64.AppImage; do | |
| if [ -f "$f" ]; then | |
| mv "$f" CodeSwitch.AppImage | |
| echo "Renamed $f -> CodeSwitch.AppImage" | |
| break | |
| fi | |
| done | |
| ls -la CodeSwitch.AppImage | |
| - name: Set nfpm script permissions | |
| run: | | |
| chmod +x build/linux/nfpm/scripts/postinstall.sh | |
| chmod +x build/linux/nfpm/scripts/postremove.sh | |
| - name: Update nfpm version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| sed -i "s/^version:.*/version: \"$VERSION\"/" build/linux/nfpm/nfpm.yaml | |
| echo "Updated nfpm version to: $VERSION" | |
| - name: Create DEB Package | |
| run: wails3 task linux:create:deb | |
| - name: Create RPM Package | |
| run: wails3 task linux:create:rpm | |
| - name: Generate SHA256 Checksums | |
| run: | | |
| cd bin | |
| sha256sum CodeSwitch.AppImage > CodeSwitch.AppImage.sha256 | |
| for f in codeswitch_*.deb; do [ -f "$f" ] && sha256sum "$f" > "${f}.sha256"; done | |
| for f in codeswitch-*.rpm; do [ -f "$f" ] && sha256sum "$f" > "${f}.sha256"; done | |
| echo "SHA256 checksums:" | |
| cat *.sha256 | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-amd64 | |
| path: | | |
| bin/CodeSwitch.AppImage | |
| bin/CodeSwitch.AppImage.sha256 | |
| bin/codeswitch_*.deb | |
| bin/codeswitch_*.deb.sha256 | |
| bin/codeswitch-*.rpm | |
| bin/codeswitch-*.rpm.sha256 | |
| create-release: | |
| name: Create Release | |
| needs: [build-macos, build-windows, build-linux] | |
| 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 | |
| # macOS | |
| cp artifacts/macos-arm64/codeswitch-macos-arm64.zip release-assets/ | |
| cp artifacts/macos-amd64/codeswitch-macos-amd64.zip release-assets/ | |
| # Windows | |
| cp artifacts/windows-amd64/CodeSwitch-amd64-installer.exe release-assets/ | |
| cp artifacts/windows-amd64/CodeSwitch.exe release-assets/ | |
| cp artifacts/windows-amd64/CodeSwitch.exe.sha256 release-assets/ | |
| cp artifacts/windows-amd64/updater.exe release-assets/ | |
| cp artifacts/windows-amd64/updater.exe.sha256 release-assets/ | |
| # Linux | |
| cp artifacts/linux-amd64/CodeSwitch.AppImage release-assets/ | |
| cp artifacts/linux-amd64/CodeSwitch.AppImage.sha256 release-assets/ | |
| cp artifacts/linux-amd64/codeswitch_*.deb release-assets/ 2>/dev/null || true | |
| cp artifacts/linux-amd64/codeswitch_*.deb.sha256 release-assets/ 2>/dev/null || true | |
| cp artifacts/linux-amd64/codeswitch-*.rpm release-assets/ 2>/dev/null || true | |
| cp artifacts/linux-amd64/codeswitch-*.rpm.sha256 release-assets/ 2>/dev/null || true | |
| ls -lh release-assets/ | |
| - name: Generate release body | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Generating release body for v$VERSION" | |
| # 提取当前版本的更新内容(从标题到下一个版本标题之前) | |
| awk "/^# Code Switch v$VERSION/,/^# Code Switch v[0-9]/" RELEASE_NOTES.md | head -n -1 > /tmp/version_notes.md | |
| # 如果没找到版本说明,使用默认内容 | |
| if [ ! -s /tmp/version_notes.md ]; then | |
| echo "## 更新亮点" > /tmp/version_notes.md | |
| echo "- 请查看提交历史了解详细更新" >> /tmp/version_notes.md | |
| fi | |
| # 组合完整的 release body | |
| cat /tmp/version_notes.md > /tmp/release_body.md | |
| cat >> /tmp/release_body.md << 'EOF' | |
| --- | |
| ## 下载说明 | |
| | 平台 | 文件 | 说明 | | |
| |------|------|------| | |
| | **Windows (首次)** | `CodeSwitch-amd64-installer.exe` | NSIS 安装器 | | |
| | **Windows (便携)** | `CodeSwitch.exe` | 直接运行 | | |
| | **Windows (更新)** | `updater.exe` | 静默更新辅助 | | |
| | **macOS (ARM)** | `codeswitch-macos-arm64.zip` | Apple Silicon | | |
| | **macOS (Intel)** | `codeswitch-macos-amd64.zip` | Intel 芯片 | | |
| | **Linux (通用)** | `CodeSwitch.AppImage` | 跨发行版便携 | | |
| | **Linux (Debian/Ubuntu)** | `codeswitch_*.deb` | apt 安装 | | |
| | **Linux (RHEL/Fedora)** | `codeswitch-*.rpm` | dnf/yum 安装 | | |
| ## Linux 安装 | |
| ### AppImage (推荐) | |
| ```bash | |
| chmod +x CodeSwitch.AppImage | |
| ./CodeSwitch.AppImage | |
| ``` | |
| 如遇 FUSE 问题:`./CodeSwitch.AppImage --appimage-extract-and-run` | |
| ### Debian/Ubuntu | |
| ```bash | |
| sudo dpkg -i codeswitch_*.deb | |
| sudo apt-get install -f # 安装依赖 | |
| ``` | |
| ### RHEL/Fedora | |
| ```bash | |
| sudo rpm -i codeswitch-*.rpm | |
| # 或 | |
| sudo dnf install codeswitch-*.rpm | |
| ``` | |
| ## 文件校验 | |
| 所有平台均提供 SHA256 校验文件(`.sha256`),下载后可验证完整性: | |
| ```bash | |
| # Linux/macOS | |
| sha256sum -c CodeSwitch.AppImage.sha256 | |
| # Windows PowerShell | |
| Get-FileHash CodeSwitch.exe | Format-List | |
| ``` | |
| EOF | |
| echo "Generated release body:" | |
| cat /tmp/release_body.md | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: release-assets/* | |
| body_path: /tmp/release_body.md | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |