Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 65 additions & 4 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:

env:
SOURCEMOD: ${{ github.workspace }}/${{ inputs.cache-dir }}/sourcemod
PROJECT: 'accelerator'
PROJECT_OS: ${{ inputs.os }}

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -50,7 +53,20 @@ jobs:
key: ${{ inputs.cache-key }}
fail-on-cache-miss: true
enableCrossOsArchive: true


# https://stackoverflow.com/a/64195658
# i hate github actions
- name: Add SHORT_SHA env property with commit short sha
shell: bash
run: |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV

- name: scrape version and export to env
shell: bash
run: |
echo "SM_VERSION=`cat ./extension/version.h | grep "#define SM_VERSION" | cut -f 2 -d '"'`" >> $GITHUB_ENV
echo ${{ env.SM_VERSION }}

- name: Linux dependencies
if: startsWith(runner.os, 'Linux')
run: |
Expand All @@ -60,7 +76,8 @@ jobs:
gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \
libc6-dev libc6-dev-i386 linux-libc-dev \
linux-libc-dev:i386 lib32z1-dev \
zlib1g-dev:i386 zlib1g-dev ${{ inputs.cc }}
zlib1g-dev:i386 zlib1g-dev \
${{ inputs.cc }}

- name: Select clang compiler
if: startsWith(runner.os, 'Linux')
Expand Down Expand Up @@ -89,14 +106,58 @@ jobs:

- name: Build (Release)
if: not ${{ inputs.debug }}
shell: bash
run: |
mkdir -p build && cd build
python ../configure.py --enable-optimize
ambuild

- name: Upload package
# e.g. accelerator-2.6.0-abcdefg-windows.zip
ZIP_FILENAME="${{ env.PROJECT }}-${{ env.SM_VERSION }}-${{ env.SHORT_SHA }}-${{ env.PROJECT_OS }}.zip"
echo ${ZIP_FILENAME}
echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV

# github upload
- name: Upload release to GitHub
if: ${{ inputs.upload }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.upload-artifact-name }}
path: build/package
path: build/package
retention-days: 14

- name: Package release - Windows
if: ${{ startsWith(env.PROJECT_OS, 'windows-latest') }}
# shell: pwsh
working-directory: 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(env.PROJECT_OS, 'ubuntu-22.04') }}
working-directory: build/package
run: |
zip -r "${{ env.ZIP_FILENAME }}" .
cp "${{ env.ZIP_FILENAME }}" "${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }}"

# limetech upload
- name: Upload release to limetech
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
shell: bash
working-directory: build/package
#
# AUTHORIZATION="$(echo -n '${{ secrets.USERNAME }}:${{ secrets.UPLOAD_PASSWORD }}' | base64)"
run: |
echo "Begin upload..."
AUTHORIZATION="$(echo -n 'builds:${{ secrets.UPLOAD_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
echo "server returned HTTP status ${HTTP_CODE}!!"
exit 254
# we can not exit ${HTTP_CODE}, bash only goes up to a maximum of exit 255, and http has more codes than that!
fi
echo "Upload successful!"

Loading