Skip to content

Commit ba40ce7

Browse files
committed
refactor(ci): 发布链去除 artifact 中转,build job 直接发布(配额限制)
1 parent 5a92010 commit ba40ce7

1 file changed

Lines changed: 45 additions & 48 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: Release Tauri App
22

3-
# 由 semantic-release 创建的 v* tag 触发:构建 Tauri 安装包并附加到对应 Release
3+
# 由 v* tag 触发:构建 Tauri 安装包并发布到 GitHub Release + 自建服务器 + OSS
44
# 适配说明(2026-08-21):原 Electron 发布链适配为 Tauri——
55
# electron-builder → cargo tauri build(nsis);更新源 latest.yml → Tauri 安装包直链
66
# (updater 端点未启用,TODO:启用 tauri.conf updater 后补 latest.json 同步)
7+
# 2026-08-27 重构:build 完成后直接发布(gh release + SCP + OSS),
8+
# 移除 artifact 中转——artifact 存储配额(500MB)无法容纳 349MB 安装包多次构建
79
on:
810
push:
911
tags: ['v*']
@@ -66,8 +68,10 @@ jobs:
6668
build:
6769
needs: lint-test
6870
runs-on: windows-latest
69-
# Tauri 打包 + 上传 + 服务器同步:上限 90 分钟
71+
# Tauri 打包 + 发布(GitHub Release + 服务器 + OSS):上限 90 分钟
7072
timeout-minutes: 90
73+
env:
74+
HAS_ALIYUN_AK: ${{ secrets.ALIYUN_ACCESS_KEY_ID != '' }}
7175
steps:
7276
- uses: actions/checkout@v4
7377
- uses: actions/setup-node@v4
@@ -106,41 +110,44 @@ jobs:
106110
env:
107111
ORT_LIB_LOCATION: ${{ github.workspace }}/app/src-tauri/ort/ci
108112
ORT_PREFER_DYNAMIC_LINK: "1"
109-
- uses: actions/upload-artifact@v4
110-
with:
111-
name: release-windows-latest
112-
path: |
113-
app/src-tauri/target/release/bundle/nsis/*.exe
114-
115-
release:
116-
needs: build
117-
runs-on: ubuntu-latest
118-
timeout-minutes: 30
119-
env:
120-
HAS_ALIYUN_AK: ${{ secrets.ALIYUN_ACCESS_KEY_ID != '' }}
121-
steps:
122-
- uses: actions/download-artifact@v4
123-
with:
124-
pattern: release-*
125-
- uses: softprops/action-gh-release@v2
126-
with:
127-
files: release-*/*
128113

129114
# ---------------------------------------------------------------
130-
# 同步安装包至自建服务器(国内主下载源;服务器连接继承自原项目)
115+
# 发布阶段(不再走 artifact 中转:配额 500MB 装不下 349MB 安装包多次构建)
131116
# ---------------------------------------------------------------
132-
- name: Generate latest.json for download page
117+
- name: Collect installer and generate latest.json
133118
id: meta
119+
shell: bash
134120
run: |
135-
FILE=$(ls release-windows-latest/*.exe | head -1 | xargs basename)
136-
SIZE=$(stat -c%s "release-windows-latest/$FILE")
137-
SHA256=$(sha256sum "release-windows-latest/$FILE" | awk '{print $1}')
121+
mkdir -p release-files
122+
cp app/src-tauri/target/release/bundle/nsis/*.exe release-files/
123+
FILE=$(ls release-files/*.exe | head -1 | xargs basename)
124+
SIZE=$(stat -c%s "release-files/$FILE")
125+
SHA256=$(sha256sum "release-files/$FILE" | awk '{print $1}')
138126
DATE=$(date -u +%F)
139127
printf '{"version":"%s","fileName":"%s","size":%s,"sha256":"%s","releaseDate":"%s"}\n' \
140-
"${{ github.ref_name }}" "$FILE" "$SIZE" "$SHA256" "$DATE" > release-windows-latest/latest.json
141-
cat release-windows-latest/latest.json
128+
"${{ github.ref_name }}" "$FILE" "$SIZE" "$SHA256" "$DATE" > release-files/latest.json
129+
cat release-files/latest.json
142130
echo "file=$FILE" >> "$GITHUB_OUTPUT"
131+
SIZE_MB=$(awk "BEGIN {printf \"%.2f\", $SIZE / 1048576}")
132+
echo "📦 $FILE: ${SIZE_MB} MB"
133+
if [ "$SIZE" -gt 419430400 ]; then
134+
echo "::warning::${FILE} 超过 400MB,请检查是否误打包大文件(模型不入库)"
135+
fi
136+
137+
- name: Upload installer to GitHub Release
138+
shell: bash
139+
env:
140+
GH_TOKEN: ${{ github.token }}
141+
TAG: ${{ github.ref_name }}
142+
FILE_NAME: ${{ steps.meta.outputs.file }}
143+
run: |
144+
# tag 触发的 release 可能尚不存在(semantic-release 未参与时),不存在则创建
145+
gh release view "$TAG" --json id >/dev/null 2>&1 || gh release create "$TAG" --title "$TAG" --notes "熵减 $TAG" --generate-notes
146+
gh release upload "$TAG" "release-files/$FILE_NAME" --clobber
143147
148+
# ---------------------------------------------------------------
149+
# 同步安装包至自建服务器(国内主下载源;服务器连接继承自原项目)
150+
# ---------------------------------------------------------------
144151
- name: Ensure downloads directory on server
145152
uses: appleboy/ssh-action@v1
146153
with:
@@ -155,7 +162,7 @@ jobs:
155162
host: ${{ secrets.SERVER_HOST }}
156163
username: ${{ secrets.SERVER_USER }}
157164
key: ${{ secrets.SSH_PRIVATE_KEY }}
158-
source: release-windows-latest/*.exe
165+
source: release-files/*.exe
159166
target: /opt/Entropydecrease/downloads
160167
strip_components: 1
161168

@@ -165,7 +172,7 @@ jobs:
165172
host: ${{ secrets.SERVER_HOST }}
166173
username: ${{ secrets.SERVER_USER }}
167174
key: ${{ secrets.SSH_PRIVATE_KEY }}
168-
source: release-windows-latest/latest.json
175+
source: release-files/latest.json
169176
target: /opt/Entropydecrease/downloads
170177
strip_components: 1
171178

@@ -174,6 +181,7 @@ jobs:
174181
# ---------------------------------------------------------------
175182
- name: Upload to OSS (CDN origin)
176183
if: env.HAS_ALIYUN_AK == 'true'
184+
shell: bash
177185
env:
178186
AK_ID: ${{ secrets.ALIYUN_ACCESS_KEY_ID }}
179187
AK_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
@@ -182,14 +190,15 @@ jobs:
182190
run: |
183191
set -eo pipefail
184192
OSS_ENDPOINT="${OSS_ENDPOINT_IN:-oss-cn-hangzhou.aliyuncs.com}"
185-
curl -sL https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o /tmp/aliyun.tgz
186-
tar -xzf /tmp/aliyun.tgz -C /tmp
187-
/tmp/aliyun configure set --profile ossci --mode AK --region cn-hangzhou \
193+
# build job 为 windows runner,需下载 Windows 版 aliyun CLI
194+
curl -sL https://aliyuncli.alicdn.com/aliyun-cli-windows-latest-amd64.zip -o /tmp/aliyun.zip
195+
unzip -q /tmp/aliyun.zip -d /tmp/aliyun
196+
/tmp/aliyun/aliyun.exe configure set --profile ossci --mode AK --region cn-hangzhou \
188197
--access-key-id "$AK_ID" --access-key-secret "$AK_SECRET"
189-
/tmp/aliyun oss cp "release-windows-latest/$FILE_NAME" \
198+
/tmp/aliyun/aliyun.exe oss cp "release-files/$FILE_NAME" \
190199
"oss://${{ secrets.OSS_BUCKET }}/downloads/$FILE_NAME" \
191200
--force -e "$OSS_ENDPOINT" --profile ossci
192-
/tmp/aliyun oss cp release-windows-latest/latest.json \
201+
/tmp/aliyun/aliyun.exe oss cp release-files/latest.json \
193202
"oss://${{ secrets.OSS_BUCKET }}/downloads/latest.json" \
194203
--force -e "$OSS_ENDPOINT" --profile ossci
195204
echo "OSS sync done"
@@ -214,6 +223,7 @@ jobs:
214223
# ---------------------------------------------------------------
215224
- name: Verify release assets
216225
if: startsWith(github.ref, 'refs/tags/')
226+
shell: bash
217227
env:
218228
GH_TOKEN: ${{ github.token }}
219229
GH_REPO: ${{ github.repository }}
@@ -228,16 +238,3 @@ jobs:
228238
exit 1
229239
fi
230240
echo "发布资产完整校验通过"
231-
232-
- name: Check installer size
233-
run: |
234-
set -eo pipefail
235-
for exe in release-windows-latest/*.exe; do
236-
[ -f "$exe" ] || continue
237-
SIZE=$(stat -c%s "$exe")
238-
SIZE_MB=$(awk "BEGIN {printf \"%.2f\", $SIZE / 1048576}")
239-
echo "📦 $exe: ${SIZE_MB} MB"
240-
if [ "$SIZE" -gt 419430400 ]; then
241-
echo "::warning::${exe} 超过 400MB,请检查是否误打包大文件(模型不入库)"
242-
fi
243-
done

0 commit comments

Comments
 (0)