forked from arch1t3cht/Aegisub
-
Notifications
You must be signed in to change notification settings - Fork 3
261 lines (227 loc) · 11.6 KB
/
Copy pathci.yml
File metadata and controls
261 lines (227 loc) · 11.6 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
name: Aegisub CI
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
subproject:
description: '需更新的子项目名称,多个用逗号分隔 (如 ffms2, vapoursynth)'
required: false
default: ''
subproject_version:
description: '子项目目标分支/标签/提交,多个用逗号分隔,与子项目一一对应 (默认 main)'
required: false
default: 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TZ: Asia/Shanghai
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: Windows MSVC Release
os: windows-latest
msvc: true
buildtype: release
args: >-
-Ddefault_library=static
--force-fallback-for=zlib,harfbuzz,freetype2,fribidi,libpng
-Dfallback_nasm=true
-Dfreetype2:harfbuzz=disabled
-Dharfbuzz:freetype=disabled
-Dharfbuzz:cairo=disabled
-Dharfbuzz:glib=disabled
-Dharfbuzz:gobject=disabled
-Dharfbuzz:tests=disabled
-Dharfbuzz:docs=disabled
-Dharfbuzz:icu=disabled
-Dfribidi:tests=false
-Dfribidi:docs=false
-Dlibass:fontconfig=disabled
-Dffmpeg:libdav1d=enabled
-Davisynth=enabled
-Dbestsource=enabled
-Dvapoursynth=enabled
steps:
- name: set current date
id: set_date
run: |
date=$(date -d '+8 hour' +'%Y-%m')
echo "date=$date" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/checkout@v6
with:
fetch-depth: '0'
persist-credentials: false
- name: cache Aegisub build
id: Aegisub_cache
uses: actions/cache@v5
with:
path: |
D:\a\Aegisub\Aegisub\build
D:\a\Aegisub\Aegisub\subprojects
key: Aegisub-build-${{ steps.set_date.outputs.date }}
restore-keys: Aegisub-build-
- name: delete git_version.h
run: |
ls -lah /d/a/Aegisub/Aegisub/subprojects
rm -f /d/a/Aegisub/Aegisub/build/git_version.h
shell: bash
- name: Update subproject
if: github.event.inputs.subproject != ''
run: |
IFS=',' read -ra SPS <<< "${{ github.event.inputs.subproject }}"
IFS=',' read -ra VERS <<< "${{ github.event.inputs.subproject_version }}"
DEFAULT_VER="main"
for i in "${!SPS[@]}"; do
SP="$(echo "${SPS[$i]}" | xargs)"
[ -z "$SP" ] && continue
SP_VER="$(echo "${VERS[$i]:-$DEFAULT_VER}" | xargs)"
[ -z "$SP_VER" ] && SP_VER="$DEFAULT_VER"
SP_DIR="subprojects/${SP}"
echo "Updating subproject: ${SP} -> ${SP_VER}"
if [ ! -d "$SP_DIR" ]; then
echo "ERROR: subprojects/${SP} not found"
exit 1
fi
pushd "$SP_DIR"
if [ ! -d .git ]; then
echo "ERROR: ${SP_DIR} is not a git repository"
popd
exit 1
fi
# 获取当前 remote URL 以避免反复 config
REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "")
if [ -n "$REMOTE_URL" ]; then
echo "Fetching from $REMOTE_URL"
git fetch origin --tags --force
else
echo "WARNING: no origin remote, trying default URL"
git fetch --tags --force
fi
git checkout "$SP_VER" || {
echo "Checkout failed, trying fetch + checkout"
git fetch origin "$SP_VER" --force
git checkout FETCH_HEAD -B "$SP_VER"
}
git reset --hard "$SP_VER"
echo "Subproject ${SP} updated to $(git rev-parse --short HEAD)"
popd
# 清除 meson 子项目构建缓存强制重编
rm -rf build/subprojects/${SP}
done
shell: bash
- name: Reset subproject wrap lock
if: github.event.inputs.subproject != ''
run: |
LOCK_FILE="subprojects/.wraplock"
if [ -f "$LOCK_FILE" ]; then
echo "Removing wrap lock to allow subproject update"
rm -f "$LOCK_FILE"
fi
shell: bash
- uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Setup Meson
run: |
python -m pip install --upgrade pip setuptools
pip install meson
- name: Setup MSVC
if: matrix.config.os == 'windows-latest' && matrix.config.msvc == true
uses: ilammy/msvc-dev-cmd@v1
- name: Install dependencies (Windows)
if: matrix.config.os == 'windows-latest'
run: |
choco install ninja innosetup
$moonscripturl = "https://github.com/leafo/moonscript/releases/download/v0.6.0/moonscript-v0.6.0-windows-x86_64.zip"
mkdir moonscript
Invoke-WebRequest -Uri $moonscripturl -OutFile ".\moonscript\moonscript.zip"
pushd moonscript
7z e moonscript.zip
Get-Location | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
popd
$gettexturl = "https://github.com/mlocati/gettext-iconv-windows/releases/download/v1.0-v1.18-r3/gettext1.0-iconv1.18-static-64.zip"
Invoke-WebRequest -Uri $gettexturl -OutFile ".\gettext.zip"
Expand-Archive ".\gettext.zip" -DestinationPath gettext
pushd gettext/bin
Get-Location | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
popd
- name: Configure
run: |
$args = @("${{ matrix.config.args }}".Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries))
if ("${{ github.event.inputs.version }}" -ne "") {
$args += "-Dversion=${{ github.event.inputs.version }}"
Write-Host "Using version: ${{ github.event.inputs.version }}"
}
if (Test-Path "build\build.ninja") {
Write-Host "Reconfiguring cached build directory"
meson setup --reconfigure build @args -Dbuildtype=${{ matrix.config.buildtype }}
} else {
Write-Host "Configuring fresh build directory"
meson setup build @args -Dbuildtype=${{ matrix.config.buildtype }}
}
meson configure build
shell: pwsh
- name: Build
run: meson compile -C build -j(Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors
- name: Run test
run: meson test -C build --verbose
# Windows artifacts
- name: Generate Windows installer
if: matrix.config.os == 'windows-latest'
env:
AEGISUB_VERSION: ${{ github.event.inputs.version }}
run:
meson compile win-installer -C build -j(Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors
- name: Generate Windows portable
if: matrix.config.os == 'windows-latest'
run: meson compile win-portable -C build -j(Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors
- name: set release package
id: set_tag
run: |
version="${{ github.event.inputs.version }}"
if [ -z "$version" ]; then
version=$(date -d '+8 hour' +'%Y-%m-%d-%H%M%S')
fi
echo "tag=$version" >> $GITHUB_OUTPUT
installer_name="Aegisub-${version}-win64-installer.exe"
portable_name="Aegisub-${version}-win64-portable.zip"
echo "installer_name=${installer_name}" >> $GITHUB_OUTPUT
echo "portable_name=${portable_name}" >> $GITHUB_OUTPUT
mv build/Aegisub-${version}.exe "build/${installer_name}"
mv build/aegisub-portable-64.zip "build/${portable_name}"
shell: bash
#- name: Upload artifacts - installer
# uses: actions/upload-artifact@v6
# if: matrix.config.os == 'windows-latest'
# with:
# name: ${{ matrix.config.name }} - installer
# path: build/${{ steps.set_tag.outputs.installer_name }}
# if-no-files-found: error
#
#- name: Upload artifacts - portable
# uses: actions/upload-artifact@v6
# if: matrix.config.os == 'windows-latest'
# with:
# name: ${{ matrix.config.name }} - portable
# path: build/${{ steps.set_tag.outputs.portable_name }}
- name: Cleanup old build artifacts
run: |
keep_installer="build/${{ steps.set_tag.outputs.installer_name }}"
keep_portable="build/${{ steps.set_tag.outputs.portable_name }}"
find build -maxdepth 1 \( -name "*.exe" -o -name "*.zip" \) ! -name "$(basename "$keep_installer")" ! -name "$(basename "$keep_portable")" -exec rm -v {} \;
shell: bash
- name: create Release
uses: ncipollo/release-action@v1.21.0
with:
allowUpdates: true
artifacts: "build/${{ steps.set_tag.outputs.installer_name }},build/${{ steps.set_tag.outputs.portable_name }}"
tag: ${{ steps.set_tag.outputs.tag }}
draft: true