|
| 1 | +name: Build Artifact |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + push: |
| 6 | + branches: [ main ] |
| 7 | + pull_request: |
| 8 | + branches: [ main ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + platform: [ |
| 15 | + { name: ubuntu-20.04, os: ubuntu-latest, containerImage: 'ubuntu:20.04', cc: clang-8, cxx: clang++-8 }, |
| 16 | + { name: windows-2019, os: windows-2019, cc: msvc }, |
| 17 | + ] |
| 18 | + |
| 19 | + name: ${{ matrix.platform.name }} - ${{ matrix.platform.cc }} |
| 20 | + runs-on: ${{ matrix.platform.os }} |
| 21 | + container: ${{ matrix.platform.containerImage }} |
| 22 | + |
| 23 | + env: |
| 24 | + # We currently only support tf2 |
| 25 | + SDKS: '["tf2"]' |
| 26 | + MMSOURCE_VERSION: '1.12' |
| 27 | + SOURCEMOD_VERSION: '1.12' |
| 28 | + CACHE_PATH: 'cache' |
| 29 | + IN_CONTAINER: ${{ matrix.platform.containerImage != '' }} |
| 30 | + PYTHON_VERSION: '3.8' |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Install Linux container dependencies |
| 34 | + if: startsWith(runner.os, 'Linux') && env.IN_CONTAINER == 'true' |
| 35 | + run: | |
| 36 | + apt-get update |
| 37 | + DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata |
| 38 | + apt-get install -y --no-install-recommends \ |
| 39 | + sudo \ |
| 40 | + git \ |
| 41 | + curl \ |
| 42 | + wget \ |
| 43 | + zstd \ |
| 44 | + build-essential \ |
| 45 | + software-properties-common |
| 46 | +
|
| 47 | + - uses: actions/checkout@v4 |
| 48 | + name: Repository checkout |
| 49 | + with: |
| 50 | + fetch-depth: 0 |
| 51 | + submodules: true |
| 52 | + path: sendvaredit |
| 53 | + |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + name: Sourcemod checkout |
| 56 | + with: |
| 57 | + repository: alliedmodders/sourcemod |
| 58 | + ref: ${{ env.SOURCEMOD_VERSION }}-dev |
| 59 | + submodules: true |
| 60 | + path: ${{ env.CACHE_PATH }}/sourcemod |
| 61 | + |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + name: Metamod-Source checkout |
| 64 | + with: |
| 65 | + repository: alliedmodders/metamod-source |
| 66 | + ref: ${{ env.MMSOURCE_VERSION }}-dev |
| 67 | + path: ${{ env.CACHE_PATH }}/metamod |
| 68 | + |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + name: AMBuild checkout |
| 71 | + with: |
| 72 | + repository: alliedmodders/ambuild |
| 73 | + ref: master |
| 74 | + path: ${{ env.CACHE_PATH }}/ambuild |
| 75 | + |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + name: Checkout TF2 SDK |
| 78 | + with: |
| 79 | + repository: alliedmodders/hl2sdk |
| 80 | + ref: tf2 |
| 81 | + path: ${{ env.CACHE_PATH }}/hl2sdk-tf2 |
| 82 | + |
| 83 | + - name: Setup Python ${{ env.PYTHON_VERSION }} |
| 84 | + uses: actions/setup-python@v5 |
| 85 | + if: ${{ !(startsWith( runner.os, 'Linux' ) && env.IN_CONTAINER == 'true') }} |
| 86 | + with: |
| 87 | + python-version: ${{ env.PYTHON_VERSION }} |
| 88 | + |
| 89 | + # The Setup Python action will fetch from a cached build of Python that is |
| 90 | + # built on newer distros which are not guaranteed to be compatible with older ones. |
| 91 | + # https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#using-setup-python-with-a-self-hosted-runner |
| 92 | + - name: Setup Python ${{ env.PYTHON_VERSION }} (Container) |
| 93 | + if: startsWith( runner.os, 'Linux' ) && env.IN_CONTAINER == 'true' |
| 94 | + shell: bash |
| 95 | + run: | |
| 96 | + sudo apt-get install -y --no-install-recommends python3-pip |
| 97 | + python3 -m pip install packaging |
| 98 | +
|
| 99 | + if python3 -c \ |
| 100 | + 'import sys; from packaging.version import parse; exit(0) if parse(".".join(map(str, sys.version_info[:2]))) < parse("${{ env.PYTHON_VERSION }}") else exit(1)'; \ |
| 101 | + then |
| 102 | +
|
| 103 | + sudo add-apt-repository ppa:deadsnakes/ppa |
| 104 | + sudo apt update |
| 105 | +
|
| 106 | + sudo apt install -y --no-install-recommends \ |
| 107 | + python${{ env.PYTHON_VERSION }} \ |
| 108 | + python${{ env.PYTHON_VERSION }}-dev \ |
| 109 | + python${{ env.PYTHON_VERSION }}-distutils |
| 110 | +
|
| 111 | + curl -sS https://bootstrap.pypa.io/get-pip.py | python${{ env.PYTHON_VERSION }} |
| 112 | + fi |
| 113 | +
|
| 114 | + ln -sf /usr/bin/python${{ env.PYTHON_VERSION }} /usr/local/bin/python |
| 115 | +
|
| 116 | + python --version |
| 117 | + pip --version |
| 118 | +
|
| 119 | + - name: Install Python dependencies |
| 120 | + run: | |
| 121 | + python -m pip install --upgrade pip setuptools wheel |
| 122 | +
|
| 123 | + - name: Setup AMBuild |
| 124 | + working-directory: ${{ env.CACHE_PATH }} |
| 125 | + run: | |
| 126 | + pip install ./ambuild |
| 127 | +
|
| 128 | + - name: Linux dependencies |
| 129 | + if: startsWith(runner.os, 'Linux') |
| 130 | + run: | |
| 131 | + sudo dpkg --add-architecture i386 |
| 132 | + sudo apt-get update |
| 133 | + sudo apt-get install -y --no-install-recommends \ |
| 134 | + gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \ |
| 135 | + libc6-dev libc6-dev-i386 linux-libc-dev \ |
| 136 | + linux-libc-dev:i386 lib32z1-dev ${{ matrix.platform.cc }} |
| 137 | +
|
| 138 | + - name: Select clang compiler |
| 139 | + if: startsWith(runner.os, 'Linux') |
| 140 | + run: | |
| 141 | + echo "CC=${{ matrix.platform.cc }}" >> $GITHUB_ENV |
| 142 | + echo "CXX=${{ matrix.platform.cxx }}" >> $GITHUB_ENV |
| 143 | + ${{ matrix.platform.cc }} --version |
| 144 | + ${{ matrix.platform.cxx }} --version |
| 145 | +
|
| 146 | + - name: Build |
| 147 | + working-directory: sendvaredit |
| 148 | + shell: bash |
| 149 | + run: | |
| 150 | + mkdir build |
| 151 | + cd build |
| 152 | + python ../configure.py --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} \ |
| 153 | + --mms-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/metamod" \ |
| 154 | + --hl2sdk-root="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}" \ |
| 155 | + --sm-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/sourcemod" \ |
| 156 | + --hl2sdk-manifest-path="$GITHUB_WORKSPACE/${{ env.CACHE_PATH }}/sourcemod/hl2sdk-manifests" \ |
| 157 | + --targets=x86 |
| 158 | + ambuild |
| 159 | +
|
| 160 | + - name: Upload artifact |
| 161 | + uses: actions/upload-artifact@v4 |
| 162 | + with: |
| 163 | + name: sendvaredit_${{ runner.os }} |
| 164 | + path: sendvaredit/build/package |
0 commit comments