Repository navigation
145 lines (131 loc) · 4.79 KB
/
Copy pathrelease.yml
File metadata and controls
145 lines (131 loc) · 4.79 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
name: Release
# 推一个 v* 标签即可触发:社区扩展和 Windows 桌面端并行构建,产物汇总成一个「草稿」Release,
# 你在网页上确认无误后点 Publish 发布。
#
# 构建所需的生产地址来自仓库变量(Settings → Secrets and variables → Actions → Variables):
# VITE_API_BASE_URL 必填,例如 https://chat-api.example.com
# VITE_WS_URL 必填,例如 wss://chat-api.example.com/ws
# VITE_EXTENSION_ASSET_URL 选填,已发布的扩展文件地址
# VITE_BOT_API_DOCS_URL 选填,机器人 API 文档地址
# KUKECHAT_UPDATE_METADATA_URL 选填,覆盖桌面端更新地址(默认 <VITE_API_BASE_URL>/desktop-update.json)
#
# 仓库源码不含任何服务器地址,fork 后请设置你自己的变量。
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "发布用的标签名(例如 v1.2.1)"
required: true
permissions:
contents: write
env:
VITE_API_BASE_URL: ${{ vars.VITE_API_BASE_URL }}
VITE_WS_URL: ${{ vars.VITE_WS_URL }}
VITE_EXTENSION_ASSET_URL: ${{ vars.VITE_EXTENSION_ASSET_URL }}
VITE_BOT_API_DOCS_URL: ${{ vars.VITE_BOT_API_DOCS_URL }}
jobs:
preflight:
name: 配置检查
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.resolve.outputs.tag }}
version: ${{ steps.resolve.outputs.version }}
steps:
- uses: actions/checkout@v5
- name: 必填变量是否已配置
run: |
missing=""
[ -n "$VITE_API_BASE_URL" ] || missing="$missing VITE_API_BASE_URL"
[ -n "$VITE_WS_URL" ] || missing="$missing VITE_WS_URL"
if [ -n "$missing" ]; then
echo "::error::缺少仓库变量:$missing"
echo "请在 Settings → Secrets and variables → Actions → Variables 中设置。"
echo "本仓库源码不内置任何服务器地址,构建产物必须显式指定后端。"
exit 1
fi
echo "后端地址: $VITE_API_BASE_URL"
- name: 解析版本号
id: resolve
run: |
tag="${{ github.event.inputs.tag || github.ref_name }}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
echo "标签: $tag"
extension:
name: 构建社区扩展
needs: preflight
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
- name: 重命名产物
run: cp dist/KukeChat.js "KukeChat-${{ needs.preflight.outputs.version }}.js"
- uses: actions/upload-artifact@v4
with:
name: extension
path: KukeChat-*.js
if-no-files-found: error
desktop:
name: 构建 Windows 桌面端
needs: preflight
runs-on: windows-latest
env:
# Rust 侧在编译期通过 option_env! 读取,未设置则桌面端跳过更新检查
KUKECHAT_UPDATE_METADATA_URL: ${{ vars.KUKECHAT_UPDATE_METADATA_URL }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 20
cache: npm
- uses: dtolnay/rust-toolchain@stable
- uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri
- run: npm ci
- run: npm run tauri:build
- name: 收集安装包
shell: bash
run: |
mkdir -p out
find src-tauri/target/release/bundle -type f \( -name "*.msi" -o -name "*-setup.exe" \) -exec cp {} out/ \;
ls -la out
- uses: actions/upload-artifact@v4
with:
name: desktop
path: out/*
if-no-files-found: error
release:
name: 汇总为草稿 Release
needs: [preflight, extension, desktop]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: 列出产物
run: find artifacts -type f | sort
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.preflight.outputs.tag }}
name: KukeChat ${{ needs.preflight.outputs.tag }}
# 草稿状态:你确认产物无误后再手动发布
draft: true
generate_release_notes: true
files: artifacts/**/*
body: |
## 下载
| 形态 | 文件 | 说明 |
| --- | --- | --- |
| 社区扩展 | `KukeChat-*.js` | 在 CCW / Gandi 扩展加载器中加载 |
| Windows 桌面端 | `*.msi` / `*-setup.exe` | 二选一安装 |
> 以上产物已连接官方服务,下载后可直接使用。
> 想连接自建后端请自行构建,见 README 的「配置」一节。
---