Skip to content

docs: 新增 release 文档 #11

docs: 新增 release 文档

docs: 新增 release 文档 #11

# Tauri 桌面端:构建;推 main 且构建成功后打 tag 并推送,触发发布工作流
# 触发:推送到 main、或向 main/release 提 PR
name: Build Desktop (CI)
on:
push:
branches:
- main
pull_request:
branches:
- main
- release
jobs:
build-tauri:
strategy:
fail-fast: false
matrix:
include:
- platform: windows-latest
args: ''
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
cache-dependency-path: desktop/package-lock.json
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: desktop/src-tauri
- name: Install frontend dependencies
run: npm ci
working-directory: desktop
- name: Download bundled JDK 11 (Windows)
run: .\scripts\download-jdk11.ps1
working-directory: desktop
- name: Build (no release)
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: desktop
args: ${{ matrix.args }}
- name: Upload desktop build artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-windows-${{ matrix.platform }}
path: |
desktop/src-tauri/target/release/bundle/nsis/*.exe
desktop/src-tauri/target/release/bundle/msi/**/*.msi
# 仅 push 到 main 时:构建成功后打 tag,直接创建草稿 Release 并上传 exe/msi(不再触发另一工作流重复构建)
create-release:
needs: build-tauri
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tauri.conf.json
id: version
shell: bash
run: |
V=$(node -p "require('./desktop/src-tauri/tauri.conf.json').version")
echo "version=$V" >> $GITHUB_OUTPUT
echo "tag=desktop-v$V" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check-tag
run: |
if git ls-remote --exit-code --tags origin refs/tags/${{ steps.version.outputs.tag }}; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create and push tag
if: steps.check-tag.outputs.exists != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.tag }}" -m "Desktop ${{ steps.version.outputs.version }} (auto from CI)"
git push origin "${{ steps.version.outputs.tag }}"
- name: Download build artifacts
if: steps.check-tag.outputs.exists != 'true'
uses: actions/download-artifact@v4
with:
name: desktop-windows-windows-latest
path: release-files
- name: Create Release and upload exe/msi
if: steps.check-tag.outputs.exists != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: COMSOL Agent Desktop v${{ steps.version.outputs.version }}
body: |
Windows 安装包(含内嵌 Java 11)。请下载 exe 或 msi 安装后使用。
See the assets below to download and install.
draft: true
files: |
release-files/**/*.exe
release-files/**/*.msi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}