|
1 | | -name: Build & Release |
| 1 | +name: Prepare Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
|
20 | 20 | prepare-release: |
21 | 21 | runs-on: ubuntu-latest |
22 | 22 | if: github.event_name == 'workflow_dispatch' |
23 | | - outputs: |
24 | | - new_tag: ${{ steps.get_tag.outputs.tag }} |
25 | | - changelog: ${{ steps.extract_changelog.outputs.notes }} |
26 | 23 | steps: |
27 | 24 | - name: Checkout code |
28 | 25 | uses: actions/checkout@v4 |
@@ -58,183 +55,14 @@ jobs: |
58 | 55 | run: | |
59 | 56 | node -e "const fs=require('fs');const pkg=require('./package.json');const path='src-tauri/tauri.conf.json';const conf=JSON.parse(fs.readFileSync(path,'utf8'));conf.version=pkg.version;fs.writeFileSync(path, JSON.stringify(conf,null,2)+'\\n');" |
60 | 57 |
|
| 58 | + - name: Sync Cargo version |
| 59 | + run: | |
| 60 | + node -e "const fs=require('fs');const pkg=require('./package.json');const path='src-tauri/Cargo.toml';const content=fs.readFileSync(path,'utf8').replace(/^version = \".*\"$/m, `version = \"${pkg.version}\"`);fs.writeFileSync(path, content);" |
| 61 | +
|
61 | 62 | - name: Commit and tag |
62 | 63 | run: | |
63 | 64 | VERSION=$(node -p "require('./package.json').version") |
64 | | - git add package.json pnpm-lock.yaml CHANGELOG.md src-tauri/tauri.conf.json |
| 65 | + git add package.json pnpm-lock.yaml CHANGELOG.md src-tauri/tauri.conf.json src-tauri/Cargo.toml |
65 | 66 | git commit -m "chore(release): v${VERSION}" |
66 | 67 | git tag -a "v${VERSION}" -m "v${VERSION}" |
67 | 68 | git push --follow-tags origin HEAD:main |
68 | | -
|
69 | | - - name: Get new tag |
70 | | - id: get_tag |
71 | | - run: | |
72 | | - TAG=$(git describe --tags --abbrev=0) |
73 | | - echo "tag=$TAG" >> $GITHUB_OUTPUT |
74 | | - echo "Generated new tag: $TAG" |
75 | | -
|
76 | | - - name: Extract Changelog |
77 | | - id: extract_changelog |
78 | | - run: | |
79 | | - CHANGELOG_CONTENT=$(node .github/scripts/extract-changelog.js) |
80 | | - echo "notes<<EOF" >> $GITHUB_OUTPUT |
81 | | - echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT |
82 | | - echo "EOF" >> $GITHUB_OUTPUT |
83 | | -
|
84 | | - build-mac: |
85 | | - needs: [prepare-release] |
86 | | - strategy: |
87 | | - matrix: |
88 | | - include: |
89 | | - - os: macos-15-intel |
90 | | - arch: x64 |
91 | | - - os: macos-latest |
92 | | - arch: arm64 |
93 | | - runs-on: ${{ matrix.os }} |
94 | | - steps: |
95 | | - - name: Checkout code |
96 | | - uses: actions/checkout@v4 |
97 | | - with: |
98 | | - ref: ${{ needs.prepare-release.outputs.new_tag }} |
99 | | - |
100 | | - - name: Setup pnpm |
101 | | - uses: pnpm/action-setup@v4 |
102 | | - with: |
103 | | - version: "10" |
104 | | - run_install: false |
105 | | - |
106 | | - - name: Setup Node.js |
107 | | - uses: actions/setup-node@v4 |
108 | | - with: |
109 | | - node-version: "20" |
110 | | - cache: "pnpm" |
111 | | - cache-dependency-path: "pnpm-lock.yaml" |
112 | | - |
113 | | - - name: Setup Rust |
114 | | - uses: dtolnay/rust-toolchain@stable |
115 | | - |
116 | | - - name: Install dependencies |
117 | | - run: pnpm install --frozen-lockfile |
118 | | - |
119 | | - - name: Build macOS app |
120 | | - run: pnpm tauri build |
121 | | - |
122 | | - - name: Rename macOS artifacts |
123 | | - run: | |
124 | | - VERSION=${{ needs.prepare-release.outputs.new_tag }} |
125 | | - VERSION=${VERSION#v} |
126 | | - DMG=$(ls src-tauri/target/release/bundle/dmg/*.dmg | head -n 1) |
127 | | - mv "$DMG" "src-tauri/target/release/bundle/dmg/skills-manager-gui_${VERSION}_macos-${{ matrix.arch }}.dmg" |
128 | | -
|
129 | | - - name: Upload macOS artifacts |
130 | | - uses: actions/upload-artifact@v4 |
131 | | - with: |
132 | | - name: mac-artifacts-${{ matrix.arch }} |
133 | | - path: | |
134 | | - src-tauri/target/release/bundle/dmg/skills-manager-gui_*.dmg |
135 | | - if-no-files-found: error |
136 | | - |
137 | | - build-win: |
138 | | - needs: [prepare-release] |
139 | | - runs-on: windows-latest |
140 | | - steps: |
141 | | - - name: Checkout code |
142 | | - uses: actions/checkout@v4 |
143 | | - with: |
144 | | - ref: ${{ needs.prepare-release.outputs.new_tag }} |
145 | | - |
146 | | - - name: Setup pnpm |
147 | | - uses: pnpm/action-setup@v4 |
148 | | - with: |
149 | | - version: "10" |
150 | | - run_install: false |
151 | | - |
152 | | - - name: Setup Node.js |
153 | | - uses: actions/setup-node@v4 |
154 | | - with: |
155 | | - node-version: "20" |
156 | | - cache: "pnpm" |
157 | | - cache-dependency-path: "pnpm-lock.yaml" |
158 | | - |
159 | | - - name: Setup Rust |
160 | | - uses: dtolnay/rust-toolchain@stable |
161 | | - |
162 | | - - name: Install dependencies |
163 | | - run: pnpm install --frozen-lockfile |
164 | | - |
165 | | - - name: Build Windows app |
166 | | - run: pnpm tauri build |
167 | | - |
168 | | - - name: Rename Windows artifacts |
169 | | - shell: pwsh |
170 | | - run: | |
171 | | - $version = "${{ needs.prepare-release.outputs.new_tag }}".TrimStart("v") |
172 | | - $msi = Get-ChildItem "src-tauri/target/release/bundle/msi" -Filter "*.msi" | Select-Object -First 1 |
173 | | - if ($msi) { |
174 | | - Rename-Item $msi.FullName (Join-Path $msi.DirectoryName "skills-manager-gui_${version}_windows-x64.msi") |
175 | | - } |
176 | | - $exe = Get-ChildItem "src-tauri/target/release/bundle/nsis" -Filter "*.exe" | Select-Object -First 1 |
177 | | - if ($exe) { |
178 | | - Rename-Item $exe.FullName (Join-Path $exe.DirectoryName "skills-manager-gui_${version}_windows-x64-setup.exe") |
179 | | - } |
180 | | -
|
181 | | - - name: Upload Windows artifacts |
182 | | - uses: actions/upload-artifact@v4 |
183 | | - with: |
184 | | - name: win-artifacts |
185 | | - path: | |
186 | | - src-tauri/target/release/bundle/msi/skills-manager-gui_*.msi |
187 | | - src-tauri/target/release/bundle/nsis/skills-manager-gui_*.exe |
188 | | - if-no-files-found: error |
189 | | - |
190 | | - release: |
191 | | - needs: [prepare-release, build-mac, build-win] |
192 | | - runs-on: ubuntu-latest |
193 | | - steps: |
194 | | - - name: Download macOS artifacts |
195 | | - uses: actions/download-artifact@v4 |
196 | | - with: |
197 | | - pattern: mac-artifacts-* |
198 | | - merge-multiple: true |
199 | | - path: artifacts |
200 | | - |
201 | | - - name: Download Windows artifacts |
202 | | - uses: actions/download-artifact@v4 |
203 | | - with: |
204 | | - name: win-artifacts |
205 | | - path: artifacts |
206 | | - |
207 | | - - name: Create GitHub Release |
208 | | - uses: softprops/action-gh-release@v2 |
209 | | - with: |
210 | | - tag_name: ${{ needs.prepare-release.outputs.new_tag }} |
211 | | - draft: false |
212 | | - prerelease: false |
213 | | - files: | |
214 | | - artifacts/**/skills-manager-gui_*.dmg |
215 | | - artifacts/**/skills-manager-gui_*.msi |
216 | | - artifacts/**/skills-manager-gui_*.exe |
217 | | - body: | |
218 | | - ## 🎉 新版本发布! |
219 | | -
|
220 | | - **注意:本项目暂无商业签名证书,安装时可能会提示安全警告。** |
221 | | -
|
222 | | - ### 🍎 macOS 用户 |
223 | | - 初次安装可能出现 “应用已损坏,无法打开” 或 “来自身份不明的开发者”。 |
224 | | -
|
225 | | - 请打开「终端」执行: |
226 | | -
|
227 | | - ```bash |
228 | | - xattr -cr /Applications/skills-manager-gui.app |
229 | | - ``` |
230 | | -
|
231 | | - ### 🪟 Windows 用户 |
232 | | - 1. 点击 “更多信息” |
233 | | - 2. 点击 “仍要运行” |
234 | | -
|
235 | | - --- |
236 | | -
|
237 | | - ### 更新日志 |
238 | | - ${{ needs.prepare-release.outputs.changelog }} |
239 | | - env: |
240 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments