Build and Release #122
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to build from (e.g., v1.0.0)' | |
| required: false | |
| type: string | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| env: | |
| npm_config_msvs_version: '2022' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [windows-2022, ubuntu-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| ref: ${{ github.event.inputs.tag || github.ref }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Install Linux build dependencies | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libx11-dev libxtst-dev | |
| - name: Build native overlay addon | |
| run: pnpm rebuild-native | |
| - name: Fetch GCPad libraries | |
| run: node ./scripts/fetch-gcpad.cjs | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Overlay DLL (Windows only) | |
| if: runner.os == 'Windows' | |
| run: | | |
| powershell -ExecutionPolicy Bypass -File overlay-dll/setup-minhook.ps1 | |
| cmake -B overlay-dll/build -S overlay-dll -G "Visual Studio 17 2022" -A x64 | |
| cmake --build overlay-dll/build --config Release | |
| env: | |
| VCPKG_ROOT: ${{ github.workspace }}/vcpkg | |
| - name: Verify Overlay DLL output (Windows only) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| if (!(Test-Path "overlay-dll/build/Release/uc-overlay-x64.dll")) { | |
| throw "Expected overlay DLL at overlay-dll/build/Release/uc-overlay-x64.dll" | |
| } | |
| - name: Verify GCPad Linux libraries (Linux only) | |
| if: runner.os == 'Linux' | |
| run: | | |
| if [ ! -f "gcpad-lib/libgcpad.so" ]; then | |
| echo "ERROR: libgcpad.so not found in gcpad-lib/" | |
| exit 1 | |
| fi | |
| if [ ! -f "gcpad-lib/libSDL2-2.0.so.0" ]; then | |
| echo "ERROR: libSDL2-2.0.so.0 not found in gcpad-lib/" | |
| exit 1 | |
| fi | |
| echo "GCPad Linux libraries verified" | |
| - name: Build application | |
| run: pnpm -s build && pnpm exec electron-builder --publish=never | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| USE_HARD_LINKS: false | |
| CSC_IDENTITY_AUTO_DISCOVERY: false | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-${{ matrix.os }} | |
| path: | | |
| dist-packaged/*.exe | |
| dist-packaged/*.blockmap | |
| dist-packaged/*.zip | |
| dist-packaged/latest*.yml | |
| dist-packaged/*.AppImage | |
| dist-packaged/*.tar.gz | |
| release: | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/') || (github.event.inputs.tag != '') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist-packaged | |
| - name: Create or Update Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ github.event.inputs.tag || github.ref_name }} | |
| allowUpdates: true | |
| replacesArtifacts: true | |
| artifacts: | | |
| dist-packaged/**/*.exe | |
| dist-packaged/**/*.blockmap | |
| dist-packaged/**/*.zip | |
| dist-packaged/**/latest*.yml | |
| dist-packaged/**/*.AppImage | |
| dist-packaged/**/*.tar.gz | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |