版本升级到0.9.0 #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 构建和发布 | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: 在 ${{ matrix.os }} 上构建 ${{ matrix.target }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
target: windows | |
- os: macos-latest | |
target: macos-modern | |
- os: macos-latest | |
target: macos-bigsur | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 设置 Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22' | |
- name: 安装 pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: 缓存 pnpm 依赖项 | |
uses: actions/cache@v3 | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: 安装依赖 | |
run: pnpm install | |
- name: 缓存 Cargo 注册表 | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: 缓存 Cargo 构建目录 | |
uses: actions/cache@v3 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: 安装 Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: 安装 macOS 构建目标 | |
if: matrix.os == 'macos-latest' | |
run: | | |
rustup target add x86_64-apple-darwin | |
rustup target add aarch64-apple-darwin | |
- name: 设置环境变量(针对 macOS Big Sur) | |
if: matrix.target == 'macos-bigsur' | |
run: echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV | |
- name: 构建 Tauri 应用 (现代 macOS) | |
if: matrix.target == 'macos-modern' | |
uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
args: --target "universal-apple-darwin" | |
includeDebug: false | |
- name: 构建 Tauri 应用 (Big Sur) | |
if: matrix.target == 'macos-bigsur' | |
uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
args: --target x86_64-apple-darwin | |
config: | | |
{ | |
"tauri": { | |
"bundle": { | |
"macOS": { | |
"minimumSystemVersion": "10.13", | |
"targets": ["x86_64-apple-darwin"] | |
} | |
} | |
} | |
} | |
- name: 构建 Tauri 应用 (Windows) | |
if: matrix.target == 'windows' | |
uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 上传构建产物 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.target }}-build | |
path: | | |
src-tauri/target/release/bundle/**/* | |
src-tauri/target/release/*.app.zip | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 设置 Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22' | |
- name: 安装 pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: 获取版本 | |
id: package-version | |
shell: bash | |
run: | | |
version=$(pnpm pkg get version | tr -d '"') | |
echo "Version: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
- name: 下载所有构建产物 | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: 列出下载的构建产物 | |
shell: bash | |
run: | | |
ls -R artifacts/ | |
- name: 发布到 GitHub Releases | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ steps.package-version.outputs.version }} | |
name: 发布 v${{ steps.package-version.outputs.version }} | |
files: artifacts/**/*.* | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |