|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - LICENSE |
| 7 | + - README.md |
| 8 | + |
| 9 | + pull_request: |
| 10 | + paths-ignore: |
| 11 | + - LICENSE |
| 12 | + - README.md |
| 13 | + |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build on ${{ matrix.os_short }} |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + # Compile on Linux & Windows. |
| 24 | + os: |
| 25 | + - ubuntu-20.04 |
| 26 | + - windows-latest |
| 27 | + |
| 28 | + include: |
| 29 | + - os: ubuntu-20.04 |
| 30 | + os_short: linux |
| 31 | + - os: windows-latest |
| 32 | + os_short: win |
| 33 | + steps: |
| 34 | + # Setup Python for AMBuild. |
| 35 | + - name: Setup Python 3.10 |
| 36 | + uses: actions/setup-python@v4 |
| 37 | + with: |
| 38 | + python-version: '3.10' |
| 39 | + |
| 40 | + # Install dependencies |
| 41 | + - name: Install AMBuild |
| 42 | + run: | |
| 43 | + python -m pip install --upgrade pip setuptools wheel |
| 44 | + pip install git+https://github.com/alliedmodders/ambuild |
| 45 | +
|
| 46 | + - name: Install dependencies |
| 47 | + if: runner.os == 'Linux' |
| 48 | + run: | |
| 49 | + sudo dpkg --add-architecture i386 |
| 50 | + sudo apt-get update |
| 51 | + sudo apt-get install -y clang g++-multilib |
| 52 | +
|
| 53 | + - name: Select clang compiler |
| 54 | + if: runner.os == 'Linux' |
| 55 | + run: | |
| 56 | + echo "CC=clang" >> $GITHUB_ENV |
| 57 | + echo "CXX=clang++" >> $GITHUB_ENV |
| 58 | + clang --version |
| 59 | + clang++ --version |
| 60 | +
|
| 61 | + - name: Find Visual C++ compilers and make all environment variables global (W) |
| 62 | + if: runner.os == 'Windows' |
| 63 | + shell: cmd |
| 64 | + run: | |
| 65 | + :: See https://github.com/microsoft/vswhere/wiki/Find-VC |
| 66 | + for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do ( |
| 67 | + call "%%i"\Common7\Tools\vsdevcmd.bat -arch=x64 -host_arch=x64 |
| 68 | + ) |
| 69 | +
|
| 70 | + :: Loop over all environment variables and make them global. |
| 71 | + for /f "delims== tokens=1,2" %%a in ('set') do ( |
| 72 | + echo>>"%GITHUB_ENV%" %%a=%%b |
| 73 | + ) |
| 74 | +
|
| 75 | + # Checkout repos |
| 76 | + - name: Checkout |
| 77 | + uses: actions/checkout@v4 |
| 78 | + with: |
| 79 | + path: project |
| 80 | + |
| 81 | + - name: Checkout hl2sdk-cs2 |
| 82 | + uses: actions/checkout@v4 |
| 83 | + with: |
| 84 | + repository: alliedmodders/hl2sdk |
| 85 | + ref: cs2 |
| 86 | + path: hl2sdk-cs2 |
| 87 | + |
| 88 | + - name: Checkout Metamod:Source |
| 89 | + uses: actions/checkout@v4 |
| 90 | + with: |
| 91 | + repository: alliedmodders/metamod-source |
| 92 | + ref: master |
| 93 | + path: metamod-source |
| 94 | + |
| 95 | + # Build |
| 96 | + - name: Build |
| 97 | + shell: bash |
| 98 | + run: | |
| 99 | + cd project && mkdir build && cd build |
| 100 | + python ../configure.py --enable-optimize --sdks=cs2 --targets=x86_64 |
| 101 | + ambuild |
| 102 | +
|
| 103 | + - name: Upload artifact |
| 104 | + uses: actions/upload-artifact@v3 |
| 105 | + with: |
| 106 | + name: ${{ runner.os }} |
| 107 | + path: project/build/package |
| 108 | + |
| 109 | + release: |
| 110 | + name: Release |
| 111 | + if: startsWith(github.ref, 'refs/tags/') |
| 112 | + needs: build |
| 113 | + runs-on: ubuntu-latest |
| 114 | + |
| 115 | + steps: |
| 116 | + - name: Download artifacts |
| 117 | + uses: actions/download-artifact@v3 |
| 118 | + |
| 119 | + - name: Package |
| 120 | + run: | |
| 121 | + 7z a -mx9 linux.zip ./Linux/* |
| 122 | + 7z a -mx9 windows.zip ./Windows/* |
| 123 | + - name: Release |
| 124 | + uses: svenstaro/upload-release-action@v2 |
| 125 | + with: |
| 126 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + file: '*.zip' |
| 128 | + tag: ${{ github.ref }} |
| 129 | + file_glob: true |
0 commit comments