166 lines
6.0 KiB
YAML
166 lines
6.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: '版本号 (例如 1.5.16)'
|
|
required: true
|
|
type: string
|
|
environment:
|
|
description: '构建环境'
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- test
|
|
- prod
|
|
default: test
|
|
|
|
jobs:
|
|
build-macos:
|
|
name: Build macOS (Universal)
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-apple-darwin,aarch64-apple-darwin
|
|
|
|
- name: Download sidecar binaries
|
|
run: |
|
|
mkdir -p tauri-app/src-tauri/binaries
|
|
gh release download v0.0.0-sidecar --repo fun0/meijiaka-zy --pattern "sidecar-binaries.tar.gz" --dir /tmp
|
|
tar xzf /tmp/sidecar-binaries.tar.gz -C tauri-app/src-tauri/binaries/
|
|
chmod +x tauri-app/src-tauri/binaries/ffmpeg-* tauri-app/src-tauri/binaries/ffprobe-*
|
|
# Create universal binary for macOS universal-apple-darwin target
|
|
# by combining aarch64 and x86_64 binaries with lipo
|
|
if [ -f tauri-app/src-tauri/binaries/ffmpeg-aarch64-apple-darwin ] && [ -f tauri-app/src-tauri/binaries/ffmpeg-x86_64-apple-darwin ]; then
|
|
lipo -create \
|
|
tauri-app/src-tauri/binaries/ffmpeg-aarch64-apple-darwin \
|
|
tauri-app/src-tauri/binaries/ffmpeg-x86_64-apple-darwin \
|
|
-output tauri-app/src-tauri/binaries/ffmpeg-universal-apple-darwin
|
|
lipo -create \
|
|
tauri-app/src-tauri/binaries/ffprobe-aarch64-apple-darwin \
|
|
tauri-app/src-tauri/binaries/ffprobe-x86_64-apple-darwin \
|
|
-output tauri-app/src-tauri/binaries/ffprobe-universal-apple-darwin
|
|
fi
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
- name: Install dependencies
|
|
working-directory: tauri-app
|
|
run: npm ci
|
|
|
|
- name: Build macOS Universal
|
|
working-directory: tauri-app
|
|
run: npm run tauri -- build --target universal-apple-darwin
|
|
env:
|
|
VITE_API_BASE_URL: ${{ inputs.environment == 'prod' && 'https://tapi.meijiaka.cn/api/v1' || 'https://dev.tapi.meijiaka.cn/api/v1' }}
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
|
|
- name: Add README to DMG
|
|
run: |
|
|
DMG_PATH=$(ls tauri-app/src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg | head -1)
|
|
DMG_RW="/tmp/temp_rw.dmg"
|
|
MOUNT_POINT="/tmp/dmg_mount"
|
|
|
|
# 转换为可读写格式
|
|
hdiutil convert "$DMG_PATH" -format UDRW -o "$DMG_RW"
|
|
|
|
# 挂载可读写 DMG
|
|
mkdir -p "$MOUNT_POINT"
|
|
hdiutil attach "$DMG_RW" -mountpoint "$MOUNT_POINT" -nobrowse
|
|
|
|
# 复制 README.txt 到 DMG 根目录
|
|
cp tauri-app/src-tauri/README.txt "$MOUNT_POINT/"
|
|
|
|
# 卸载
|
|
hdiutil detach "$MOUNT_POINT"
|
|
|
|
# 删除原 DMG,转换回压缩只读格式
|
|
rm -f "$DMG_PATH"
|
|
hdiutil convert "$DMG_RW" -format UDZO -o "$DMG_PATH"
|
|
|
|
# 清理临时文件
|
|
rm -f "$DMG_RW"
|
|
|
|
- name: Re-sign DMG
|
|
working-directory: tauri-app
|
|
run: |
|
|
DMG_PATH=$(ls src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg | head -1)
|
|
rm -f "${DMG_PATH}.sig"
|
|
# 用 python 将私钥写入文件,避免 shell heredoc 缩进问题
|
|
python3 -c "import os; open('/tmp/private.key','w').write(os.environ['TAURI_SIGNING_PRIVATE_KEY'])"
|
|
npx tauri signer sign -f /tmp/private.key -p "$TAURI_SIGNING_PRIVATE_KEY_PASSWORD" "$DMG_PATH"
|
|
rm -f /tmp/private.key
|
|
env:
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: macos-universal
|
|
path: |
|
|
tauri-app/src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
|
|
tauri-app/src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg.sig
|
|
|
|
build-windows:
|
|
name: Build Windows (x64)
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-pc-windows-msvc
|
|
|
|
- name: Download sidecar binaries
|
|
shell: pwsh
|
|
run: |
|
|
New-Item -ItemType Directory -Force -Path tauri-app/src-tauri/binaries
|
|
gh release download v0.0.0-sidecar --repo fun0/meijiaka-zy --pattern "sidecar-binaries.tar.gz" --dir $env:TEMP
|
|
tar xzf "$env:TEMP\sidecar-binaries.tar.gz" -C tauri-app/src-tauri/binaries/
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
- name: Install dependencies
|
|
working-directory: tauri-app
|
|
run: npm ci
|
|
|
|
- name: Build Windows x64
|
|
working-directory: tauri-app
|
|
shell: pwsh
|
|
run: npm run tauri -- build --target x86_64-pc-windows-msvc
|
|
env:
|
|
VITE_API_BASE_URL: ${{ inputs.environment == 'prod' && 'https://tapi.meijiaka.cn/api/v1' || 'https://dev.tapi.meijiaka.cn/api/v1' }}
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: windows-x64
|
|
path: |
|
|
tauri-app/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe
|
|
tauri-app/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe.sig
|