Build & Release #12
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| RETOC_VERSION: "v0.1.5" | |
| UASSETTOOL_VERSION: "v1.2.0" | |
| jobs: | |
| # Windows build ─ | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| - name: Build with PyInstaller | |
| run: pyinstaller build.spec --noconfirm --clean | |
| - name: Zip release folder | |
| run: Compress-Archive -Path dist\RivalsSwapper\* -DestinationPath dist\RivalsSwapper-Windows.zip | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: RivalsSwapper-Windows | |
| path: dist/RivalsSwapper-Windows.zip | |
| # Linux build | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-tk | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| # Committed tools/ contains Windows binaries. | |
| # Replace retoc and UAssetTool with their Linux equivalents. | |
| - name: Download retoc (Linux) | |
| run: | | |
| mkdir -p _retoc_tmp | |
| curl -sL "https://github.com/trumank/retoc/releases/download/${{ env.RETOC_VERSION }}/retoc_cli-x86_64-unknown-linux-gnu.tar.xz" | tar -xJ -C _retoc_tmp | |
| find _retoc_tmp -type f -name "retoc" -exec cp {} tools/retoc/retoc \; | |
| chmod +x tools/retoc/retoc | |
| rm -rf _retoc_tmp | |
| - name: Download UAssetTool (Linux) | |
| run: | | |
| curl -sL "https://github.com/XzantGaming/UAssetToolRivals/releases/download/${{ env.UASSETTOOL_VERSION }}/UAssetTool-linux-x64.tar.gz" | tar -xz -C tools/uassettool | |
| chmod +x tools/uassettool/UAssetTool | |
| - name: Build with PyInstaller | |
| run: pyinstaller build.spec --noconfirm --clean | |
| - name: Archive release folder | |
| run: tar -czf dist/RivalsSwapper-Linux.tar.gz -C dist RivalsSwapper | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: RivalsSwapper-Linux | |
| path: dist/RivalsSwapper-Linux.tar.gz | |
| # Create GitHub Release | |
| release: | |
| needs: [build-windows, build-linux] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download Windows artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: RivalsSwapper-Windows | |
| path: artifacts | |
| - name: Download Linux artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: RivalsSwapper-Linux | |
| path: artifacts | |
| - name: Determine tag | |
| id: tag | |
| run: | | |
| VERSION=$(python -c 'import sys; sys.path.insert(0, "src"); from _version import __version__; print(__version__)') | |
| echo "TAG_NAME=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.TAG_NAME }} | |
| name: Rivals Swapper ${{ steps.tag.outputs.TAG_NAME }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| files: | | |
| artifacts/RivalsSwapper-Windows.zip | |
| artifacts/RivalsSwapper-Linux.tar.gz |