1- name : Bump plugin version
1+ name : Auto bump + Compile
22
33on :
44 push :
@@ -9,42 +9,146 @@ permissions:
99 contents : write
1010
1111jobs :
12- bump :
12+ bump_version :
1313 runs-on : ubuntu-latest
1414
1515 steps :
1616 - name : Checkout
1717 uses : actions/checkout@v4
1818 with :
19- token : ${{ secrets.GITHUB_TOKEN }}
19+ fetch-depth : 0
2020
21- - name : Increment version
21+ - name : Detect changes that really matter
22+ id : changed
2223 run : |
23- FILE="addons/sourcemod/scripting/include/multimode/base.inc"
24+ CHANGED=$(git diff --name-only HEAD^ HEAD)
25+ echo "Changed Files:"
26+ echo "$CHANGED"
27+ NEED_BUMP=false
28+ if echo "$CHANGED" | grep -q '^addons/sourcemod/scripting/multimode_.*\.sp'; then
29+ NEED_BUMP=true
30+ fi
31+ if echo "$CHANGED" | grep -q '^addons/sourcemod/scripting/include/multimode/.*\.inc'; then
32+ if ! echo "$CHANGED" | grep -q 'addons/sourcemod/scripting/include/multimode/base.inc'; then
33+ NEED_BUMP=true
34+ fi
35+ fi
36+ echo "need_bump=$NEED_BUMP" >> $GITHUB_OUTPUT
2437
38+ - name : Bump version
39+ if : steps.changed.outputs.need_bump == 'true'
40+ run : |
41+ FILE="addons/sourcemod/scripting/include/multimode/base.inc"
2542 RAW_VERSION=$(grep -oP '(?<=#define PLUGIN_VERSION ")([^"]+)' "$FILE")
2643 VERSION=$(echo "$RAW_VERSION" | sed 's/[^0-9.]*//g')
27-
2844 IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
29-
3045 if [ "$PATCH" -ge 9 ]; then
3146 PATCH=0
3247 MINOR=$((MINOR + 1))
3348 else
3449 PATCH=$((PATCH + 1))
3550 fi
36-
3751 NEW_VERSION="$MAJOR.$MINOR.$PATCH++"
38-
3952 sed -i "s/#define PLUGIN_VERSION \".*\"/#define PLUGIN_VERSION \"$NEW_VERSION\"/" "$FILE"
40-
4153 echo "New Version: $NEW_VERSION"
4254
43- - name : Commit & push
55+ - name : Commit + Push
56+ if : steps.changed.outputs.need_bump == 'true'
4457 run : |
4558 git config user.name "github-actions"
4659 git config user.email "github-actions@users.noreply.github.com"
47-
4860 git add addons/sourcemod/scripting/include/multimode/base.inc
4961 git commit -m "Bump version automatically [skip ci]" || exit 0
5062 git push
63+
64+ compile :
65+ runs-on : ubuntu-latest
66+ needs : bump_version
67+
68+ steps :
69+ - name : Checkout
70+ uses : actions/checkout@v4
71+ with :
72+ fetch-depth : 0
73+
74+ - name : Download SourceMod compiler
75+ run : |
76+ mkdir compiler
77+ cd compiler
78+ wget https://sm.alliedmods.net/smdrop/1.11/sourcemod-1.11.0-git6923-linux.tar.gz
79+ tar -xzf sourcemod-*-linux.tar.gz
80+ mv addons/sourcemod/scripting/* ..
81+ cd ..
82+
83+ - name : Prepare include folder
84+ run : |
85+ mkdir -p addons/sourcemod/scripting/include
86+
87+ - name : Download Sourcemod Discord includes
88+ run : |
89+ git clone https://github.com/Cruze03/sourcemod-discord.git temp-discord
90+ cp -r temp-discord/include/* addons/sourcemod/scripting/include/
91+
92+ - name : Download SMJansson include
93+ run : |
94+ curl -L https://raw.githubusercontent.com/davenonymous/SMJansson/master/pawn/scripting/include/smjansson.inc \
95+ -o addons/sourcemod/scripting/include/smjansson.inc
96+
97+ - name : Detect changed multimode files
98+ id : changed
99+ run : |
100+ CHANGED=$(git diff --name-only HEAD^ HEAD)
101+ echo "Arquivos alterados:"
102+ echo "$CHANGED"
103+ NEED_BUILD=false
104+ if echo "$CHANGED" | grep -q '^addons/sourcemod/scripting/multimode_.*\.sp'; then
105+ NEED_BUILD=true
106+ fi
107+ if echo "$CHANGED" | grep -q '^addons/sourcemod/scripting/include/multimode/.*\.inc'; then
108+ if ! echo "$CHANGED" | grep -q 'addons/sourcemod/scripting/include/multimode/base.inc'; then
109+ NEED_BUILD=true
110+ fi
111+ fi
112+ echo "need_build=$NEED_BUILD" >> $GITHUB_OUTPUT
113+
114+ - name : Compile Multimode Core only
115+ if : steps.changed.outputs.need_build == 'true'
116+ run : |
117+ mkdir -p build
118+ for file in addons/sourcemod/scripting/multimode_*.sp; do
119+ if [[ "$file" == *"multimode_test.sp" ]]; then
120+ echo "Skipping $file"
121+ continue
122+ fi
123+ ./spcomp "$file" -iaddons/sourcemod/scripting/include -o"build/$(basename "${file%.sp}.smx")"
124+ done
125+
126+ - name : Upload artifacts
127+ if : steps.changed.outputs.need_build == 'true'
128+ uses : actions/upload-artifact@v4
129+ with :
130+ name : compiled-plugins
131+ path : build
132+
133+ - name : Remove old Multimode compiled plugins
134+ if : steps.changed.outputs.need_build == 'true'
135+ run : |
136+ mkdir -p addons/sourcemod/plugins
137+ git rm -f addons/sourcemod/plugins/multimode_*.smx || true
138+ rm -f addons/sourcemod/plugins/multimode_*.smx || true
139+
140+ - name : Copy compiled plugins into repo
141+ if : steps.changed.outputs.need_build == 'true'
142+ run : |
143+ mkdir -p addons/sourcemod/plugins
144+ cp -f build/multimode_*.smx addons/sourcemod/plugins/
145+
146+ - name : Commit plugins to repository
147+ if : steps.changed.outputs.need_build == 'true'
148+ run : |
149+ git config user.name "github-actions"
150+ git config user.email "github-actions@users.noreply.github.com"
151+ git add addons/sourcemod/plugins/*.smx
152+ git commit -m "Replace compiled plugins automatically [skip ci]" || exit 0
153+ git pull --rebase origin main || true
154+ git push
0 commit comments