style: 优化按钮间距样式 #16
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: Build and Release | |
| # 当推送 tag 时触发(如 v1.0.0, v1.2.3) | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| # 多平台并行构建 | |
| build: | |
| strategy: | |
| # 即使某个平台构建失败,也继续构建其他平台 | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Windows 构建 | |
| - os: windows-latest | |
| platform: win | |
| build_cmd: npm run dist:win | |
| artifact_name: release-windows | |
| artifact_path: | | |
| release/*.exe | |
| release/*.zip | |
| # macOS 构建 | |
| - os: macos-latest | |
| platform: mac | |
| build_cmd: npm run dist:mac | |
| artifact_name: release-macos | |
| artifact_path: | | |
| release/*.dmg | |
| # Linux 构建 | |
| - os: ubuntu-latest | |
| platform: linux | |
| build_cmd: npm run dist:linux | |
| artifact_name: release-linux | |
| artifact_path: | | |
| release/*.AppImage | |
| release/*.deb | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| # 1. 检出代码 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. 安装 Node.js | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| # 3. 安装依赖 | |
| - name: Install dependencies | |
| run: npm ci | |
| # 4. 打包 Electron 应用 | |
| - name: Build Electron app for ${{ matrix.platform }} | |
| run: ${{ matrix.build_cmd }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # 5. 上传构建产物 | |
| - name: Upload ${{ matrix.platform }} artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: ${{ matrix.artifact_path }} | |
| retention-days: 5 | |
| # 创建 Release 并上传所有平台的文件 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract release notes | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Extracting release notes for version $VERSION" | |
| awk "/^## \[$VERSION\]/{flag=1;next} /^## /{flag=0} flag" CHANGELOG.md > RELEASE_NOTE.md | |
| cat RELEASE_NOTE.md | |
| # 下载所有平台的构建产物 | |
| - name: Download Windows artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-windows | |
| path: ./release | |
| continue-on-error: true | |
| - name: Download macOS artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-macos | |
| path: ./release | |
| continue-on-error: true | |
| - name: Download Linux artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-linux | |
| path: ./release | |
| continue-on-error: true | |
| # 列出所有下载的文件(调试用) | |
| - name: List release files | |
| run: | | |
| echo "=== Release files ===" | |
| ls -la ./release || echo "No release directory" | |
| # 创建 Release 并上传文件 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| release/*.exe | |
| release/*.zip | |
| release/*.dmg | |
| release/*.AppImage | |
| release/*.deb | |
| body_path: RELEASE_NOTE.md | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |