Repository navigation
67 lines (57 loc) · 2.45 KB
/
Copy pathrelease.yml
File metadata and controls
67 lines (57 loc) · 2.45 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
name: Release
# 推 tag 即发布:版本号由 tag 驱动注入,产物在 GitHub runner 上构建并直接
# 上传到 Release(上传不出 GitHub 内网,本机无需上传 116MB 安装包)。
#
# 发版流程:
# 1. 编辑 .github/release-notes.md 填好「新增 / 修复」条目
# 2. git push(确保 tag 指向的提交已推送)
# 3. git tag v1.4.0 && git push origin v1.4.0
# 4. 等 Actions 完成(约 5-10 分钟),Release 自动生成三份资产
# 注意:tag 版本号优先于 package.json,构建前会自动覆盖(--no-git-tag-version)。
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: 从 tag 注入版本号
id: ver
shell: pwsh
run: |
$v = $env:GITHUB_REF_NAME.TrimStart('v')
if ($v -notmatch '^\d+\.\d+\.\d+$') { throw "tag 格式应为 vX.Y.Z,实际:$env:GITHUB_REF_NAME" }
npm version $v --no-git-tag-version --allow-same-version
"version=$v" >> $env:GITHUB_OUTPUT
- name: 安装依赖
env:
# runner 在海外,直连官方源;覆盖 .npmrc 中的国内镜像
ELECTRON_MIRROR: https://github.com/electron/electron/releases/download/
ELECTRON_BUILDER_BINARIES_MIRROR: https://github.com/electron-userland/electron-builder-binaries/releases/download/
run: npm ci
- name: 构建安装包
env:
ELECTRON_MIRROR: https://github.com/electron/electron/releases/download/
ELECTRON_BUILDER_BINARIES_MIRROR: https://github.com/electron-userland/electron-builder-binaries/releases/download/
run: npm run build:win
- name: 生成发布说明
shell: pwsh
run: |
(Get-Content .github/release-notes.md -Raw -Encoding utf8).Replace('{{VERSION}}', '${{ steps.ver.outputs.version }}') |
Set-Content -Encoding utf8NoBOM .github/release-notes.out.md
- name: 发布 Release
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.ver.outputs.version }}
body_path: .github/release-notes.out.md
files: |
dist/knowledge-base-Setup-${{ steps.ver.outputs.version }}.exe
dist/knowledge-base-Setup-${{ steps.ver.outputs.version }}.exe.blockmap
dist/latest.yml