-
Notifications
You must be signed in to change notification settings - Fork 128
291 lines (260 loc) · 11.5 KB
/
Copy pathrelease.yml
File metadata and controls
291 lines (260 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
name: Release package
on:
push:
tags:
- 'ctex-v*'
- 'xeCJK-v*'
- 'CJKpunct-v*'
- 'zhnumber-v*'
- 'xCJK2uni-v*'
- 'xpinyin-v*'
- 'zhmetrics-v*'
- 'zhmetrics-uptex-v*'
- 'zhspacing-v*'
- 'zhlineskip-v*'
permissions:
contents: write
actions: read
env:
NOTO_SANS_URL: https://github.com/notofonts/noto-cjk/releases/download/Sans2.004/03_NotoSansCJK-OTC.zip
NOTO_SERIF_URL: https://github.com/notofonts/noto-cjk/releases/download/Serif2.002/04_NotoSerifCJKOTC.zip
# 跟 test.yml 顶层 env 保持一致, 复用 PR #901 weekly bypass cache.
TL_VERSION: '2026'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Parse tag
id: parse
run: |
TAG="${GITHUB_REF_NAME}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
case "${TAG}" in
ctex-v*)
echo "pkg=ctex" >> "$GITHUB_OUTPUT"
echo "dir=ctex" >> "$GITHUB_OUTPUT"
echo "module=ctex" >> "$GITHUB_OUTPUT"
echo "dtx=ctex.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#ctex-v}" >> "$GITHUB_OUTPUT"
;;
xeCJK-v*)
echo "pkg=xeCJK" >> "$GITHUB_OUTPUT"
echo "dir=xeCJK" >> "$GITHUB_OUTPUT"
echo "module=xecjk" >> "$GITHUB_OUTPUT"
echo "dtx=xeCJK.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#xeCJK-v}" >> "$GITHUB_OUTPUT"
;;
CJKpunct-v*)
echo "pkg=CJKpunct" >> "$GITHUB_OUTPUT"
echo "dir=CJKpunct" >> "$GITHUB_OUTPUT"
echo "module=cjkpunct" >> "$GITHUB_OUTPUT"
echo "dtx=CJKpunct.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#CJKpunct-v}" >> "$GITHUB_OUTPUT"
;;
zhnumber-v*)
echo "pkg=zhnumber" >> "$GITHUB_OUTPUT"
echo "dir=zhnumber" >> "$GITHUB_OUTPUT"
echo "module=zhnumber" >> "$GITHUB_OUTPUT"
echo "dtx=zhnumber.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#zhnumber-v}" >> "$GITHUB_OUTPUT"
;;
xCJK2uni-v*)
echo "pkg=xCJK2uni" >> "$GITHUB_OUTPUT"
echo "dir=xCJK2uni" >> "$GITHUB_OUTPUT"
echo "module=xcjk2uni" >> "$GITHUB_OUTPUT"
echo "dtx=xCJK2uni.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#xCJK2uni-v}" >> "$GITHUB_OUTPUT"
;;
xpinyin-v*)
echo "pkg=xpinyin" >> "$GITHUB_OUTPUT"
echo "dir=xpinyin" >> "$GITHUB_OUTPUT"
echo "module=xpinyin" >> "$GITHUB_OUTPUT"
echo "dtx=xpinyin.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#xpinyin-v}" >> "$GITHUB_OUTPUT"
;;
zhmetrics-uptex-v*)
echo "pkg=zhmetrics-uptex" >> "$GITHUB_OUTPUT"
echo "dir=zhmetrics-uptex" >> "$GITHUB_OUTPUT"
echo "module=zhmetrics-uptex" >> "$GITHUB_OUTPUT"
echo "dtx=" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#zhmetrics-uptex-v}" >> "$GITHUB_OUTPUT"
;;
zhmetrics-v*)
echo "pkg=zhmetrics" >> "$GITHUB_OUTPUT"
echo "dir=zhmetrics" >> "$GITHUB_OUTPUT"
echo "module=zhmcjk" >> "$GITHUB_OUTPUT"
echo "dtx=zhmCJK.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#zhmetrics-v}" >> "$GITHUB_OUTPUT"
;;
zhspacing-v*)
echo "pkg=zhspacing" >> "$GITHUB_OUTPUT"
echo "dir=zhspacing" >> "$GITHUB_OUTPUT"
echo "module=zhspacing" >> "$GITHUB_OUTPUT"
echo "dtx=" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#zhspacing-v}" >> "$GITHUB_OUTPUT"
;;
zhlineskip-v*)
echo "pkg=zhlineskip" >> "$GITHUB_OUTPUT"
echo "dir=zhlineskip" >> "$GITHUB_OUTPUT"
echo "module=zhlineskip" >> "$GITHUB_OUTPUT"
echo "dtx=zhlineskip.dtx" >> "$GITHUB_OUTPUT"
echo "ver=${TAG#zhlineskip-v}" >> "$GITHUB_OUTPUT"
;;
*)
echo "::error::Unknown tag format: ${TAG}"
exit 1
;;
esac
# PR #901 weekly bypass cache, 跟 test.yml 的 caller / warmup-tl 共享同
# 一个 key (tl-bypass-Linux-2026-<ISO 周>). Schedule 每周一 12:00 UTC
# 跑 test.yml warmup-tl 刷新这个 cache, 周内打 release tag 触发本工作流
# 时直接 cache hit, 跳过 setup-texlive-action (~70s → ~10s restore).
- name: Compute TL cache week
id: tlcache
run: |
week="$(TZ=UTC date +'%G-W%V')"
echo "week=${week}" >> "$GITHUB_OUTPUT"
echo "TL cache week: ${week}"
- name: TL bypass cache (restore)
id: bypass-cache
uses: actions/cache@v6
with:
path: ${{ runner.temp }}/setup-texlive-action/${{ env.TL_VERSION }}
# key 含 weekly + tl_packages hash. 见 test.yml warmup-tl 同款 key 注释.
key: tl-bypass-${{ runner.os }}-${{ env.TL_VERSION }}-${{ steps.tlcache.outputs.week }}-${{ hashFiles('.github/tl_packages') }}
# cache hit fast path: export PATH + sanity check. 失败时 continue-on-error
# 让下面 setup-texlive fallback 接管 (cache 损坏 / 极少). Linux runner 上
# tlmgr 直接可调用, 不需要 tlmgr.bat hack.
- name: Export PATH (cache hit fast path)
id: export-path
if: steps.bypass-cache.outputs.cache-hit == 'true'
continue-on-error: true
run: |
TL_BIN="${{ runner.temp }}/setup-texlive-action/${{ env.TL_VERSION }}/bin/x86_64-linux"
echo "$TL_BIN" >> "$GITHUB_PATH"
echo "Added to PATH: $TL_BIN"
"$TL_BIN/tlmgr" version
- name: Install TeX Live (fallback, cache miss or corrupt)
if: steps.bypass-cache.outputs.cache-hit != 'true' || steps.export-path.outcome == 'failure'
timeout-minutes: 30
uses: TeX-Live/setup-texlive-action@v4
with:
version: ${{ env.TL_VERSION }}
package-file: .github/tl_packages
repository: https://ctan.math.illinois.edu/systems/texlive/tlnet
update-all-packages: true
# 关闭 setup-texlive 内部 cache, 我们自己用 bypass-cache.
cache: false
- name: Install zhmakeindex
run: |
ZHMK_VERSION=$(gh api repos/Liam0205/zhmakeindex/releases/latest --jq '.tag_name')
ZHMK_URL="https://github.com/Liam0205/zhmakeindex/releases/download/${ZHMK_VERSION}/zhmakeindex_${ZHMK_VERSION#v}_linux_amd64.tar.gz"
curl -fsSL "$ZHMK_URL" | tar xz -C /usr/local/bin zhmakeindex
zhmakeindex >/dev/null 2>&1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install CJK fonts
run: |
sudo apt-get install -y --no-install-recommends fonts-freefont-ttf
HANAMINB_URL="https://github.com/googlefonts/chinese/raw/gh-pages/fonts/HanaMin/HanaMinB.ttf"
NOTO_SYMBOLS2_URL="https://github.com/notofonts/symbols/releases/download/NotoSansSymbols2-v2.008/NotoSansSymbols2-v2.008.zip"
curl -LO ${{ env.NOTO_SANS_URL }}
curl -LO ${{ env.NOTO_SERIF_URL }}
curl -fsSL -o HanaMinB.ttf "$HANAMINB_URL"
curl -LO "$NOTO_SYMBOLS2_URL"
sudo mkdir -p /usr/share/fonts/truetype
for f in *OTC.zip; do unzip -ojd /usr/share/fonts/truetype "$f" "*.ttc"; done
for f in NotoSansSymbols2-*.zip; do unzip -ojd /usr/share/fonts/truetype "$f" "*.ttf"; done
cp HanaMinB.ttf /usr/share/fonts/truetype/
fc-cache -f
- name: Download Unihan data (xeCJK)
if: steps.parse.outputs.pkg == 'xeCJK'
run: curl -fsSL -o support/Unihan.zip "https://www.unicode.org/Public/UNIDATA/Unihan.zip"
- name: Build CTAN zip
working-directory: ./${{ steps.parse.outputs.dir }}
run: l3build ctan
- name: Prepare release asset
run: |
MODULE="${{ steps.parse.outputs.module }}"
VER="${{ steps.parse.outputs.ver }}"
SHORT_SHA=$(git rev-parse --short HEAD)
ASSET="${MODULE}-v${VER}-${SHORT_SHA}.zip"
mv "${{ steps.parse.outputs.dir }}/${MODULE}-ctan.zip" "${ASSET}"
echo "asset=${ASSET}" >> "$GITHUB_ENV"
- name: Generate release notes
run: |
PKG="${{ steps.parse.outputs.pkg }}"
DIR="${{ steps.parse.outputs.dir }}"
DTX="${{ steps.parse.outputs.dtx }}"
VER="${{ steps.parse.outputs.ver }}"
TAG="${{ steps.parse.outputs.tag }}"
NOTES_FILE="release-notes.md"
# RC tags (e.g. 3.10.1-rc1, 3.10.1-rc2) share the same \changes entries
# as the base version (3.10.1), since RCs are pre-release builds of
# the same upcoming release. Strip the -rcN / -pre / -alpha / -beta
# suffix to look up \changes against the base version.
BASE_VER=$(printf '%s' "${VER}" | sed -E 's/-(rc[0-9]+|pre[0-9]*|alpha[0-9]*|beta[0-9]*)$//')
# Try extracting from \changes entries. 共用 scripts/extract-changes.py
# 与 release-ctan-upload.yml 一致, 防 \changes → markdown 的清洗规则
# 在两个 workflow 间漂移.
if grep -q "\\\\changes{v${BASE_VER}}" "${DIR}/${DTX}" 2>/dev/null; then
python3 scripts/extract-changes.py "${DIR}/${DTX}" "v${BASE_VER}" > "${NOTES_FILE}"
fi
# Fallback: use git log between previous tag and current tag
if [ ! -s "${NOTES_FILE}" ]; then
PREV_TAG=$(git tag -l "${PKG}-v*" --sort=-version:refname | sed -n '2p')
if [ -n "${PREV_TAG}" ]; then
git log --oneline "${PREV_TAG}..${TAG}" -- "${DIR}/" \
| grep -v -E "^[a-f0-9]+ (chore|docs|Merge)" \
| sed 's/^[a-f0-9]* /- /' > "${NOTES_FILE}"
fi
fi
# Final fallback
if [ ! -s "${NOTES_FILE}" ]; then
echo "Release ${PKG} v${VER}" > "${NOTES_FILE}"
fi
echo "--- Release Notes ---"
cat "${NOTES_FILE}"
- name: Wait for test CI to pass
run: |
SHA="${{ github.sha }}"
echo "Waiting for 'ctex-kit test' to pass on ${SHA:0:8}..."
for i in $(seq 1 120); do
RESULT=$(gh api \
"repos/${{ github.repository }}/actions/workflows/test.yml/runs?head_sha=${SHA}&per_page=1" \
--jq 'if (.workflow_runs | length) == 0 then "none"
else .workflow_runs[0] | "\(.status);\(.conclusion)" end') || RESULT=""
if [ -z "$RESULT" ] || [ "$RESULT" = "none" ]; then
echo " No test run found yet, retrying... (attempt ${i}/60)"
sleep 30
continue
fi
STATUS="${RESULT%%;*}"
CONCLUSION="${RESULT##*;}"
if [ "$CONCLUSION" = "success" ]; then
echo "Test CI passed!"
exit 0
elif [ "$STATUS" = "completed" ]; then
echo "::error::Test CI finished with: ${CONCLUSION}"
exit 1
fi
echo " Test CI status: ${STATUS}, waiting... (attempt ${i}/120)"
sleep 30
done
echo "::error::Timeout after 60 minutes waiting for test CI"
exit 1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
run: |
gh release delete "${{ steps.parse.outputs.tag }}" --yes 2>/dev/null || true
gh release create "${{ steps.parse.outputs.tag }}" \
"${{ env.asset }}" \
--prerelease \
--title "${{ steps.parse.outputs.pkg }} v${{ steps.parse.outputs.ver }}" \
--notes-file release-notes.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}