-
Notifications
You must be signed in to change notification settings - Fork 154
312 lines (276 loc) · 9.91 KB
/
install.yml
File metadata and controls
312 lines (276 loc) · 9.91 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
branches:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
workflow_dispatch:
env:
MAA_FRAMEWORK_VERSION: "v5.10.4"
MXU_VERSION: "v2.1.3"
permissions:
contents: write
actions: write
jobs:
meta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: set_tag
run: |
# 检查标签格式
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?$ ]]; then
is_release=true
tag=${GITHUB_REF#refs/tags/}
echo "Release tag format is valid: $tag"
else
is_release=false
# 获取最新的发布标签
tag=$(curl -sX GET "https://api.github.com/repos/${{ github.repository }}/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]')
if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
echo "No valid release tag found, using v0.0.1"
tag="v0.0.1"
fi
tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)")
fi
if [ "$is_release" != "true" ] ; then
prefix=${tag%-*-*}
suffix=${tag#$prefix-}
tag="$prefix-ci.$suffix"
fi
# 检查是否为预发布版本
is_prerelease=false
if [[ $tag =~ .*alpha.* || $tag =~ .*beta.* || $tag =~ .*rc.* || $tag =~ .*dev.* || $tag =~ .*-ci.* || $tag =~ .*preview.* ]]; then
is_prerelease=true
echo "This is a pre-release version"
fi
echo tag=$tag | tee -a $GITHUB_OUTPUT
echo is_release=$is_release | tee -a $GITHUB_OUTPUT
echo is_prerelease=$is_prerelease | tee -a $GITHUB_OUTPUT
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
is_release: ${{ steps.set_tag.outputs.is_release }}
is_prerelease: ${{ steps.set_tag.outputs.is_prerelease }}
windows:
needs: meta
strategy:
matrix:
include:
- arch: x86_64
runner: windows-latest
fail-fast: false
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set platform variables
id: platform
shell: bash
run: |
if [ "${{ matrix.arch }}" = "x86_64" ]; then
echo "tag=x64" >> $GITHUB_OUTPUT
else
echo "tag=arm64" >> $GITHUB_OUTPUT
fi
- name: Download MaaFramework
uses: robinraju/release-downloader@v1
with:
repository: MaaXYZ/MaaFramework
fileName: "MAA-win-${{ matrix.arch }}*"
tag: ${{ env.MAA_FRAMEWORK_VERSION }}
out-file-path: "deps"
extract: true
- name: Download MXU
id: download_mxu
uses: robinraju/release-downloader@v1
with:
repository: MistEO/MXU
fileName: "MXU-win-${{ matrix.arch }}*"
tag: ${{ env.MXU_VERSION }}
out-file-path: "MXU"
extract: true
- name: Clean up MXU archive on Windows
shell: bash
run: |
ARCHIVE_FILE_PATH="${{ fromJson(steps.download_mxu.outputs.downloaded_files)[0] }}"
rm -f "${ARCHIVE_FILE_PATH}"
echo "Archive cleanup command executed for MXU on Windows."
- name: Convert PNG to ICO
if: matrix.arch == 'x86_64'
shell: bash
run: |
# 安装 ImageMagick
choco install imagemagick -y
# 转换 PNG 到 ICO
magick convert assets/logo.png -define icon:auto-resize=256,128,64,48,32,24,16 maante.ico
- name: Modify Windows exe icons
if: matrix.arch == 'x86_64'
shell: bash
run: |
# 下载 rcedit
curl -L https://github.com/electron/rcedit/releases/download/v2.0.0/rcedit-x64.exe -o rcedit.exe
# 修改 MXU 图标(如果存在)
if [ -f "MXU/mxu.exe" ]; then
./rcedit.exe "MXU/mxu.exe" --set-icon "maante.ico"
echo "MXU icon modified successfully"
else
echo "MXU exe not found, skipping icon update."
fi
- name: Setup Embed Python on Windows
shell: bash
run: |
python tools/ci/setup_embed_python.py
- name: Download Python dependencies
shell: bash
run: |
./install/python/python.exe tools/ci/download_deps.py --deps-dir install/deps
- name: Create MXU version
shell: bash
run: |
./install/python/python.exe ./tools/ci/install_mxu.py ${{ needs.meta.outputs.tag }}
cp -rpvn install/python/. install-mxu/python/
if [ -d "install/deps" ]; then
cp -rpvn install/deps/. install-mxu/deps/
fi
- name: Install and patch soundcard
shell: bash
run: |
echo "Installing soundcard into embedded Python..."
./install-mxu/python/python.exe -m pip install \
--no-index \
--find-links install-mxu/deps \
soundcard
echo "Patching soundcard ole32 → ole32.dll..."
./install-mxu/python/python.exe - << 'PYEOF'
import sys, soundcard
from pathlib import Path
p = Path(soundcard.__path__[0]) / 'mediafoundation.py'
c = p.read_text()
if "_ffi.dlopen('ole32')" not in c:
print(f'ERROR: expected ole32 patch target not found in {p}. soundcard may have changed.')
sys.exit(1)
c = c.replace("_ffi.dlopen('ole32')", "_ffi.dlopen('ole32.dll')")
p.write_text(c)
print('Patched:', p)
PYEOF
echo "Removing soundcard wheel from deps to prevent re-install..."
rm -f install-mxu/deps/soundcard-*.whl
- name: Copy MXU files to MXU version
shell: bash
run: |
if [ -d "MXU" ]; then
echo "Copying MXU files to install-mxu directory..."
mkdir -p install-mxu
if [ -f "MXU/mxu.exe" ]; then
cp MXU/mxu.exe install-mxu/MaaNTE.exe
elif [ -f "MXU/mxu" ]; then
cp MXU/mxu install-mxu/MaaNTE
fi
else
echo "MXU directory not found, skipping copy."
fi
- name: Copy custom icons
shell: bash
run: |
# MXU 版本的图标
if [ -f "maante.ico" ]; then
cp maante.ico install-mxu/logo.ico
fi
- uses: actions/upload-artifact@v4
with:
name: MaaNTE-win-${{ matrix.arch }}-${{ needs.meta.outputs.tag }}-MXU
path: "install-mxu"
changelog:
name: Generate changelog
needs: meta
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: .github/cliff.toml
# 正式版:使用 tag-pattern 只匹配正式版标签,包含所有从上一个正式版以来的提交
# 预发布版:正常生成,只包含从上一个标签以来的提交
args: >-
-vv --latest --strip header
${{ needs.meta.outputs.is_prerelease == 'false' && '--tag-pattern "^v[0-9]+\\.[0-9]+\\.[0-9]+$"' || '' }}
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}
release:
if: ${{ needs.meta.outputs.is_release == 'true' }}
needs: [meta, windows, changelog]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: assets
- name: Process and package artifacts
run: |
cd assets
for f in *; do
if [[ $f == *"win"* ]]; then
(cd "$f" && zip -r "../$f.zip" .)
else
echo "Processing Unix artifact: $f"
if [[ -f "$f/MaaPiCli" ]]; then
chmod +x "$f/MaaPiCli"
echo "Set execute permission for $f/MaaPiCli"
fi
find "$f" -type f -name "MFAUpdater*" -exec chmod +x {} \; 2>/dev/null || true
echo "Set execute permission for all MFAUpdater files"
if [[ -f "$f/MaaNTE" ]]; then
chmod +x "$f/MaaNTE"
echo "Set execute permission for $f/MaaNTE"
fi
PYTHON_PATHS=(
"$f/python/bin/python3"
"$f/python/python"
"$f/python/bin/python"
"$f/python/python.exe"
)
for PYTHON_PATH in "${PYTHON_PATHS[@]}"; do
if [[ -f "$PYTHON_PATH" ]]; then
chmod +x "$PYTHON_PATH"
echo "Set execute permission for $PYTHON_PATH"
fi
done
tar -cpzf "$f.tar.gz" -C "$f" .
echo "Created archive with preserved permissions: $f.tar.gz"
fi
done
- uses: softprops/action-gh-release@v2.2.2
with:
files: assets/*
tag_name: ${{ needs.meta.outputs.tag }}
body: ${{ needs.changelog.outputs.release_body }}
draft: false
prerelease: ${{ needs.meta.outputs.is_prerelease == 'true' }}
- name: Trigger MirrorChyanUploading
shell: bash
run: |
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release.yml -f tag=${{ needs.meta.outputs.tag }}
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note.yml -f tag=${{ needs.meta.outputs.tag }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}