1+ name : Compile Plugins and Release
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ paths :
8+ - ' addons/sourcemod/scripting/**/*.sp'
9+ - ' addons/sourcemod/scripting/**/*.inc'
10+ workflow_dispatch :
11+
12+ permissions :
13+ contents : write
14+
15+ jobs :
16+ build-and-release :
17+ name : Compile plugins and create release
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - uses : actions/checkout@v4
22+ with :
23+ fetch-depth : 0
24+
25+ - name : Set environment variables
26+ run : |
27+ echo "SCRIPTS_PATH=$GITHUB_WORKSPACE/addons/sourcemod/scripting" >> $GITHUB_ENV
28+ echo "PLUGINS_PATH=$GITHUB_WORKSPACE/addons/sourcemod/plugins" >> $GITHUB_ENV
29+
30+ - name : Setup SourcePawn Compiler 1.12
31+ uses : rumblefrog/setup-sp@master
32+ with :
33+ version : " 1.12"
34+
35+ - name : Create compile output directory
36+ run : mkdir -p "${{ env.SCRIPTS_PATH }}/compiled"
37+
38+ - name : Compile all plugins
39+ run : |
40+ errors=0
41+ compiled_count=0
42+ skipped_count=0
43+
44+ # Find all .sp files in scripting directory (including subdirectories)
45+ find . -name "*.sp" -type f | while read -r file; do
46+ # Skip archive, dev_plugins, and other non-compilable directories
47+ if [[ "$file" == *"/archive/"* ]] || [[ "$file" == *"/dev_plugins/"* ]] || [[ "$file" == *"/testsuite/"* ]]; then
48+ echo "Skipping archived/test file: $file"
49+ continue
50+ fi
51+
52+ # Get the basename without extension
53+ filename=$(basename "$file" .sp)
54+ output_file="compiled/${filename}.smx"
55+
56+ # Check if compiled file already exists
57+ if [ -f "$output_file" ]; then
58+ echo "Already compiled: $file (skipping)"
59+ skipped_count=$((skipped_count + 1))
60+ continue
61+ fi
62+
63+ echo "Compiling $file -> $output_file"
64+ if spcomp -E -w234 -w217 -O2 -v2 -i "${{ env.SCRIPTS_PATH }}/include" "$file" -o "$output_file"; then
65+ compiled_count=$((compiled_count + 1))
66+ else
67+ echo "::warning file=$file::Failed to compile plugin: $file"
68+ errors=$((errors + 1))
69+ fi
70+ done
71+
72+ echo ""
73+ echo "Compilation Summary:"
74+ echo "Successfully compiled: $compiled_count plugins"
75+ echo "Skipped (already compiled): $skipped_count plugins"
76+ echo "Failed to compile: $errors plugin(s)"
77+ working-directory : ${{ env.SCRIPTS_PATH }}/
78+
79+ - name : Copy compiled plugins to plugins directory
80+ run : |
81+ echo "Copying compiled .smx files to plugins directory..."
82+
83+ found_count=0
84+ not_found_count=0
85+
86+ # Copy main directory plugins
87+ for file in "${{ env.SCRIPTS_PATH }}/compiled"/*.smx; do
88+ if [ -f "$file" ]; then
89+ filename=$(basename "$file")
90+ found=false
91+
92+ # Try to find the corresponding .smx file in plugins directory
93+ # First check main plugins directory
94+ if [ -f "${{ env.PLUGINS_PATH }}/$filename" ]; then
95+ echo "Updating ${{ env.PLUGINS_PATH }}/$filename"
96+ cp "$file" "${{ env.PLUGINS_PATH }}/$filename"
97+ found=true
98+ found_count=$((found_count + 1))
99+ else
100+ # Check subdirectories (fixes, optional, disabled, fun, anticheat, server_specified)
101+ for subdir in fixes optional disabled fun anticheat server_specified; do
102+ if [ -f "${{ env.PLUGINS_PATH }}/$subdir/$filename" ]; then
103+ echo "Updating ${{ env.PLUGINS_PATH }}/$subdir/$filename"
104+ cp "$file" "${{ env.PLUGINS_PATH }}/$subdir/$filename"
105+ found=true
106+ found_count=$((found_count + 1))
107+ break
108+ fi
109+ done
110+ fi
111+
112+ # If no matching file found, log warning notification and skip
113+ if [ "$found" = false ]; then
114+ echo "::notice title=Plugin Not Found::No matching plugin file found for $filename - skipping"
115+ not_found_count=$((not_found_count + 1))
116+ fi
117+ fi
118+ done
119+
120+ echo ""
121+ echo "Plugin copy completed."
122+ echo "Successfully updated: $found_count plugins"
123+ echo "Skipped (not found): $not_found_count plugins"
124+
125+ - name : Check for changes
126+ id : check_changes
127+ run : |
128+ if git diff --quiet addons/sourcemod/plugins/; then
129+ echo "changes=false" >> $GITHUB_OUTPUT
130+ echo "No changes detected in compiled plugins."
131+ else
132+ echo "changes=true" >> $GITHUB_OUTPUT
133+ echo "Changes detected in compiled plugins."
134+ fi
135+
136+ - name : Prepare release package
137+ if : steps.check_changes.outputs.changes == 'true'
138+ run : |
139+ # Create manifest file in project root
140+ {
141+ echo "# L4D2 Competitive Rework - Compiled Release"
142+ echo ""
143+ echo "**Package Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
144+ echo ""
145+ echo "## Contents"
146+ echo "Complete project with recompiled plugins."
147+ echo ""
148+ echo "Updated plugins location:"
149+ echo "- \`addons/sourcemod/plugins/\` - Main and optional plugins"
150+ echo "- \`addons/sourcemod/plugins/fixes/\` - Bug fix plugins"
151+ echo "- \`addons/sourcemod/plugins/optional/\` - Optional plugins"
152+ echo "- \`addons/sourcemod/plugins/disabled/\` - Disabled plugins"
153+ echo "- \`addons/sourcemod/plugins/fun/\` - Fun plugins"
154+ echo ""
155+ echo "## Installation"
156+ echo "Extract the contents of this zip file to your game directory."
157+ echo ""
158+ echo "**Build Information**"
159+ echo "- Compiled: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
160+ echo "- Compiler: spcomp 1.12"
161+ echo "- Commit: ${{ github.sha }}"
162+ } > "$GITHUB_WORKSPACE/RELEASE_INFO.txt"
163+
164+ cat "$GITHUB_WORKSPACE/RELEASE_INFO.txt"
165+
166+ - name : Remove l4dtoolz addon
167+ if : steps.check_changes.outputs.changes == 'true'
168+ run : |
169+ rm -rf "$GITHUB_WORKSPACE/addons/l4dtoolz"
170+ echo "Removed addons/l4dtoolz folder"
171+
172+ - name : Create project zip package
173+ if : steps.check_changes.outputs.changes == 'true'
174+ run : |
175+ cd "$GITHUB_WORKSPACE/.."
176+ zip -r L4D2-Competitive-Rework-compiled.zip L4D2-Competitive-Rework -q -x "L4D2-Competitive-Rework/.git/*" "L4D2-Competitive-Rework/.github/*" "L4D2-Competitive-Rework/.gitignore" "L4D2-Competitive-Rework/.gitattributes"
177+ ls -lh L4D2-Competitive-Rework-compiled.zip
178+ mv L4D2-Competitive-Rework-compiled.zip "$GITHUB_WORKSPACE/"
179+ echo "Project zip package created successfully"
180+
181+ - name : Generate release notes
182+ if : steps.check_changes.outputs.changes == 'true'
183+ id : release_notes
184+ run : |
185+ release_date=$(date '+%Y-%m-%d')
186+ release_tag="v$(date '+%Y%m%d-%H%M%S')"
187+ echo "release_date=$release_date" >> $GITHUB_OUTPUT
188+ echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
189+
190+ # Generate release notes with compilation summary
191+ {
192+ echo "# Plugin Compilation Release"
193+ echo ""
194+ echo "**Release Date:** $release_date"
195+ echo ""
196+ echo "## Summary"
197+ echo "Complete L4D2 Competitive Rework project with recompiled plugins from the latest source code."
198+ echo ""
199+ echo "### Build Information"
200+ echo "- SourceMod Version: 1.12"
201+ echo "- Compiler: spcomp with optimization level 2"
202+ echo "- Build Date: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
203+ echo "- Commit: ${{ github.sha }}"
204+ echo ""
205+ echo "### Installation"
206+ echo "1. Download \`L4D2-Competitive-Rework-compiled.zip\`"
207+ echo "2. Extract to your game server directory"
208+ echo "3. The entire project structure will be placed with updated compiled plugins"
209+ } > release_notes.md
210+
211+ cat release_notes.md
212+ env :
213+ TZ : UTC
214+
215+ - name : Create Release
216+ if : steps.check_changes.outputs.changes == 'true'
217+ uses : softprops/action-gh-release@v1
218+ with :
219+ tag_name : ${{ steps.release_notes.outputs.release_tag }}
220+ name : Plugin Compilation Release ${{ steps.release_notes.outputs.release_date }}
221+ body_path : release_notes.md
222+ draft : false
223+ prerelease : false
224+ files : L4D2-Competitive-Rework-compiled.zip
225+ env :
226+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
227+
228+ - name : Skip release (no changes)
229+ if : steps.check_changes.outputs.changes == 'false'
230+ run : |
231+ echo "No plugin changes detected. Release skipped."
0 commit comments