Skip to content

Commit

Permalink
ci: 🎡 优化CI配置 (#141)
Browse files Browse the repository at this point in the history
* ci: 🎡 优化CI配置

* fix: 🐛 修复CI中缓存顺序问题
  • Loading branch information
nongyehong authored Jan 4, 2025
1 parent 4d4bd9c commit 6b47049
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 62 deletions.
42 changes: 30 additions & 12 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
# Add 'frontend' label to any changes in src directory
frontend:
# 前端相关变更
'前端':
- src/**/*

# Add 'workflow' label to any changes in the .github directory
workflow:
# 工作流程相关变更
'工作流程':
- .github/**/*

# Add 'documentation' label to any markdown files
documentation:
# 文档相关变更
'文档':
- '**/*.md'

# Add 'dependencies' label to any changes to package files
dependencies:
# 依赖相关变更
'依赖更新':
- package.json
- package-lock.json
- yarn.lock
- pnpm-lock.yaml

# Add 'rust' label to any Rust-related files
rust:
# Rust 相关变更
'Rust':
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- 'src-tauri/**/*'

# 配置文件变更
'配置':
- '*.config.ts'
- '*.config.js'
- 'tsconfig.json'
- '.env*'

# 测试相关变更
'测试':
- '**/*.test.ts'
- 'test/**/*'

# 样式相关变更
'样式':
- '**/*.css'
- '**/*.scss'
- 'uno.config.*'
25 changes: 8 additions & 17 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

# 首先安装 pnpm
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
# 然后设置 Node.js
- name: Setup Node
uses: actions/setup-node@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: '22'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install
Expand Down
25 changes: 8 additions & 17 deletions .github/workflows/pr-chatbot-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,19 @@ jobs:
echo "EOF" >> $GITHUB_ENV
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

# 首先安装 pnpm
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
# 然后设置 Node.js
- name: Setup Node
uses: actions/setup-node@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: '22'
cache: 'pnpm'

- name: Install dependencies
run: |
Expand Down
48 changes: 32 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,57 @@ name: Release CI
on:
push:
tags:
- 'v*'
workflow_dispatch:
- 'v*' # 当推送 v 开头的标签时触发
workflow_dispatch: # 允许手动触发工作流

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: true # 如果有新的发布任务,取消正在进行的任务

jobs:
publish-tauri:
permissions:
contents: write
contents: write # 授予写入仓库内容的权限
strategy:
fail-fast: false
fail-fast: false # 某个平台构建失败不影响其他平台
matrix:
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
args: '--target x86_64-apple-darwin'
- platform: 'windows-latest'
args: ''
- platform: "macos-latest" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin"
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin"
- platform: "ubuntu-22.04"
args: ""
- platform: "windows-latest"
args: ""

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

# 安装 Node.js
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # Tauri v2 最低兼容性版本
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libudev-dev
# 添加环境变量配置
- name: Set up environment variables
run: echo "${{ secrets.ENV_LOCAL_CONTENT }}" > .env.local

# 首先安装 pnpm
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

# 然后设置 Node.js
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '22'

# 安装 pnpm
- name: Install pnpm
run: npm install -g pnpm@latest
cache: 'pnpm'

- name: Install dependencies
run: pnpm install
Expand Down

0 comments on commit 6b47049

Please sign in to comment.