@@ -90,94 +90,20 @@ jobs:
9090 run : bun run electron:build
9191 working-directory : .
9292
93- # 打包(不上传发布,避免并行竞态)
94- - name : 打包 (macOS)
93+ # 打包并发布到 GitHub Releases
94+ - name : 打包并发布 (macOS)
9595 if : matrix.platform == 'mac'
9696 env :
97+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9798 APPLE_ID : ${{ secrets.APPLE_ID }}
9899 APPLE_APP_SPECIFIC_PASSWORD : ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
99100 APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
100- run : npx electron-builder --mac ${{ matrix.builder_arg }}
101+ run : npx electron-builder --mac ${{ matrix.builder_arg }} --publish always
101102 working-directory : apps/electron
102103
103- - name : 打包 (Windows)
104+ - name : 打包并发布 (Windows)
104105 if : matrix.platform == 'win'
105- run : npx electron-builder --win ${{ matrix.builder_arg }}
106- working-directory : apps/electron
107-
108- # 上传产物为 workflow artifact
109- - name : 上传产物
110- uses : actions/upload-artifact@v4
111- with :
112- name : build-${{ matrix.platform }}-${{ matrix.arch }}
113- path : apps/electron/out/*
114- retention-days : 1
115-
116- publish :
117- needs : build
118- runs-on : ubuntu-latest
119- steps :
120- - name : 下载 macOS ARM64 产物
121- uses : actions/download-artifact@v4
122- with :
123- name : build-mac-arm64
124- path : artifacts/mac-arm64
125-
126- - name : 下载 macOS x64 产物
127- uses : actions/download-artifact@v4
128- with :
129- name : build-mac-x64
130- path : artifacts/mac-x64
131-
132- - name : 下载 Windows x64 产物
133- uses : actions/download-artifact@v4
134- with :
135- name : build-win-x64
136- path : artifacts/win-x64
137-
138- - name : 汇总产物并合并 latest-mac.yml
139- run : |
140- mkdir -p release
141-
142- # 拷贝 Windows 产物(排除 win-unpacked 中间目录)
143- cp artifacts/win-x64/*.exe artifacts/win-x64/*.exe.blockmap artifacts/win-x64/latest.yml release/
144-
145- # 拷贝 macOS 产物(排除 latest-mac.yml,稍后合并)
146- cp artifacts/mac-x64/*.dmg artifacts/mac-x64/*.zip artifacts/mac-x64/*.zip.blockmap release/ 2>/dev/null || true
147- cp artifacts/mac-arm64/*.dmg artifacts/mac-arm64/*.zip artifacts/mac-arm64/*.zip.blockmap release/ 2>/dev/null || true
148-
149- # 合并两份 latest-mac.yml
150- pip install pyyaml -q
151- python3 << 'PYEOF'
152- import yaml
153-
154- with open('artifacts/mac-x64/latest-mac.yml') as f:
155- x64 = yaml.safe_load(f)
156- with open('artifacts/mac-arm64/latest-mac.yml') as f:
157- arm64 = yaml.safe_load(f)
158-
159- files = []
160- if 'files' in x64:
161- files.extend(x64['files'])
162- if 'files' in arm64:
163- files.extend(arm64['files'])
164-
165- merged = dict(x64)
166- merged['files'] = files
167-
168- with open('release/latest-mac.yml', 'w') as f:
169- yaml.dump(merged, f, default_flow_style=False, allow_unicode=True)
170- PYEOF
171-
172- echo "=== release/ 文件列表 ==="
173- ls -la release/
174-
175- - name : 创建 GitHub Release
176- uses : softprops/action-gh-release@v2
177- with :
178- name : ${{ github.ref_name }}
179- files : release/*
180- draft : false
181- prerelease : false
182106 env :
183- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
107+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
108+ run : npx electron-builder --win ${{ matrix.builder_arg }} --publish always
109+ working-directory : apps/electron
0 commit comments