@@ -3,15 +3,15 @@ name: Release
33on :
44 push :
55 tags :
6- - ' v* '
6+ - " v* "
77 workflow_dispatch :
88 inputs :
99 tag_name :
10- description : ' Release tag name (e.g.: v1.0.0)'
10+ description : " Release tag name (e.g.: v1.0.0)"
1111 required : true
1212 type : string
1313 prerelease :
14- description : ' Mark as pre-release'
14+ description : " Mark as pre-release"
1515 required : false
1616 default : false
1717 type : boolean
3636 echo "Looking for version: $VERSION"
3737 CHANGELOG_FILE=$(mktemp)
3838 awk "/^## \\[?v?${VERSION//./\\.}\]?/ {flag=1; next} /^## / && flag {flag=0} flag {print}" CHANGELOG.md > "$CHANGELOG_FILE"
39-
39+
4040 if [ -s "$CHANGELOG_FILE" ]; then
4141 {
4242 echo "CHANGELOG_CONTENT<<EOF"
@@ -116,7 +116,7 @@ jobs:
116116 needs : prepare
117117 strategy :
118118 matrix :
119- rust_target : [ x86_64-pc-windows-msvc, aarch64-pc-windows-msvc ]
119+ rust_target : [x86_64-pc-windows-msvc, aarch64-pc-windows-msvc]
120120 environment : TAURI_KEY
121121 steps :
122122 - name : Checkout repository
@@ -148,12 +148,29 @@ jobs:
148148 cat >> .cargo/config.toml <<EOF
149149 [target.x86_64-pc-windows-msvc]
150150 linker = "lld-link"
151-
151+
152152 [target.aarch64-pc-windows-msvc]
153153 linker = "lld-link"
154154 EOF
155155 - name : Install dependencies
156156 run : pnpm install
157+ - name : Get version
158+ id : get_version
159+ shell : bash
160+ run : |
161+ VERSION=$(node -p "require('./package.json').version")
162+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
163+ echo "Version is $VERSION"
164+ - name : Compute short target name
165+ id : short
166+ shell : bash
167+ run : |
168+ case "${{ matrix.rust_target }}" in
169+ *x86_64-pc-windows*) SHORT=win_x64 ;;
170+ *aarch64-pc-windows*) SHORT=win_arm64 ;;
171+ *) SHORT=unknown ;;
172+ esac
173+ echo "SHORT=$SHORT" >> $GITHUB_OUTPUT
157174 - name : Build and Upload to Draft Release
158175 uses : tauri-apps/tauri-action@v0
159176 env :
@@ -168,9 +185,41 @@ jobs:
168185 releaseDraft : true
169186 prerelease : false
170187 includeUpdaterJson : true
171- includeRelease : true
188+ includeRelease : true
172189 tauriScript : pnpm tauri
173190 args : --target ${{ matrix.rust_target }}
191+ - name : Prepare portable package (Windows)
192+ shell : pwsh
193+ run : |
194+ $version = "${{ steps.get_version.outputs.VERSION }}"
195+ $short = "${{ steps.short.outputs.SHORT }}"
196+ $target = "${{ matrix.rust_target }}"
197+ $portableRoot = "src-tauri/target/$target/release/portable/ReinaManager-$version-$short"
198+ $resourcesDataDir = Join-Path $portableRoot "resources/data"
199+ $zipPath = "src-tauri/target/$target/release/ReinaManager-$version-$short-portable.zip"
200+
201+ if (Test-Path $portableRoot) {
202+ Remove-Item $portableRoot -Recurse -Force
203+ }
204+ if (Test-Path $zipPath) {
205+ Remove-Item $zipPath -Force
206+ }
207+
208+ New-Item -ItemType Directory -Path $resourcesDataDir -Force | Out-Null
209+ @"
210+ 该文件夹为数据库文件夹,删除该文件夹则退出便携模式,反之则保持便携模式。
211+ This folder stores the database. Deleting this folder exits portable mode; keeping it preserves portable mode.
212+ "@ | Set-Content -Path (Join-Path $resourcesDataDir "readme.txt") -Encoding UTF8
213+ Copy-Item "src-tauri/target/$target/release/ReinaManager.exe" "$portableRoot/ReinaManager.exe"
214+ Compress-Archive -Path "$portableRoot/*" -DestinationPath $zipPath
215+ - name : Upload portable package to Draft Release
216+ shell : bash
217+ env :
218+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
219+ run : |
220+ gh release upload "${{ github.ref_name }}" \
221+ "src-tauri/target/${{ matrix.rust_target }}/release/ReinaManager-${{ steps.get_version.outputs.VERSION }}-${{ steps.short.outputs.SHORT }}-portable.zip" \
222+ --clobber
174223
175224 finalize-release :
176225 name : Finalize Release
@@ -201,55 +250,51 @@ jobs:
201250 TAG_NAME="${{ github.ref_name }}"
202251 # 从 GitHub API 获取草稿 release 的所有资源文件名
203252 ASSETS_JSON=$(gh release view "$TAG_NAME" --json assets --jq '.assets | .[] | .name')
204-
253+
205254 # 解析 Windows 产物
206255 X64_MSI=$(echo "$ASSETS_JSON" | grep -E "_x64_.*\.msi$" || echo "")
207256 ARM64_MSI=$(echo "$ASSETS_JSON" | grep -E "_arm64_.*\.msi$" || echo "")
208-
257+ X64_PORTABLE=$(echo "$ASSETS_JSON" | grep -E "win_x64-portable\.zip$" || echo "")
258+ ARM64_PORTABLE=$(echo "$ASSETS_JSON" | grep -E "win_arm64-portable\.zip$" || echo "")
259+
209260 # 解析 Linux 产物 (AppImage & deb)
210261 X64_APPIMAGE=$(echo "$ASSETS_JSON" | grep -E "amd64.*\.AppImage$" || echo "")
211262 X64_DEB=$(echo "$ASSETS_JSON" | grep -E "amd64.*\.deb$" || echo "")
212263 ARM64_APPIMAGE=$(echo "$ASSETS_JSON" | grep -E "aarch64.*\.AppImage$" || echo "")
213264 ARM64_DEB=$(echo "$ASSETS_JSON" | grep -E "arm64.*\.deb$" || echo "")
214-
265+
215266 CHANGELOG="${{ needs.prepare.outputs.changelog }}"
216-
267+
217268 # 构建下载链接
218269 BASE_URL="https://github.com/${{ github.repository }}/releases/download/$TAG_NAME"
219-
270+
220271 DOWNLOAD_SECTION=$(cat <<EOF
221272 ---
222273 ### 📥 下载地址 (Download)
223274 
224-
275+
225276 **Windows** (不支持 Win7)
226277 - [**64位 (x64)**]($BASE_URL/$X64_MSI)
227278 - [**ARM64**]($BASE_URL/$ARM64_MSI)
228-
279+ - [**便携版 (x64)**]($BASE_URL/$X64_PORTABLE)
280+ - [**便携版 (ARM64)**]($BASE_URL/$ARM64_PORTABLE)
281+
229282 **Linux**
230283 - [**AppImage (x64)**]($BASE_URL/$X64_APPIMAGE)
231284 - [**Debian/Ubuntu (.deb x64)**]($BASE_URL/$X64_DEB)
232285 - [**AppImage (ARM64)**]($BASE_URL/$ARM64_APPIMAGE)
233286 - [**Debian/Ubuntu (.deb ARM64)**]($BASE_URL/$ARM64_DEB)
234-
235- ### ⚠️ **安装提醒 (Installation Notice)**
236- 不建议安装在 **C:\Program Files** 目录下。该目录需要以管理员权限运行软件才能正常使用以下功能:
237- - 自定义游戏封面
238- - 便携模式
239- ---
240- It is **NOT recommended** to install in **C:\Program Files**. This directory requires administrator privileges for the following features:
241- - Custom game covers
242- - Portable mode
287+
243288 EOF
244289 )
245-
290+
246291 FINAL_BODY=$(cat <<EOF
247292 $CHANGELOG
248293
249294 $DOWNLOAD_SECTION
250295 EOF
251296 )
252-
297+
253298 {
254299 echo "body<<EOF"
255300 echo "$FINAL_BODY"
@@ -295,6 +340,6 @@ jobs:
295340
296341 jq '.platforms |= with_entries(.value.url |= "https://gh.huoshen80.top/\(.)")' latest.json > latest_modified.json
297342 mv -f latest_modified.json latest.json
298-
343+
299344 gh release upload $TAG_NAME "latest.json" --clobber
300- echo "Successfully updated latest.json with CDN URLs"
345+ echo "Successfully updated latest.json with CDN URLs"
0 commit comments