-
Notifications
You must be signed in to change notification settings - Fork 6
133 lines (116 loc) · 4.72 KB
/
Copy pathrelease.yml
File metadata and controls
133 lines (116 loc) · 4.72 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
name: Build & Release
# 触发条件:
# - 推送形如 v1.2.3 的 tag 时自动构建并发布
# - 也支持在 Actions 页面手动触发 (workflow_dispatch) 做构建冒烟, 不发布
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write # 创建 Release / 上传 Assets 需要
# 强制所有 JavaScript action 用 Node 24 运行, 消除 Node 20 弃用警告
# (部分 action 如 upload-artifact@v5 内部仍用 Node 20, GitHub 2026-06 起默认切 Node 24)
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# 打包之前先跑完整测试(含 GUI 那批)。此前 build 从 checkout 直接进
# PyInstaller、release 只 needs: build,于是一条测试全红的 tag 照样能发出
# 正式包——tests.yml 虽然存在,但它只在 push/PR 上跑,和 tag 发布毫无关系。
test:
name: Tests
uses: ./.github/workflows/tests.yml
build:
name: Build ${{ matrix.label }}
needs: test
# PyInstaller 打包正常十几分钟;不设上限时卡住会烧满 6 小时。
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
label: windows-x86_64
artifact_glob: dist/DeltaLab
archive_ext: zip
- os: macos-14 # Apple Silicon (arm64)
label: macos-arm64
artifact_glob: dist/DeltaLab.app
archive_ext: zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install "pyinstaller>=6.14"
- name: Build with PyInstaller
# 版本号从 tag 注入 .app 的 Info.plist(见 deltalab.spec 的
# _resolve_version)。手动触发时 ref_name 是分支名,解析不出版本就
# 退回 0.0.0——冒烟构建不该因为版本号失败。
env:
DELTALAB_VERSION: ${{ github.ref_name }}
run: pyinstaller --noconfirm deltalab.spec
# Windows: 压缩 dist/DeltaLab 整个目录为 zip
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$name = "DeltaLab-${{ github.ref_name }}-${{ matrix.label }}.zip"
Compress-Archive -Path dist/DeltaLab/* -DestinationPath $name
echo "ASSET_PATH=$name" | Out-File -FilePath $env:GITHUB_ENV -Append
# macOS: 对 .app 打 zip (用 ditto 保留 Bundle 权限)
- name: Package (macOS)
if: runner.os == 'macOS'
run: |
NAME="DeltaLab-${{ github.ref_name }}-${{ matrix.label }}.zip"
# 去除 Gatekeeper 隔离标记 (用户侧首次打开时仍可能需要右键打开)
xattr -cr dist/DeltaLab.app || true
ditto -c -k --sequesterRsrc --keepParent dist/DeltaLab.app "$NAME"
echo "ASSET_PATH=$NAME" >> "$GITHUB_ENV"
- name: Upload workflow artifact
uses: actions/upload-artifact@v5
with:
name: DeltaLab-${{ matrix.label }}
path: ${{ env.ASSET_PATH }}
if-no-files-found: error
release:
name: Publish GitHub Release
timeout-minutes: 15
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
# 需要仓库内容才能读 CHANGELOG.md 与 tools/release_notes.py
- uses: actions/checkout@v5
- uses: actions/download-artifact@v6
with:
path: artifacts
- name: List downloaded artifacts
run: find artifacts -maxdepth 3 -type f
# 版本说明只维护 CHANGELOG.md 一份, 由脚本抽出本次 tag 的小节。
# 抽不到 (忘了写 CHANGELOG) 就置空, 下一步退回 generate_release_notes。
- name: Extract release notes from CHANGELOG
id: notes
run: |
if python3 tools/release_notes.py "${GITHUB_REF_NAME}" -o release-notes.md; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::CHANGELOG.md 缺少 ${GITHUB_REF_NAME} 小节, 退回自动生成的说明"
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Create / Update GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/**/*.zip
draft: false
prerelease: false
# 两者互斥: 有手写说明就用它, 没有才让 GitHub 按提交自动生成。
body_path: ${{ steps.notes.outputs.found == 'true' && 'release-notes.md' || '' }}
generate_release_notes: ${{ steps.notes.outputs.found != 'true' }}