174 lines
6.7 KiB
YAML
174 lines
6.7 KiB
YAML
name: Extension builder
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
python-version: ['3.14']
|
|
os: [ubuntu-latest, windows-2022]
|
|
include:
|
|
- os: ubuntu-latest
|
|
cc: clang-11
|
|
cxx: clang++-11
|
|
- os: windows-2022
|
|
cc: msvc
|
|
fail-fast: false
|
|
|
|
name: ${{ matrix.os }} - ${{ matrix.cc }}
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
env:
|
|
PROJECT: 'connect'
|
|
SDKS: 'css hl2dm dods tf2'
|
|
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
|
|
|
|
- uses: actions/setup-python@v6
|
|
if: startsWith(matrix.os, 'windows-')
|
|
name: Setup Python ${{ matrix.python-version }}
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- uses: actions/checkout@v6
|
|
name: Repository checkout
|
|
with:
|
|
fetch-depth: 0
|
|
path: extension
|
|
|
|
- uses: actions/cache@v4
|
|
name: Cache dependencies
|
|
env:
|
|
cache-name: connect-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 submodule deinit --all --force
|
|
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"
|
|
# But maybe others aren't (also probably unnecessary because git actions but paranoia)
|
|
git config --global advice.detachedHead true
|
|
|
|
- name: Build
|
|
shell: bash
|
|
working-directory: extension
|
|
run: |
|
|
export PLATFORM="${{ runner.os }}"
|
|
|
|
if [[ $PLATFORM == Linux* ]]; then
|
|
# docker instead of podman because:
|
|
# - we don't need a job to `sudo apt install podman`
|
|
# - `sudo apt install -y python3-pip` didn't work inside podman for me?
|
|
docker run \
|
|
-e PLATFORM="$PLATFORM" \
|
|
-e PROJECT=${{ env.PROJECT }} \
|
|
-e SDKS="${{ env.SDKS }}" \
|
|
-e MMSOURCE_VERSION=${{ env.MMSOURCE_VERSION }} \
|
|
-e SOURCEMOD_VERSION=${{ env.MMSOURCE_SOURCEMOD_VERSION }} \
|
|
-e CACHE_PATH=${{ env.CACHE_PATH }} \
|
|
-e SDKS_KEY=${{ env.SDKS_KEY }} \
|
|
-e CC=${{ matrix.cc }} \
|
|
-e CXX=${{ matrix.cxx }} \
|
|
--mount type=bind,source=${{ env.CACHE_PATH }},target=${{ env.CACHE_PATH }} \
|
|
--mount type=bind,source=$PWD,target=$PWD \
|
|
"registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest" \
|
|
"$PWD/.github/workflows/build.sh"
|
|
|
|
# need to fix the owner because docker root-ed stuff?
|
|
sudo chown -R $USER .
|
|
else
|
|
bash ./.github/workflows/build.sh
|
|
fi
|
|
|
|
FILENAME="$(cat build/includes/filename_versioning.txt)"
|
|
ZIP_FILENAME="${{ env.PROJECT }}-${FILENAME}-${PLATFORM,}.zip"
|
|
|
|
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV
|
|
|
|
# if: github.event_name == 'push' && github.ref == 'refs/heads/action' &&
|
|
- name: Package release - Windows
|
|
if: startsWith(matrix.os, 'windows-')
|
|
working-directory: extension/build/package
|
|
run: |
|
|
Compress-Archive -Path * -Destination ${{ env.ZIP_FILENAME }}
|
|
Copy-Item -Path ${{ env.ZIP_FILENAME }} -Destination ${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }}
|
|
|
|
- name: Package release - Linux
|
|
if: startsWith(matrix.os, 'ubuntu-')
|
|
working-directory: extension/build/package
|
|
run: |
|
|
zip -r "${{ env.ZIP_FILENAME }}" .
|
|
cp "${{ env.ZIP_FILENAME }}" "${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }}"
|
|
|
|
- name: Upload release
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
shell: bash
|
|
working-directory: extension/build/package
|
|
run: |
|
|
echo "Begin upload..."
|
|
AUTHORIZATION="$(echo -n '${{ secrets.USERNAME }}:${{ secrets.PASSWORD }}' | base64)"
|
|
echo "::add-mask::${AUTHORIZATION}"
|
|
|
|
HTTP_CODE=$(curl -XPOST -H "Authorization: Basic ${AUTHORIZATION}" -H "Content-Type: application/zip" --output /dev/null --silent --write-out "%{http_code}" --data-binary "@${{ env.ZIP_FILENAME }}" "https://builds.limetech.io/upload.php?project=${{ env.PROJECT }}&filename=${{ env.ZIP_FILENAME }}")
|
|
if test ${HTTP_CODE} -ne 200; then
|
|
exit ${HTTP_CODE}
|
|
fi
|
|
echo "Upload successful!"
|
|
|
|
- name: Upload a Build Artifact
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
# Artifact name
|
|
name: ${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }}
|
|
# optional, default is artifact
|
|
# A file, directory or wildcard pattern that describes what to upload
|
|
path: ${{ github.workspace }}/extension/build/package/${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }}
|
|
# 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
|