-
Notifications
You must be signed in to change notification settings - Fork 13
197 lines (183 loc) · 7.94 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: 插件构建发布
on:
push:
branches:
- '**'
tags-ignore:
- 'V1.0.0.0'
pull_request:
jobs:
Build:
runs-on: ubuntu-latest
name: 构建插件
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: 初始化.NET
uses: actions/setup-dotnet@v4
env:
DOTNET_CLI_UI_LANGUAGE: zh-CN
with:
dotnet-version: |
9.x
6.x
- name: 安装构建依赖
shell: pwsh
run: |
sudo apt install -y gettext
foreach ($p in @(Get-ChildItem src/**/i18n/*.po)) {
Start-Process -FilePath msgfmt -WorkingDirectory $p.Directory.FullName -ArgumentList "-o $([System.IO.Path]::ChangeExtension($p.Name, ".mo")) $($p.Name)"
}
- name: 构建插件
if: github.event_name != 'push' || github.ref != 'refs/heads/master'
shell: pwsh
run: |
./scripts/submodule_build.ps1 -BuildType Debug -TargetFramework net6.0
dotnet build Plugin.sln -c Debug
- name: 构建插件
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
shell: pwsh
run: |
./scripts/submodule_build.ps1 -BuildType Release -TargetFramework net6.0
dotnet build Plugin.sln -c Release
- name: 打包
shell: pwsh
run: |
New-Item -Name bin -ItemType Directory
$rid = if ([System.Environment]::OSVersion.Platform -Match "Unix") { "linux-(x64|amd64)" } else { "win-(x64|amd64)" }
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
Expand-Archive bin/TShock.zip -DestinationPath bin
if ([System.Environment]::OSVersion.Platform -Match "Unix") {
tar xvf bin/TShock-Beta-linux-x64-Release.tar --directory bin
}
Copy-Item out/**/*.dll bin/ServerPlugins/
Copy-Item SubmoduleAssembly/*.dll bin/ServerPlugins/
Set-Location bin
New-Item -Name manifests -ItemType Directory
foreach ($p in @(Get-ChildItem ../src/**/*.csproj)) {
$manifestPath = Join-Path $p.DirectoryName manifest.json
if (Test-Path $manifestPath -PathType Leaf) {
Copy-Item $manifestPath $(Join-Path manifests "$($p.Basename).json")
}
}
Copy-Item ../.config/submodule-manifests/* ./manifests
./TShock.Server -dump-plugins-list-only ./manifests
Set-Location ../
New-Item -Path out/Target -Name Plugins -ItemType Directory
$ErrorActionPreference = "SilentlyContinue"
foreach ($p in @(Get-ChildItem src/**/*.csproj)) {
foreach ($r in @(Get-ChildItem "$($p.Directory)/README*.md")) {
$ext_parts = ($r.Name -split '\.')
$ext = $ext_parts[1..$ext_parts.Length] -join '.'
Copy-Item $r "out/Target/Plugins/$($p.BaseName).$ext"
}
}
$ErrorActionPreference = "Continue"
Copy-Item out/**/*.dll,out/**/*.pdb out/Target/Plugins/
Copy-Item SubmoduleAssembly/* out/Target/Plugins/
Copy-Item bin/Plugins.json,README*.md,Usage.txt,LICENSE out/Target/
- name: 上传临时插件包
uses: actions/upload-artifact@v4
with:
name: Plugins
path: out/Target/*
compression-level: 9
- name: 更新相关文件
continue-on-error: true
shell: pwsh
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'UnrealMultiple/TShockPlugin'
run: |
dotnet tool restore
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
$Changed = [System.Object[]]::new(0)
foreach ($p in @(Get-ChildItem src/**/*.csproj)) {
$pot = [System.IO.Path]::Combine($p.DirectoryName, "i18n", "template.pot")
New-Item -Path $p.DirectoryName -Name i18n -ItemType Directory -Force
dotnet tool run GetText.Extractor -u -o -s $p.FullName -t $pot
}
git add -N src/**/i18n/*.pot
foreach ($p in @(git diff --numstat)) {
if (!$p.EndsWith(".pot")) { continue }
$d = -split $p
if ([int]$d[0] -le 2 -and [int]$d[1] -le 2) {
git checkout $d[2]
} else {
foreach ($t in @(Get-ChildItem $([System.IO.Path]::GetDirectoryName($d[2]))*.po)) {
msgmerge --previous --update $t $d[2]
}
}
}
git diff --quiet
if ($LastExitCode -ne 0) {
$Changed += "译文模板"
git add .
}
Copy-Item out/Target/Plugins.json Plugins.json -Force
git diff --quiet
if ($LastExitCode -ne 0) {
$Changed += "插件列表"
git add .
}
./scripts/generate-readme.ps1
git diff --quiet
if ($LastExitCode -ne 0) {
$Changed += "README文档"
git add .
}
if ($Changed.Length -gt 0) {
git commit -m "自动更新$($Changed -Join ", ") [skip ci]"
git push
}
- name: 下载临时插件包
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: dawidd6/action-download-artifact@v6
with:
name: Plugins
path: bin
skip_unpack: true
- name: 同步其他平台
continue-on-error: true
shell: pwsh
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'UnrealMultiple/TShockPlugin'
run: |
sudo pip install beautifulsoup4
python scripts/GiteeSync.py ${{ secrets.CAI_GITEE_TOKEN }}
sudo python scripts/ForumHelper.py Cai ${{ secrets.MONIKA_TR_PASSWORD }}
- name: 更新tag
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
git tag -f V1.0.0.0
git push -f origin V1.0.0.0
- name: 获取更新日志
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
id: external_changelog_second
uses: mikepenz/release-changelog-builder-action@v5
with:
configuration: ".config/log_config.json"
- name: 发布插件包
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: ncipollo/release-action@v1
with:
tag: V1.0.0.0
name: "最新版本"
body: |
# 插件下载和更新日志
### 📅 每次仓库更新,我们都会在这里发布最新的Release。请注意,这个仓库只有一个Release,所以你总是能在这里找到最新的版本。
### 📖介绍已经以MD的形式附在插件包中,可以使用文本编辑器打开。更推荐你直接在仓库主页中的[插件列表](https://github.com/UnrealMultiple/TShockPlugin?tab=readme-ov-file#%E5%B7%B2%E6%94%B6%E9%9B%86%E6%8F%92%E4%BB%B6),点击插件名跳转。
### 📦 你可以在页面的`最底部↓↓↓`找到插件包的下载链接。下载完成后,你需要使用`ZIP压缩工具`进行解压。
> [!CAUTION]
>**请你`仔细`地阅读`上面的说明`,不要到处问`插件怎么用`、`ZIP如何解压`**
<details>
<summary>更新日志</summary>
${{steps.external_changelog_second.outputs.changelog}}
</details>
artifacts: |
bin/Plugins.zip
allowUpdates: true
removeArtifacts: true