-
Notifications
You must be signed in to change notification settings - Fork 36
356 lines (308 loc) · 11.5 KB
/
Copy pathpackage.yml
File metadata and controls
356 lines (308 loc) · 11.5 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
name: XPack Build
on:
workflow_dispatch:
inputs:
manual_version:
description: 'Set version manually (e.g. 1.2.3)'
required: false
default: ''
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-22.04
container: debian:trixie
env:
XMAKE_ROOT: y
DEBIAN_FRONTEND: noninteractive
strategy:
fail-fast: true
steps:
- name: Install Dependencies
run: |
echo 'deb http://deb.debian.org/debian trixie-backports main' > /etc/apt/sources.list.d/backports.list
apt-get update
apt-get install -y \
git \
curl \
7zip \
unzip \
ca-certificates \
build-essential \
devscripts \
debhelper \
ninja-build
apt-get install -y -t trixie-backports xmake
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: git add safe directory
run: git config --global --add safe.directory '*'
- name: Determine Version
id: get_version
run: |
REF_NAME="${{ github.ref }}"
MANUAL_VER="${{ inputs.manual_version }}"
if [ -n "$MANUAL_VER" ]; then
RAW_VERSION="$MANUAL_VER"
elif [[ "$REF_NAME" == refs/tags/* ]]; then
RAW_VERSION=${REF_NAME#refs/tags/}
RAW_VERSION=${RAW_VERSION//\//}
else
RAW_VERSION=$(date +%Y.%m.%d)
fi
if [[ "$RAW_VERSION" == v* ]]; then
CLEAN_VERSION=${RAW_VERSION#v}
else
CLEAN_VERSION="$RAW_VERSION"
fi
echo "VERSION_TAG=$RAW_VERSION" >> $GITHUB_ENV
echo "VERSION_NUM=$CLEAN_VERSION" >> $GITHUB_ENV
echo "Version tag: $RAW_VERSION"
echo "Version num: $CLEAN_VERSION"
- name: set XMAKE_GLOBALDIR
run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV
- name: xmake repo --update
run: xmake repo --update
- name: cache packages from xrepo
uses: actions/cache@v3
with:
path: |
${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: ${{ runner.os }}-xrepo-${{ hashFiles('**/xmake.lua') }}
- name: Fetch xmake deb template
run: |
TEMPLATE_ROOT=.tmp/xpack-deb-template/debian
BASE_URL=https://raw.githubusercontent.com/xmake-io/xmake/v3.0.8/xmake/scripts/xpack/deb/debian
mkdir -p "$TEMPLATE_ROOT/source"
curl -fsSL "$BASE_URL/README.Debian" -o "$TEMPLATE_ROOT/README.Debian"
curl -fsSL "$BASE_URL/changelog" -o "$TEMPLATE_ROOT/changelog"
curl -fsSL "$BASE_URL/control" -o "$TEMPLATE_ROOT/control"
curl -fsSL "$BASE_URL/copyright" -o "$TEMPLATE_ROOT/copyright"
curl -fsSL "$BASE_URL/rules" -o "$TEMPLATE_ROOT/rules"
curl -fsSL "$BASE_URL/source/format" -o "$TEMPLATE_ROOT/source/format"
sed -i '2a export XMAKE_ROOT=y' "$TEMPLATE_ROOT/rules"
chmod +x "$TEMPLATE_ROOT/rules"
- name: Config and Build
run: |
sed -i 's|"deb", "rpm", "srpm"|"deb"|g' xmake.lua
sed -i '/set_formats("deb")/a\ set_specfile(".tmp/xpack-deb-template/debian")' xmake.lua
sed -i 's|set_default(false) -- repl-anchor|set_default(true)|g' xmake.lua
xmake config -vyD -o tmp/build --repl=true
xmake build goldfish
- name: Build function doc index
run: ./bin/gf doc --build-json
- name: Package
run: xmake pack -f deb -vyD goldfish
- name: Create summary table
run: |
echo "## 生成的包文件" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| 类型 | 文件名 | 大小 | 版本 | 架构 |" >> $GITHUB_STEP_SUMMARY
echo "|------|--------|------|------|------|" >> $GITHUB_STEP_SUMMARY
DIR="tmp/build/xpack/goldfish"
# Debian 包
for deb in "$DIR"/*.deb; do
if [ -f "$deb" ]; then
size=$(ls -lh "$deb" | awk '{print $5}')
info=$(dpkg-deb -f "$deb" 2>/dev/null)
pkg=$(echo "$info" | grep "^Package" | cut -d' ' -f2- || echo "")
ver=$(echo "$info" | grep "^Version" | cut -d' ' -f2- || echo "")
arch=$(echo "$info" | grep "^Architecture" | cut -d' ' -f2- || echo "")
echo "| Debian | \`$(basename "$deb")\` | $size | $ver | $arch |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "*目录: \`$DIR\`*" >> $GITHUB_STEP_SUMMARY
- name: Upload all package artifacts
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch'
with:
name: goldfish-packages
path: tmp/build/xpack/goldfish/*.deb
retention-days: 30
if-no-files-found: error
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
files: |
tmp/build/xpack/goldfish/*.deb
package-windows-zip:
runs-on: windows-2025
env:
XMAKE_GLOBALDIR: ${{ github.workspace }}/.xmake-global
steps:
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: v3.0.8
- name: git crlf
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Determine Version
shell: pwsh
run: |
$refName = "${{ github.ref }}"
$manualVer = "${{ inputs.manual_version }}"
if ($manualVer) {
$rawVersion = $manualVer
} elseif ($refName -match '^refs/tags/') {
$rawVersion = $refName -replace '^refs/tags/', ''
$rawVersion = $rawVersion -replace '/', ''
} else {
$rawVersion = Get-Date -Format "yyyy.MM.dd"
}
if ($rawVersion -match '^v') {
$cleanVersion = $rawVersion.Substring(1)
} else {
$cleanVersion = $rawVersion
}
Add-Content -Path $env:GITHUB_ENV -Value "VERSION_TAG=$rawVersion"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION_NUM=$cleanVersion"
Write-Host "Version tag: $rawVersion"
Write-Host "Version num: $cleanVersion"
- name: cache packages from xrepo
uses: actions/cache@v4
with:
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: ${{ runner.os }}-xrepo-${{ hashFiles('**/xmake.lua') }}
- name: xmake repo --update
run: xmake repo --update
- name: Config and Build
run: |
xmake config -vyD -o tmp/build -m release --repl=true --yes
xmake build goldfish
- name: Build function doc index
shell: pwsh
run: .\bin\gf.exe doc --build-json
- name: Package
run: xmake pack -vyD goldfish
- name: Create summary table
shell: pwsh
run: |
$dir = "tmp/build/xpack/goldfish"
$files = Get-ChildItem -Path $dir -Recurse -File
$size = "{0:N2} MiB" -f (($files | Measure-Object -Property Length -Sum).Sum / 1MB)
$fileCount = ($files | Measure-Object).Count
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## Generated package files"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "| Type | Path | Size | Files |"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "|------|------|------|-------|"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "| Windows artifact | ``$dir`` | $size | $fileCount |"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "*目录: ``$dir``*"
- name: Upload Windows package artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch'
with:
name: goldfish-windows-package
path: tmp/build/xpack/goldfish/*.zip
retention-days: 30
if-no-files-found: error
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
files: |
tmp/build/xpack/goldfish/*.zip
package-macos:
# GitHub 已退役 Intel macOS runner(macos-13 于 2025-12 下线),
# 当前所有 macOS runner 均为 Apple Silicon (arm64),故只产出 arm64 包。
# Intel Mac 用户走源码编译(Homebrew formula 回退到 build)。
runs-on: macos-14
env:
XMAKE_GLOBALDIR: ${{ github.workspace }}/.xmake-global
steps:
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: v3.0.8
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Determine Version
run: |
REF_NAME="${{ github.ref }}"
MANUAL_VER="${{ inputs.manual_version }}"
if [ -n "$MANUAL_VER" ]; then
RAW_VERSION="$MANUAL_VER"
elif [[ "$REF_NAME" == refs/tags/* ]]; then
RAW_VERSION=${REF_NAME#refs/tags/}
RAW_VERSION=${RAW_VERSION//\//}
else
RAW_VERSION=$(date +%Y.%m.%d)
fi
if [[ "$RAW_VERSION" == v* ]]; then
CLEAN_VERSION=${RAW_VERSION#v}
else
CLEAN_VERSION="$RAW_VERSION"
fi
echo "VERSION_TAG=$RAW_VERSION" >> $GITHUB_ENV
echo "VERSION_NUM=$CLEAN_VERSION" >> $GITHUB_ENV
echo "Version tag: $RAW_VERSION"
echo "Version num: $CLEAN_VERSION"
- name: cache packages from xrepo
uses: actions/cache@v4
with:
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: macos-14-xrepo-${{ hashFiles('**/xmake.lua') }}
- name: xmake repo --update
run: xmake repo --update
- name: Config and Build
run: |
xmake config -vyD -o tmp/build -m release --repl=true --yes
xmake build goldfish
- name: Build function doc index
run: ./bin/gf doc --build-json
- name: Package
run: xmake pack -vyD goldfish
- name: Verify package arch
run: |
# xmake xpack 用宿主机 arch;强制校验产物文件名里带 arm64,
# 防止 runner 实际架构与预期不符时悄悄产出错误命名的包。
DIR="tmp/build/xpack/goldfish"
echo "Expected arch: arm64"
ls -lh "$DIR"/*.tar.gz
if ! ls "$DIR"/*-arm64-*.tar.gz >/dev/null 2>&1; then
echo "::error::产物文件名里没找到 arm64,检查 xmake 是否正确识别了架构"
exit 1
fi
- name: Create summary table
run: |
DIR="tmp/build/xpack/goldfish"
echo "## macOS arm64 package" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| 文件名 | 大小 |" >> $GITHUB_STEP_SUMMARY
echo "|--------|------|" >> $GITHUB_STEP_SUMMARY
for pkg in "$DIR"/*.tar.gz; do
if [ -f "$pkg" ]; then
size=$(ls -lh "$pkg" | awk '{print $5}')
echo "| \`$(basename "$pkg")\` | $size |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "*目录: \`$DIR\`*" >> $GITHUB_STEP_SUMMARY
- name: Upload macOS package artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch'
with:
name: goldfish-macos-arm64-package
path: tmp/build/xpack/goldfish/*.tar.gz
retention-days: 30
if-no-files-found: error
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
files: |
tmp/build/xpack/goldfish/*.tar.gz