Merge branch 'main' of github-iaiuse:iaiuse/Desky #3
This file contains hidden or 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 }} 上构建 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ windows-latest, macos-latest] | |
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: 安装系统依赖项(Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
build-essential \ | |
libgtk-3-dev \ | |
libwebkit2gtk-4.0-dev \ | |
libssl-dev \ | |
libsoup2.4-dev \ | |
libjavascriptcoregtk-4.0-dev | |
- name: 构建 Tauri 应用 | |
uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 上传构建产物 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }}-build | |
path: | | |
src-tauri/target/release/bundle/**/* | |
src-tauri/target/release/*.app.zip | |
release: | |
needs: build | |
runs-on: ${{ matrix.os }} | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
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: | |
name: ${{ matrix.os }}-build | |
path: ${{ matrix.os }}-build | |
- name: 列出下载的构建产物 | |
shell: bash | |
run: | | |
ls -R ${{ matrix.os }}-build/ | |
- 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: | | |
${{ matrix.os == 'macos-latest' && 'macos-latest-build/**/*.dmg' || '' }} | |
${{ matrix.os == 'windows-latest' && 'windows-latest-build/**/*.msi' || '' }} | |
${{ matrix.os == 'windows-latest' && 'windows-latest-build/**/*.exe' || '' }} | |
${{ matrix.os == 'ubuntu-latest' && 'ubuntu-latest-build/**/*.AppImage' || '' }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |