Skip to content

Commit 576537e

Browse files
Merge pull request #450 from UnrealMultiple/riips
CI rework
2 parents b871b48 + f84b866 commit 576537e

30 files changed

+205
-298
lines changed

.github/workflows/build.yml

Lines changed: 81 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -23,92 +23,59 @@ jobs:
2323
dotnet-version: 6.0.x
2424

2525
- name: 安装构建依赖
26+
shell: pwsh
2627
run: |
27-
dotnet tool restore
2828
sudo apt install -y gettext
29-
wget -q https://github.com/ACaiCat/PluginInfoLoaderr/releases/download/v1.0.0.0/linux-x64.zip
30-
unzip -qq linux-x64.zip
31-
32-
- name: 生成POT
33-
continue-on-error: true
34-
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'UnrealMultiple/TShockPlugin'
35-
run: |
36-
python scripts/POFileUpdater.py auto debug
37-
git config --local user.email "action@github.com"
38-
git config --local user.name "GitHub Action"
39-
git add .
40-
if git diff --staged --quiet; then
41-
echo "跳过更新:POT没有变化"
42-
else
43-
git commit -m "自动更新POT文件 [skip ci]"
44-
git push
45-
fi
46-
47-
- name: 更新子模块
48-
continue-on-error: true
49-
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'UnrealMultiple/TShockPlugin'
50-
run: |
51-
git config --local user.email "action@github.com"
52-
git config --local user.name "GitHub Action"
53-
git add .
54-
if git diff --staged --quiet; then
55-
echo "跳过更新:子模块没有变化"
56-
else
57-
git commit -m "自动更新子模块 [skip ci]"
58-
git push
59-
fi
29+
foreach ($p in @(Get-ChildItem src/**/i18n/*.po)) {
30+
Start-Process -FilePath msgfmt -WorkingDirectory $p.Directory.FullName -ArgumentList "-o $([System.IO.Path]::ChangeExtension($p.Name, ".mo")) $($p.Name)"
31+
}
6032
61-
6233
- name: 构建插件
6334
if: github.event_name != 'push' || github.ref != 'refs/heads/master'
6435
run: |
6536
dotnet build Plugin.sln -c Debug
66-
cp ./out/Debug/*.dll ./linux-x64/ServerPlugins/
67-
sudo python scripts/BuildHelper.py Debug
68-
env:
69-
PYTHONIOENCODING: 'utf-8'
7037
7138
- name: 构建插件
7239
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
7340
run: |
7441
dotnet build Plugin.sln -c Release
75-
cp ./out/Release/*.dll ./linux-x64/ServerPlugins/
76-
77-
- name: 更新Plugins.json
78-
continue-on-error: true
79-
run: |
80-
cd linux-x64
81-
chmod +x TShock.Server
82-
timeout 60s ./TShock.Server
83-
mv Plugins.json ../
84-
85-
- name: 更新Plugins.json
86-
continue-on-error: true
87-
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'UnrealMultiple/TShockPlugin'
88-
run: |
89-
git config --local user.email "action@github.com"
90-
git config --local user.name "GitHub Action"
91-
git add Plugins.json
92-
if git diff --staged --quiet; then
93-
echo "跳过更新:没有插件版本变化"
94-
else
95-
git commit -m "自动更新Plugins.json [skip ci]"
96-
git pull
97-
git push
98-
fi
9942
10043
- name: 打包
101-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
44+
shell: pwsh
10245
run: |
103-
sudo python scripts/BuildHelper.py Release ${{ secrets.CAI_GITEE_TOKEN }}
104-
env:
105-
PYTHONIOENCODING: 'utf-8'
106-
46+
New-Item -Name bin -ItemType Directory
47+
$rid = if ([System.Environment]::OSVersion.Platform -Match "Unix") { "linux-x64" } else { "win-x64" }
48+
Invoke-WebRequest (Invoke-WebRequest 'https://api.github.com/repos/Pryaxis/TShock/releases' | ConvertFrom-Json | Select-Object -First 1 -ExpandProperty assets | Where-Object browser_download_url -Match $rid | Select-Object -ExpandProperty browser_download_url) -OutFile bin/TShock.zip
49+
Expand-Archive bin/TShock.zip -DestinationPath bin
50+
if ([System.Environment]::OSVersion.Platform -Match "Unix") {
51+
tar xvf bin/TShock-Beta-linux-x64-Release.tar --directory bin
52+
}
53+
Copy-Item out/**/*.dll bin/ServerPlugins/
54+
Set-Location bin
55+
./TShock.Server -dump-plugins-list-only
56+
Set-Location ../
57+
New-Item -Path out/Target -Name Plugins -ItemType Directory
58+
$ErrorActionPreference = "SilentlyContinue"
59+
foreach ($p in @(Get-ChildItem src/**/*.csproj)) {
60+
Copy-Item "$($p.DirectoryName)/README.md" "out/Target/Plugins/$($p.Directory.Name).md"
61+
Copy-Item "$($p.DirectoryName)/README_EN.md" "out/Target/Plugins/$($p.Directory.Name)_EN.md"
62+
}
63+
$ErrorActionPreference = "Continue"
64+
Copy-Item out/**/*.dll,out/**/*.pdb out/Target/Plugins/
65+
Copy-Item bin/Plugins.json,README.md,Usage.txt,LICENSE out/Target/
66+
python scripts/zip.py
67+
10768
- name: 上传临时插件包
10869
uses: actions/upload-artifact@v4
10970
with:
11071
name: Plugins
111-
path: Plugins.zip
72+
path: out/Plugins.zip
73+
74+
- name: 更新tag
75+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
76+
run: |
77+
git tag -f V1.0.0.0
78+
git push -f origin V1.0.0.0
11279
11380
- name: 获取更新日志
11481
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -117,20 +84,6 @@ jobs:
11784
with:
11885
configuration: ".config/log_config.json"
11986

120-
- name: 生成更新日志
121-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
122-
env:
123-
CHANGELOG: ${{ steps.external_changelog_second.outputs.changelog }}
124-
CHANGELOG_SECOND: ${{ steps.external_changelog_second.outputs.changelog }}
125-
run: |
126-
echo ${{ steps.external_changelog_collect.outputs.cache }}
127-
echo "First:"
128-
echo "$CHANGELOG"
129-
echo "Second:"
130-
echo "$CHANGELOG_SECOND"
131-
git tag -f V1.0.0.0
132-
git push -f origin V1.0.0.0
133-
13487
- name: 发布插件包
13588
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
13689
uses: ncipollo/release-action@v1
@@ -146,9 +99,55 @@ jobs:
14699
>**请你`详细`的看`上面的说明`,不要到处问`插件怎么用`、`ZIP如何解压`、`PDF怎么打开`**
147100
<details>
148101
<summary>更新日志</summary>
102+
149103
${{steps.external_changelog_second.outputs.changelog}}
150104
</details>
151105
artifacts: |
152-
Plugins.zip
106+
out/Plugins.zip
153107
allowUpdates: true
154108
removeArtifacts: true
109+
110+
- name: 更新相关文件
111+
continue-on-error: true
112+
shell: pwsh
113+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'UnrealMultiple/TShockPlugin'
114+
run: |
115+
dotnet tool restore
116+
git config --local user.email "action@github.com"
117+
git config --local user.name "GitHub Action"
118+
$Changed = [System.Object[]]::new(0)
119+
foreach ($p in @(Get-ChildItem src/**/*.csproj)) {
120+
$pot = [System.IO.Path]::Combine($p.DirectoryName, "i18n", "template.pot")
121+
New-Item -Path $p.DirectoryName -Name i18n -ItemType Directory
122+
GetText.Extractor -u -o -s $p.FullName -t $pot
123+
$d = $(git diff --numstat $pot).Split()
124+
if ($d[0] -le 2 -and $d[1] -le 2) {
125+
git checkout $pot
126+
} else {
127+
foreach ($t in @(Get-ChildItem $($p.DirectoryName)i18n/*.po)) {
128+
msgmerge --previous --update $t $pot
129+
}
130+
}
131+
}
132+
git diff --quiet
133+
if ($LastExitCode -ne 0) {
134+
$Changed += "译文模板"
135+
git add .
136+
}
137+
Copy-Item out/Target/Plugins.json Plugins.json -Force
138+
git diff --quiet
139+
if ($LastExitCode -ne 0) {
140+
$Changed += "插件列表"
141+
git add .
142+
}
143+
if ($Changed.Length -gt 0) {
144+
git commit -m "自动更新$($Changed -Join ", ") [skip ci]"
145+
git push
146+
}
147+
148+
- name: 同步Gitee
149+
continue-on-error: true
150+
shell: pwsh
151+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'UnrealMultiple/TShockPlugin'
152+
run: |
153+
python scripts/GiteeSync.py ${{ secrets.CAI_GITEE_TOKEN }}

.github/workflows/forum_update.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ jobs:
2020
- name: 安装beautifulsoup4
2121
run: |
2222
sudo pip install beautifulsoup4
23-
23+
2424
- name: 更新论坛
2525
continue-on-error: true
2626
env:
2727
PYTHONIOENCODING: 'utf-8'
2828
run:
29-
sudo python scripts/ForumUpdate.py Cai ${{ secrets.MONIKA_TR_PASSWORD }}
30-
29+
sudo python scripts/ForumUpdate.py Cai ${{ secrets.MONIKA_TR_PASSWORD }}
30+
3131
- name: 更新论坛主文档
3232
continue-on-error: true
3333
env:
34-
PYTHONIOENCODING: 'utf-8'
34+
PYTHONIOENCODING: 'utf-8'
3535
run:
36-
sudo python scripts/ForumHelper.py Cai ${{ secrets.MONIKA_TR_PASSWORD }}
36+
sudo python scripts/ForumHelper.py Cai ${{ secrets.MONIKA_TR_PASSWORD }}

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,4 @@ FodyWeavers.xsd
367367

368368
# Localization
369369
template.pot.bak
370-
*.mo
371-
372-
# CI
373-
linux-x64/
374-
linux-x64.zip
370+
*.mo

Plugin.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChestRestore", "src\ChestRe
230230
EndProject
231231
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JourneyUnlock", "src\JourneyUnlock\JourneyUnlock.csproj", "{9D12FEA8-EBEC-4249-A8BA-9E6CC2FFA77C}"
232232
EndProject
233+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DumpPluginsList", "src\DumpPluginsList\DumpPluginsList.csproj", "{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}"
234+
EndProject
233235
Global
234236
GlobalSection(SolutionConfigurationPlatforms) = preSolution
235237
Debug|Any CPU = Debug|Any CPU
@@ -1126,6 +1128,14 @@ Global
11261128
{9D12FEA8-EBEC-4249-A8BA-9E6CC2FFA77C}.Release|Any CPU.Build.0 = Release|Any CPU
11271129
{9D12FEA8-EBEC-4249-A8BA-9E6CC2FFA77C}.Release|x64.ActiveCfg = Release|Any CPU
11281130
{9D12FEA8-EBEC-4249-A8BA-9E6CC2FFA77C}.Release|x64.Build.0 = Release|Any CPU
1131+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1132+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Debug|Any CPU.Build.0 = Debug|Any CPU
1133+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Debug|x64.ActiveCfg = Debug|Any CPU
1134+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Debug|x64.Build.0 = Debug|Any CPU
1135+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Release|Any CPU.ActiveCfg = Release|Any CPU
1136+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Release|Any CPU.Build.0 = Release|Any CPU
1137+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Release|x64.ActiveCfg = Release|Any CPU
1138+
{A29A93FC-6BAA-4533-BDFC-2AFD62F15756}.Release|x64.Build.0 = Release|Any CPU
11291139
EndGlobalSection
11301140
GlobalSection(SolutionProperties) = preSolution
11311141
HideSolutionNode = FALSE

scripts/BuildHelper.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

scripts/ForumHelper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
password = sys.argv[2]
1010
print(f"论坛自动更新脚本 (by Cai😘)")
1111
print(f"登录名: {name}")
12-
print(f"密码: {password}")
1312

1413
# tr.monika.love
1514
# 创建会话

scripts/ForumUpdate.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,12 @@
77
result = rq.get("https://api.github.com/repos/UnrealMultiple/TShockPlugin/pulls?state=closed&per_page=1&page=1").json()
88

99

10-
if result[0]['merged_at'] is None:
11-
print("未合并,跳过发送")
12-
exit(0)
13-
14-
15-
1610
html = f'<font size="6">✅ <a href="{result[0]["html_url"]}">{result[0]["title"]}</a> ({datetime.datetime.strptime(result[0]["closed_at"], "%Y-%m-%dT%H:%M:%SZ").date()})</font>'
1711
# 读取用户名 密码
1812
name = sys.argv[1]
1913
password = sys.argv[2]
2014
print(f"论坛自动更新脚本 (by Cai😘)")
2115
print(f"登录名: {name}")
22-
print(f"密码: {password}")
2316

2417

2518
# tr.monika.love

0 commit comments

Comments
 (0)