Repository navigation
84 lines (72 loc) · 3.22 KB
/
Copy pathrelease-bundle.yml
File metadata and controls
84 lines (72 loc) · 3.22 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
name: Build release bundles
# 发布新 Release 时自动构建"一键安装整合包"与各平台"便携包"并上传为该 Release 的资产:
# - dsh-tui-setup.zip(一键安装脚本整合包)
# - dsh-tui-standalone-linux-x64.tar.gz(Linux x64 便携版)
# - dsh-tui-standalone-linux-arm64.tar.gz(Linux arm64 便携版)
# - dsh-tui-standalone-win-x64.zip(Windows x64 便携版)
# - dsh-tui-standalone-darwin-arm64.tar.gz(macOS Apple Silicon 便携版)
# - dsh-tui-standalone-darwin-x64.tar.gz(macOS Intel 便携版)
# 也可手动触发:Actions → Build release bundles → Run workflow → 填 tag。
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: '上传到哪个 tag(默认:最新 release)'
required: false
type: string
permissions:
contents: write
jobs:
bundle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- uses: pnpm/action-setup@v6
with:
version: 11
- uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
- name: Generate installer bundle
run: node scripts/make-installer-bundle.mjs --out dist-bundle
- name: Syntax check generated scripts
run: |
bash -n dist-bundle/dsh-tui-setup/install.sh
pwsh -NoProfile -Command "[scriptblock]::Create((Get-Content -Raw -Encoding UTF8 'dist-bundle/dsh-tui-setup/install.ps1')) | Out-Null"
- name: Generate standalone portable bundles
run: node scripts/make-standalone-bundle.mjs --out dist-standalone
- name: Generate SHA256SUMS for release assets
run: |
# 每个 release 资产按资产名(不带目录前缀)登记 SHA256 摘要,
# 消费端(便携包自更新器 src/update.ts 的 verifyAssetChecksum)
# 按 `hex name` 行匹配并校验下载字节。先写隐藏临时文件再改名,
# 避免 sha256sum 的 glob 把清单自己算进去。
cd dist-standalone
sha256sum * > .SHA256SUMS.tmp
mv .SHA256SUMS.tmp SHA256SUMS
cd ..
# 一键安装整合包同为 release 资产,一并登记。
(cd dist-bundle && sha256sum dsh-tui-setup.zip) >> dist-standalone/SHA256SUMS
cat dist-standalone/SHA256SUMS
- name: Upload to release
env:
GH_TOKEN: ${{ github.token }}
# ${{ }} 表达式一律经 env 中转,绝不内插进 run 的 shell 文本:
# workflow_dispatch 的 inputs.tag 是用户输入,直接内插等于把
# `"$(curl …)"` 类 payload 拼进命令行(表达式注入)。
RELEASE_TAG: ${{ github.event.release.tag_name }}
INPUT_TAG: ${{ github.event.inputs.tag }}
run: |
tag="$RELEASE_TAG"
[ -z "$tag" ] && tag="$INPUT_TAG"
if [ -z "$tag" ]; then
tag="$(gh release list --limit 1 --json tagName -q '.[0].tagName')"
fi
[ -n "$tag" ] || { echo "no tag given"; exit 1; }
echo "Uploading release artifacts -> $tag"
gh release upload "$tag" dist-bundle/dsh-tui-setup.zip dist-standalone/* --clobber