chore(ci): update Windows build workflow and add artifact renaming step #48
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 Release Multi-platform | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| release: | |
| types: [created] | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| # --- Linux --- | |
| - os: ubuntu-24.04 | |
| arch: x86_64 | |
| asset_suffix: linux-x86_64 | |
| - os: ubuntu-24.04-arm | |
| arch: arm64 | |
| asset_suffix: linux-arm64 | |
| # --- MacOS --- | |
| - os: macos-14 # arm64 runner | |
| arch: arm64 | |
| asset_suffix: macos-arm64 | |
| - os: macos-13 # x86_64 runner | |
| arch: x86_64 | |
| asset_suffix: macos-x86_64 | |
| # --- Windows --- | |
| - os: windows-latest | |
| arch: x86_64 | |
| asset_suffix: windows-x86_64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| # ==== Linux (native runners, no Docker) ==== | |
| - name: Build on Linux (native) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| chmod +x build.sh | |
| ./build.sh auto | |
| mv dist/tricode dist/tricode-${{ matrix.asset_suffix }} | |
| # ==== MacOS ==== | |
| - name: Build on macOS | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| chmod +x build.sh | |
| ./build.sh auto | |
| mv dist/tricode dist/tricode-${{ matrix.asset_suffix }} | |
| # ==== Windows ==== | |
| - name: Build on Windows | |
| if: startsWith(matrix.os, 'windows') | |
| shell: cmd | |
| run: | | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| .\build.bat auto | |
| - name: Rename Windows artifact | |
| if: startsWith(matrix.os, 'windows') | |
| shell: pwsh | |
| run: | | |
| $src = "dist/tricode.exe" | |
| $dst = "dist/tricode-${{ matrix.asset_suffix }}.exe" | |
| if (!(Test-Path $src)) { Write-Error "Source not found: $src"; exit 1 } | |
| if (Test-Path $dst) { Remove-Item $dst -Force } | |
| try { | |
| Move-Item -LiteralPath $src -Destination $dst -Force -ErrorAction Stop | |
| } catch { | |
| Copy-Item -LiteralPath $src -Destination $dst -Force | |
| Remove-Item -LiteralPath $src -Force | |
| } | |
| - name: Upload artifact (Windows) | |
| if: startsWith(matrix.os, 'windows') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tricode-${{ matrix.asset_suffix }} | |
| path: | | |
| dist/tricode-${{ matrix.asset_suffix }}.exe | |
| - name: Upload artifact (Unix) | |
| if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tricode-${{ matrix.asset_suffix }} | |
| path: | | |
| dist/tricode-${{ matrix.asset_suffix }} | |
| - name: Upload to release (Windows) | |
| if: github.event_name == 'release' && startsWith(matrix.os, 'windows') | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ github.event.release.tag_name }} dist/tricode-${{ matrix.asset_suffix }}.exe --clobber | |
| - name: Upload to release (Unix) | |
| if: github.event_name == 'release' && (startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ github.event.release.tag_name }} dist/tricode-${{ matrix.asset_suffix }} --clobber |