Upload as artifacts for 1 month #175
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compile with SourceMod | |
on: | |
push: | |
branches: master | |
workflow_dispatch: | |
schedule: | |
- cron: '53 05 01 */1 *' # Artifact expires after 1 month | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: sudo apt install curl p7zip-full p7zip-rar | |
- name: Set environment variables | |
run: | | |
git fetch --unshallow | |
VERSION=$(git rev-list --count HEAD) | |
SHORT=$(git describe --always --long --dirty) | |
SOURCEMOD_PATH=$GITHUB_WORKSPACE/addons/sourcemod | |
echo "GIT_COMMIT=$VERSION" >> $GITHUB_ENV | |
echo "PLUGIN_VERSION=SM1.11.$VERSION.$SHORT" >> $GITHUB_ENV | |
echo "SOURCEMOD_PATH=$SOURCEMOD_PATH" >> $GITHUB_ENV | |
echo "SCRIPTS_PATH=$SOURCEMOD_PATH/scripting" >> $GITHUB_ENV | |
echo "PLUGINS_PATH=$SOURCEMOD_PATH/plugins" >> $GITHUB_ENV | |
- name: Setup SourcePawn Compiler SM1.11 | |
uses: rumblefrog/setup-sp@master | |
- name: Set TTT version | |
run: | | |
sed -i "s/<VERSION>/$PLUGIN_VERSION/g" $SCRIPTS_PATH/include/ttt_stock.inc | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: python3 -m pip install --upgrade pip setuptools wheel | |
- name: Download colorlib-gen | |
run: | | |
cd tools | |
git clone https://github.com/c0rp3n/colorlib-gen.git | |
- name: Install colorlib-gen | |
run: | | |
cd tools/colorlib-gen | |
pip install -r ./requirements.txt | |
python3 ./setup.py install | |
- name: Generate colorlib_map.inc | |
run: colorlib_gen -r --config "./ttt_colors.yaml" "../addons/sourcemod/scripting/include/colorlib_map.inc" | |
working-directory: ./tools | |
- name: Compile TTT | |
run: | | |
for file in *.sp | |
do | |
echo -e "\nCompiling $file..." | |
spcomp -E -w234 -O2 -v2 -i $includePath -i $SCRIPTS_PATH/include $file | |
done | |
working-directory: ${{ env.SCRIPTS_PATH }}/ttt | |
- name: Compile 3rd party plugins | |
run: | | |
for plugin in "block_messages" "customkeyvalues" "discord_api" "no_weapon_fix" "turret_core" "vphysics_crash_avoider" | |
do | |
echo -e "\nCompiling $plugin.sp..." | |
spcomp -E -w234 -O2 -v2 -i $includePath -i $SCRIPTS_PATH/include $plugin.sp | |
done | |
working-directory: ${{ env.SCRIPTS_PATH }}/ | |
- name: Move compiled plugins | |
run: | | |
rm -rf $PLUGINS_PATH | |
mkdir -p $PLUGINS_PATH/{ttt,disabled} | |
rsync -av --include='*/' --include="*.smx" --exclude="*" --prune-empty-dirs --remove-source-files $SCRIPTS_PATH/ $PLUGINS_PATH/ | |
- name: Disable optional plugins | |
run: | | |
mv $SCRIPTS_PATH/README.md $PLUGINS_PATH/disabled | |
mv $PLUGINS_PATH/ttt/ttt_{discord,dronescameras,futuristicgrenades,glow_light,parachute,tactical_shield}.smx $PLUGINS_PATH/disabled | |
- name: Move folders (addons, materials, models, particles, sound) to build | |
run: | | |
mkdir build | |
mv ./{addons,materials,models,particles,sound} build/ | |
- name: Add LICENSE, CREDITS.md, CVARS.txt and adminmenu_custom.txt to build package | |
run: | | |
mv $GITHUB_WORKSPACE/{LICENSE,CREDITS.md,CVARS.txt,adminmenu_custom.txt} . | |
working-directory: ./build | |
- name: Remove unnecessary files and folders from build | |
run: | | |
rm -rf addons/sourcemod/scripting | |
rm -rf addons/sourcemod/configs/{*.cfg,*.ini} | |
working-directory: ./build | |
- name: Rename build to build-linux and copy for build-windows | |
run: | | |
mv build build-linux | |
cp -r build-linux build-windows | |
- name: Download DHooks, SMJansson and SteamWorks | |
run: | | |
wget http://users.alliedmods.net/~kyles/builds/SteamWorks/SteamWorks-git132-linux.tar.gz -O steamworks_linux.tar.gz | |
wget http://users.alliedmods.net/~kyles/builds/SteamWorks/SteamWorks-git132-windows.zip -O steamworks_windows.zip | |
wget https://github.com/peace-maker/DHooks2/releases/download/v2.2.0-detours16/dhooks-2.2.0-detours16-sm110.zip -O dhooks.zip | |
wget "https://forums.alliedmods.net/attachment.php?attachmentid=133799&d=1400973546" -O smjansson.zip | |
- name: Unpacking DHooks, SMJansson and SteamWorks | |
run: | | |
tar xfv steamworks_linux.tar.gz | |
unzip -o steamworks_windows.zip | |
unzip dhooks.zip | |
unzip smjansson.zip | |
- name: Move DHooks, SMJansson and SteamWorks files | |
run: | | |
mkdir -p build-{windows,linux}/addons/sourcemod/extensions/ | |
cp addons/sourcemod/extensions/SteamWorks.ext.so build-linux/addons/sourcemod/extensions/ | |
cp addons/sourcemod/extensions/SteamWorks.ext.dll build-windows/addons/sourcemod/extensions/ | |
cp addons/sourcemod/extensions/dhooks.ext.so build-linux/addons/sourcemod/extensions/ | |
cp addons/sourcemod/extensions/dhooks.ext.dll build-windows/addons/sourcemod/extensions/ | |
cp smjansson.ext.so build-linux/addons/sourcemod/extensions/ | |
cp smjansson.ext.dll build-windows/addons/sourcemod/extensions/ | |
- name: Compress package | |
run: | | |
mkdir packages | |
zip -9rq packages/TTT.Linux.${{ env.PLUGIN_VERSION }}.zip build-linux/* | |
zip -9rq packages/TTT.Windows.${{ env.PLUGIN_VERSION }}.zip build-windows/* | |
- name: Upload linux artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: TTT.Linux.${{ env.PLUGIN_VERSION }} | |
path: packages/TTT.Linux.${{ env.PLUGIN_VERSION }}.zip | |
- name: Upload windows artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: TTT.Windows.${{ env.PLUGIN_VERSION }} | |
path: packages/TTT.Windows.${{ env.PLUGIN_VERSION }}.zip | |