build(workflow): 更新 GitHub Actions 工作流配置 #94
This commit is contained in:
55
.github/workflows/buildapp.yml
vendored
Normal file
55
.github/workflows/buildapp.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: Build and Release Tauri App
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
jobs:
|
||||
publish-tauri:
|
||||
permissions:
|
||||
contents: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [macos-latest, ubuntu-20.04, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies (ubuntu only)
|
||||
if: matrix.platform == 'ubuntu-20.04'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Rust cache
|
||||
uses: swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: ./src-tauri -> target
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: pnpm
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build the app
|
||||
uses: tauri-apps/tauri-action@v0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tagName: ${{ github.ref_name }} # the action automatically replaces \_\_VERSION\_\_ with the app version
|
||||
releaseName: 'App ${{ github.ref_name }}'
|
||||
releaseBody: See the assets to download this version and install.
|
||||
releaseDraft: true
|
||||
prerelease: false
|
||||
6
.github/workflows/node.js.yml
vendored
6
.github/workflows/node.js.yml
vendored
@@ -5,7 +5,7 @@ name: Node.js CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'pnpm'
|
||||
cache: pnpm
|
||||
- run: pnpm install
|
||||
- run: pnpm build
|
||||
- name: Copy and Rename index.html to dist
|
||||
@@ -40,5 +40,3 @@ jobs:
|
||||
build_dir: dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||
|
||||
|
||||
|
||||
77
.github/workflows/release.yml
vendored
77
.github/workflows/release.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
build-web:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
@@ -26,8 +26,8 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '22.x'
|
||||
cache: 'pnpm'
|
||||
node-version: 22.x
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
@@ -35,9 +35,6 @@ jobs:
|
||||
- name: Build for production
|
||||
run: pnpm build
|
||||
|
||||
- name: Build for file protocol
|
||||
run: pnpm build:file
|
||||
|
||||
- name: Prepare directories
|
||||
run: |
|
||||
mv dist dist-prod
|
||||
@@ -45,18 +42,72 @@ jobs:
|
||||
|
||||
- name: Create production build archive
|
||||
run: |
|
||||
tar -czf dist.tar.gz dist-prod
|
||||
zip -r dist.zip dist-prod
|
||||
|
||||
- name: Create file protocol build archive
|
||||
run: |
|
||||
tar -czf dist-file.tar.gz dist-file
|
||||
- name: Upload web build artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: web-build
|
||||
path: dist.zip
|
||||
|
||||
- name: Release
|
||||
publish-tauri:
|
||||
permissions:
|
||||
contents: write
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Rust cache
|
||||
uses: swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: ./src-tauri -> target
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: pnpm
|
||||
|
||||
- name: Install frontend dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build the app
|
||||
uses: tauri-apps/tauri-action@v0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tagName: ${{ github.ref_name }}
|
||||
releaseBody: See the assets to download this version and install.
|
||||
releaseDraft: true
|
||||
prerelease: false
|
||||
|
||||
release:
|
||||
needs: [build-web, publish-tauri]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download web build artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: web-build
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
dist.tar.gz
|
||||
dist-file.tar.gz
|
||||
dist.zip
|
||||
draft: true
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
22
build/syncVersion.js
Normal file
22
build/syncVersion.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// 读取 package.json 版本号
|
||||
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
||||
const version = packageJson.version;
|
||||
|
||||
// 读取并更新 tauri.conf.json
|
||||
const tauriConfPath = path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json');
|
||||
const tauriConf = JSON.parse(fs.readFileSync(tauriConfPath, 'utf8'));
|
||||
|
||||
// 更新版本号
|
||||
tauriConf.version = version;
|
||||
|
||||
// 写回 tauri.conf.json
|
||||
fs.writeFileSync(tauriConfPath, JSON.stringify(tauriConf, null, 2));
|
||||
|
||||
console.log(`Tauri 配置版本号已同步至: ${version}`);
|
||||
@@ -2,7 +2,7 @@ import antfu from '@antfu/eslint-config'
|
||||
|
||||
export default antfu(
|
||||
{
|
||||
ignores: ['**/node_modules', '**/public', '**/dist', '**/package.json', '**/*.yaml', '**/.gitignore', '**/.env*', '**/tsconfig*', '**/*.config.js'],
|
||||
ignores: ['**/node_modules', '**/build', '**/public', '**/dist', '**/package.json', '**/*.yaml', '**/.gitignore', '**/.env*', '**/tsconfig*', '**/*.config.js'],
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
"build:pre": "vue-tsc --noEmit && vite build --mode prebuild",
|
||||
"build:file": "vue-tsc --noEmit && vite build --mode file",
|
||||
"tauri":"node ./build/syncVersion.js && tauri",
|
||||
"test": "vitest",
|
||||
"test:ui": "vitest --ui",
|
||||
"preview": "vite preview",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "log-lottery",
|
||||
"version": "0.1.0",
|
||||
"version": "0.0.4",
|
||||
"identifier": "to2026.xyz",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
Reference in New Issue
Block a user