1- # 在 tag 推送时为 Linux x86_64 构建 AppImage 并附加到对应 release。
1+ # 从独立维护的 Linux 分支构建 x86_64 AppImage,并附加到已存在的共享 release。
22#
3- # 流程:release.sh(Mac)构建 macOS 双变体 + 建 release + 推 tag → 本 workflow 被 tag 触发 →
4- # 在 swift:6.0-jammy 容器(glibc 2.35,覆盖 2022+ 发行版)里 checkout normal(含 Linux 源码)
5- # → 跑 scripts/build-appimage.sh → 把 TokenClock-x86_64.AppImage + .sha256 附加到该 release。
6- # 与 release.sh 之间是异步的(AppImage 约在发版后 5–10 分钟出现);softprops/action-gh-release
7- # 的 create-or-update 语义避免「release 还没建好」的竞态。
3+ # linux-v1.4.0 映射到共享 release v1.4.0。构建源码和 workflow 都来自这个不可变的
4+ # Linux tag,因此 Linux catalog、路径和 GTK 界面无需并入 macOS normal/main 分支。
85name : linux-appimage
96
107on :
118 push :
12- tags : ['v*']
13- workflow_dispatch : # 允许手动触发,便于在不打 tag 时验证
9+ tags : ['linux-v*']
1410
1511permissions :
1612 contents : write # 附加资产到 release 需要
@@ -21,10 +17,39 @@ jobs:
2117 container :
2218 image : swift:6.0-jammy
2319 steps :
24- - name : Checkout normal branch ( Linux sources + build script)
20+ - name : Checkout tagged Linux source
2521 uses : actions/checkout@v4
26- with :
27- ref : normal
22+
23+ - name : Map Linux tag to shared release tag
24+ id : release
25+ shell : bash
26+ run : |
27+ linux_tag='${{ github.ref_name }}'
28+ if [[ ! "$linux_tag" =~ ^linux-(v[0-9].*)$ ]]; then
29+ echo "Unexpected Linux tag: $linux_tag" >&2
30+ exit 1
31+ fi
32+ echo "tag=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
33+
34+ - name : Require an existing shared release
35+ shell : bash
36+ env :
37+ GH_TOKEN : ${{ github.token }}
38+ RELEASE_TAG : ${{ steps.release.outputs.tag }}
39+ run : |
40+ encoded_tag="${RELEASE_TAG//\//%2F}"
41+ api="https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$encoded_tag"
42+ for attempt in $(seq 1 20); do
43+ if curl -fsS \
44+ -H "Authorization: Bearer $GH_TOKEN" \
45+ -H "Accept: application/vnd.github+json" \
46+ "$api" >/dev/null; then
47+ exit 0
48+ fi
49+ sleep 15
50+ done
51+ echo "Shared release $RELEASE_TAG does not exist" >&2
52+ exit 1
2853
2954 - name : Build AppImage
3055 run : |
3459 - name : Attach AppImage + SHA256 to the release
3560 uses : softprops/action-gh-release@v2
3661 with :
37- tag_name : ${{ github.ref_name }}
62+ tag_name : ${{ steps.release.outputs.tag }}
63+ fail_on_unmatched_files : true
3864 files : |
3965 TokenClock-x86_64.AppImage
4066 TokenClock-x86_64.AppImage.sha256
0 commit comments