Skip to content

Commit 1a810e8

Browse files
committed
workflow和脚本
1 parent 6fd83ec commit 1a810e8

4 files changed

Lines changed: 437 additions & 1 deletion

File tree

‎.github/workflows/check_plugins.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
build:
2525
name: build with sm${{ matrix.sm_version }}
2626
runs-on: ubuntu-latest
27+
if: false
2728
strategy:
2829
fail-fast: false
2930
matrix:
@@ -63,4 +64,4 @@ jobs:
6364
echo -e "\nAll plugins compiled successfully."
6465
exit 0
6566
fi
66-
working-directory: ${{ env.SCRIPTS_PATH }}/
67+
working-directory: ${{ env.SCRIPTS_PATH }}/
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
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."

‎update_full.sh‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
echo "==================本次执行时间=================="
3+
TZ=UTC-8 date
4+
echo "==================开始执行=================="
5+
6+
# github存储库名称
7+
gitrep=L4D2-Competitive-Rework
8+
9+
sudo iptables -F
10+
sudo iptables -X
11+
sudo iptables -P INPUT ACCEPT
12+
sudo iptables -P FORWARD ACCEPT
13+
sudo iptables -P OUTPUT ACCEPT
14+
15+
echo "Get Plugin updates";
16+
cd /home/steam/$gitrep/;
17+
sudo timedatectl set-timezone Asia/Shanghai
18+
git reset --hard;
19+
git pull --rebase;
20+
git status;
21+
22+
directories=("/home/steam/Steam/steamapps/common/l4d2versus/left4dead2" "/home/steam/Steam/steamapps/common/l4d2/left4dead2")
23+
24+
for dir in "${directories[@]}"; do
25+
if [ -d "$dir" ]; then
26+
27+
../steamcmd.sh +force_install_dir ${dir%/left4dead2} +login anonymous +app_update 222860 validate +quit
28+
29+
echo ""
30+
find "$dir/addons/sourcemod/" \
31+
! -path "$dir/addons/sourcemod/logs*" \
32+
! -path "$dir/addons/sourcemod/configs/admins_simple.ini" \
33+
! -path "$dir/addons/sourcemod/configs/sourcebans*" \
34+
! -path "$dir/addons/sourcemod/configs/databases.cfg" \
35+
! -path "$dir/addons/sourcemod/data/music_mapstart.txt" \
36+
-type f -delete
37+
find $dir/addons/sourcemod/logs* -type f -mtime +14 -delete
38+
find $dir/logs* -type f -mtime +14 -delete
39+
rm -rf "$dir/addons/metamod/"*
40+
rm -rf "$dir/addons/l4dtoolz/"*
41+
rm -rf "$dir/addons/stripper/"*
42+
rm -rf "$dir/scripts/vscripts/"*
43+
rm -rf "$dir/models/player/custom_player/"*
44+
rm -rf "$dir/sound/kodua/fortnite_emotes/"*
45+
# 剩下三个cfg应该不会被删除
46+
find "$dir/cfg/cfgogl/" \
47+
! -path "$dir/cfg/cfgogl/promod" \
48+
-type f -delete
49+
rm -rf "$dir/cfg/mixmap/"*
50+
rm -rf "$dir/cfg/sourcemod/"*
51+
rm -rf "$dir/cfg/stripper/"*
52+
53+
rm -f "$dir/l4dtoolz.dll"
54+
rm -f "$dir/l4dtoolz.so"
55+
rm -f "$dir/l4dtoolz.vdf"
56+
rm -f "$dir/metamod.vdf"
57+
58+
\cp -rp /home/steam/$gitrep/* "$dir/";
59+
chmod 777 "$dir/"
60+
61+
echo "Updated | $dir"
62+
else
63+
echo "Unexist | $dir "
64+
fi
65+
done
66+
echo "File Copy Success";
67+
68+
echo "==================当前commit=================="
69+
git log -1
70+
echo "================== 运行结束 =================="
71+
cd /home/steam/$gitrep/;

0 commit comments

Comments
 (0)