name: Extension builder on: push: branches: - master tags: - "*" pull_request: branches: - master jobs: build: strategy: matrix: os: [ubuntu-20.04] include: - os: ubuntu-20.04 cc: clang-10 cxx: clang++-10 fail-fast: false name: ${{ matrix.os }} - ${{ matrix.cc }} runs-on: ${{ matrix.os }} env: PROJECT: 'a2sqcache' SDKS: 'css' MMSOURCE_VERSION: '1.12' SOURCEMOD_VERSION: '1.12' CACHE_PATH: ${{ github.workspace }}/cache steps: - name: Concatenate SDK Names shell: bash run: | # Paranoia SDKS_VAR="${{env.SDKS}}" # This will be used in our cache key echo "SDKS_KEY=${SDKS_VAR//[[:blank:]]/}" >> $GITHUB_ENV - name: Linux dependencies if: startsWith(runner.os, 'Linux') run: | sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install -y --no-install-recommends \ gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \ libc6-dev libc6-dev-i386 linux-libc-dev \ linux-libc-dev:i386 lib32z1-dev ${{ matrix.cc }} - uses: actions/setup-python@v4 name: Setup Python 3.9 with: python-version: 3.9 - name: Install Python dependencies run: | python -m pip install --upgrade pip setuptools wheel - uses: actions/checkout@v3 name: Repository checkout with: fetch-depth: 0 path: extension - uses: actions/cache@v3 name: Cache dependencies if: ${{ ! startsWith(github.ref, 'refs/tags/') }} env: cache-name: cache with: path: ${{ env.CACHE_PATH }} key: ${{ runner.os }}-build-${{ env.cache-name }}-sm${{ env.SOURCEMOD_VERSION }}-mmsource${{ env.MMSOURCE_VERSION }}-${{ env.SDKS_KEY }} - shell: bash name: Install dependencies run: | mkdir -p "${{ env.CACHE_PATH }}" cd "${{ env.CACHE_PATH }}" shallow_checkout () { # Param 1 is origin # Param 2 is branch # Param 3 is name if [ ! -d "$3" ]; then git clone "$1" --depth 1 --branch "$2" "$3" fi cd "$3" git remote set-url origin "$1" git fetch --depth 1 origin "$2" git checkout --force --recurse-submodules FETCH_HEAD git submodule init git submodule update --depth 1 cd .. } # We are aware of what we are doing! git config --global advice.detachedHead false # Verify github cache, and see if we don't have the sdks already cloned and update them for sdk in ${{ env.SDKS }} do shallow_checkout "https://github.com/alliedmodders/hl2sdk" "${sdk}" "hl2sdk-${sdk}" done shallow_checkout "https://github.com/alliedmodders/ambuild" "master" "ambuild" shallow_checkout "https://github.com/alliedmodders/sourcemod" "${{env.SOURCEMOD_VERSION}}-dev" "sourcemod" shallow_checkout "https://github.com/alliedmodders/metamod-source/" "${{env.MMSOURCE_VERSION}}-dev" "metamod-source" shallow_checkout "https://github.com/srcdslab/sm-ext-common" "master" "sourcemod/public/sm-ext-common" # But maybe others aren't (also probably unnecessary because git actions but paranoia) git config --global advice.detachedHead true - name: Setup AMBuild shell: bash run: | cd "${{ env.CACHE_PATH }}" python -m pip install ./ambuild - name: Select clang compiler if: startsWith(runner.os, 'Linux') run: | echo "CC=${{ matrix.cc }}" >> $GITHUB_ENV echo "CXX=${{ matrix.cxx }}" >> $GITHUB_ENV ${{ matrix.cc }} --version ${{ matrix.cxx }} --version - name: Build shell: bash working-directory: extension run: | mkdir build cd build python ../configure.py --enable-optimize --sdks="${{ env.SDKS }}" --mms-path="${{ env.CACHE_PATH }}/metamod-source" --hl2sdk-root="${{ env.CACHE_PATH }}" --sm-path="${{ env.CACHE_PATH }}/sourcemod" --targets=x86,x86_64 ambuild - name: Upload a Build Artifact uses: actions/upload-artifact@v4 with: # Artifact name name: ${{ runner.os }} # optional, default is artifact # A file, directory or wildcard pattern that describes what to upload path: extension/build/package # The desired behavior if no files are found using the provided path. if-no-files-found: error # Duration after which artifact will expire in days. 0 means using default retention. retention-days: 14 release: name: Release if: startsWith(github.ref, 'refs/tags/') needs: build runs-on: ubuntu-latest steps: - name: Download artifacts uses: actions/download-artifact@v4 - name: Package run: | version=`echo $GITHUB_REF | sed "s/refs\/tags\///"` if [ -d "./Linux/" ]; then cd ./Linux/ tar -czf ../${{ github.event.repository.name }}-${version}-linux.tar.gz -T <(\ls -1) fi if [ -d "./macOS/" ]; then cd ./macOS/ tar -czf ../${{ github.event.repository.name }}-${version}-mac.tar.gz -T <(\ls -1) fi if [ -d "./Windows/" ]; then cd ./Windows/ tar -czf ../${{ github.event.repository.name }}-${version}-windows.tar.gz -T <(\ls -1) fi - name: Release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: '*.tar.gz' tag: ${{ github.ref }} file_glob: true