Cross-Platform Build and Release #20
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: Cross-Platform Build and Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_version: | |
| description: "Enter the release version (e.g., v1.0.0)" | |
| required: true | |
| type: string | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| os: [windows-2022, ubuntu-latest, macos-latest] | |
| python-version: ['3.13'] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Update build version (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| $version = "${{ github.event.inputs.release_version }}" | |
| "VERSION = `"$version`"" | Out-File -FilePath "version.py" -Encoding utf8 | |
| - name: Update build version (macOS/Linux) | |
| if: runner.os != 'Windows' | |
| run: | | |
| echo "VERSION = \"${{ github.event.inputs.release_version }}\"" > version.py | |
| - name: Install PyInstaller and dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Build executable | |
| run: pyinstaller main.spec | |
| - name: Archive the release package (Windows) | |
| if: ${{ matrix.os == 'windows-2022' }} | |
| run: | | |
| mv dist/PyPSADiag/PyPSADiag.exe dist/PyPSADiag/PyPSADiag-windows.exe | |
| cd dist | |
| tar -a -c -f ../PyPSADiag-Windows.zip PyPSADiag | |
| - name: Archive the release package (macOS) | |
| if: ${{ matrix.os == 'macos-latest' }} | |
| run: | | |
| cd dist | |
| zip -r ../PyPSADiag-macOS.zip PyPSADiag.app | |
| - name: Archive the release package (Linux) | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| mv dist/PyPSADiag/PyPSADiag dist/PyPSADiag/PyPSADiag-linux | |
| chmod +x dist/PyPSADiag/PyPSADiag-linux || true | |
| cd dist | |
| tar -czf ../PyPSADiag-Linux.tar.gz PyPSADiag | |
| - name: Upload release artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.os }}-build | |
| path: | | |
| PyPSADiag-Windows.zip | |
| PyPSADiag-macOS.zip | |
| PyPSADiag-Linux.tar.gz | |
| version.py | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.event.inputs.release_version }} | |
| release_name: Release ${{ github.event.inputs.release_version }} | |
| draft: false | |
| prerelease: false | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create GitHub Release and Upload Assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.release_version }} | |
| name: Release ${{ github.event.inputs.release_version }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| artifacts/**/PyPSADiag-Windows.zip | |
| artifacts/**/PyPSADiag-Linux.tar.gz | |
| artifacts/**/PyPSADiag-macOS.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |