Skip to content

Commit

Permalink
ci: 重构
Browse files Browse the repository at this point in the history
  • Loading branch information
typed-sigterm committed Jul 21, 2024
1 parent d0e1986 commit d8133f6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/autofix.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ on:
- renovate/**
push:
branches-ignore:
- insider
- latest
- renovate/**

permissions:
contents: read

jobs:
autofix:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- uses: pnpm/action-setup@v4
with:
run_install: true
cache: pnpm

- run: pnpm install
- run: pnpm lint --fix

- uses: autofix-ci/[email protected]
with:
commit-message: 'style: autofix'
29 changes: 20 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,41 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 检查版本稳定性
id: check-stability
uses: actions/github-script@v7
with:
script: |
import { prerelease } from 'semver'
import { version } from './package.json'
const { prerelease } = require('semver');
const { version } = require('./package.json');
return !prerelease(version)
- name: 更新 latest 分支
if: steps.check-stability.outputs.result
run: |
git checkout -b latest origin/latest
git merge --ff-only origin/main
git push origin latest
- name: 更新 insider 分支
if: !steps.check-stability.outputs.result
run: |
git checkout -b insider origin/insider || git switch -c insider
git merge --ff-only origin/main
git push origin insider
- name: 删除 insider 分支
if: steps.check-stability.outputs.result
run: |
git push origin -d insider || true
release:
name: 发布更新包
permissions:
contents: write
runs-on: ${{ matrix.platform }}

strategy:
fail-fast: false
matrix:
Expand All @@ -54,41 +61,45 @@ jobs:
target: universal-apple-darwin
install: aarch64-apple-darwin,x86_64-apple-darwin
# i686-apple-darwin 在 Rust 平台支持的 Tier 3,不一定能正常工作,所以不支持
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: pnpm

- name: 获取 release ID
id: get-release
uses: actions/github-script@v7
with:
script: |
const [owner, repo] = process.env.REPO.split('/')
const [owner, repo] = process.env.REPO.split('/');
const { data } = await github.request('GET /repos/{owner}/{repo}/releases/tags/{tag}', {
owner,
repo,
tag: process.env.REF,
headers: { 'X-GitHub-Api-Version': '2022-11-28' },
})
return data.id
});
return data.id;
env:
REF: ${{ github.ref_name }}
REPO: ${{ github.repository }}

- name: 安装工具链
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.install || matrix.target }}

- name: 缓存依赖
uses: swatinem/rust-cache@v2
with:
workspaces: ./src-tauri -> target
- uses: pnpm/action-setup@v3
with:
run_install: true

- name: 构建应用
run: pnpm web:build

- name: 构建与发布安装包
uses: tauri-apps/[email protected]
env:
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
name: 代码质量测试

on:
pull_request:
branches-ignore:
- renovate/**
push:
branches-ignore:
- insider
- latest
- renovate/**
pull_request:

jobs:
unit-test:
name: 单元测试
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- uses: pnpm/action-setup@v3
with:
run_install: true
- name: 运行单元测试
run: pnpm test
cache: pnpm

- run: pnpm install
- run: pnpm test

0 comments on commit d8133f6

Please sign in to comment.