@@ -23,92 +23,59 @@ jobs:
23
23
dotnet-version : 6.0.x
24
24
25
25
- name : 安装构建依赖
26
+ shell : pwsh
26
27
run : |
27
- dotnet tool restore
28
28
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
+ }
60
32
61
-
62
33
- name : 构建插件
63
34
if : github.event_name != 'push' || github.ref != 'refs/heads/master'
64
35
run : |
65
36
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'
70
37
71
38
- name : 构建插件
72
39
if : github.event_name == 'push' && github.ref == 'refs/heads/master'
73
40
run : |
74
41
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
99
42
100
43
- name : 打包
101
- if : github.event_name == 'push' && github.ref == 'refs/heads/master'
44
+ shell : pwsh
102
45
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
+
107
68
- name : 上传临时插件包
108
69
uses : actions/upload-artifact@v4
109
70
with :
110
71
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
112
79
113
80
- name : 获取更新日志
114
81
if : github.event_name == 'push' && github.ref == 'refs/heads/master'
@@ -117,20 +84,6 @@ jobs:
117
84
with :
118
85
configuration : " .config/log_config.json"
119
86
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
-
134
87
- name : 发布插件包
135
88
if : github.event_name == 'push' && github.ref == 'refs/heads/master'
136
89
uses : ncipollo/release-action@v1
@@ -146,9 +99,55 @@ jobs:
146
99
>**请你`详细`的看`上面的说明`,不要到处问`插件怎么用`、`ZIP如何解压`、`PDF怎么打开`**
147
100
<details>
148
101
<summary>更新日志</summary>
102
+
149
103
${{steps.external_changelog_second.outputs.changelog}}
150
104
</details>
151
105
artifacts : |
152
- Plugins.zip
106
+ out/ Plugins.zip
153
107
allowUpdates : true
154
108
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 }}
0 commit comments