Skip to content

fix action

fix action #43

Workflow file for this run

name: Release
on:
push:
tags:
- '*.*.*'
permissions:
contents: write
jobs:
build_win:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Setup Python (for node-gyp)
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Ensure setuptools available
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Install dependencies
run: pnpm install --frozen-lockfile=false
- name: Prepare FFmpeg (Windows)
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path vendor/ffmpeg/win32-x64 | Out-Null
$url = 'https://github.com/BtbN/FFmpeg-Builds/releases/latest/download/ffmpeg-master-latest-win64-gpl.zip'
Invoke-WebRequest -Uri $url -OutFile ffmpeg.zip
Expand-Archive -Path ffmpeg.zip -DestinationPath ffmpeg_unzip -Force
$ff = (Get-ChildItem -Recurse -Filter ffmpeg.exe ffmpeg_unzip | Select-Object -First 1).FullName
Copy-Item -Path $ff -Destination vendor/ffmpeg/win32-x64/ffmpeg.exe -Force
Remove-Item ffmpeg.zip -Force
Remove-Item ffmpeg_unzip -Recurse -Force
- name: Build Rust N-API (rust_package)
working-directory: rust_package
run: npx --yes @napi-rs/cli@2.18.4 build --platform --release --target x86_64-pc-windows-msvc
- name: Build (vite)
env:
CLOUD_SYNC_BASE_URL_PROD: ${{ secrets.CLOUD_SYNC_BASE_URL_PROD }}
CLOUD_SYNC_API_SECRET_KEY: ${{ secrets.CLOUD_SYNC_API_SECRET_KEY }}
run: pnpm build
- name: Package (electron-builder, no publish)
run: npx electron-builder --win --x64 --publish never
# 不再复制 rc.yml,严格遵循 GitHub provider 读取 latest.yml / latest-mac.yml
- name: Upload dist artifacts (Windows)
uses: actions/upload-artifact@v4
if: always()
with:
name: win-artifacts
path: |
dist/FRKB-*-win32-x64.exe
dist/*.blockmap
dist/*.yml
build_mac:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Setup Python (for node-gyp)
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Ensure setuptools available
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin, x86_64-apple-darwin
- name: Ensure Rust targets
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
- name: Install dependencies
run: pnpm install --frozen-lockfile=false
- name: Prepare FFmpeg (macOS both arch)
run: |
set -e
mkdir -p vendor/ffmpeg/darwin-arm64 vendor/ffmpeg/darwin-x64
# Arm64 ffmpeg via brew (native)
brew update
brew install ffmpeg
install -m 755 "$(brew --prefix)/bin/ffmpeg" vendor/ffmpeg/darwin-arm64/ffmpeg
# Install Rosetta for x64 support
softwareupdate --install-rosetta --agree-to-license || true
# Try to use x64 Homebrew under Rosetta
if [ -x "/usr/local/bin/brew" ]; then
arch -x86_64 /usr/local/bin/brew update || true
arch -x86_64 /usr/local/bin/brew install ffmpeg || true
if [ -x "/usr/local/bin/ffmpeg" ]; then
install -m 755 "/usr/local/bin/ffmpeg" vendor/ffmpeg/darwin-x64/ffmpeg || true
else
# Fallback: try brew --prefix
X64_PREFIX=$(arch -x86_64 /usr/local/bin/brew --prefix 2>/dev/null || echo "/usr/local")
if [ -x "$X64_PREFIX/bin/ffmpeg" ]; then
install -m 755 "$X64_PREFIX/bin/ffmpeg" vendor/ffmpeg/darwin-x64/ffmpeg || true
fi
fi
fi
# Final fallback: if x64 ffmpeg still missing, copy arm64 (build will pass, but Intel 机器不可执行)
if [ ! -f vendor/ffmpeg/darwin-x64/ffmpeg ]; then
echo "WARN: x64 ffmpeg not found, falling back to arm64 copy (runtime on Intel mac will fail)."
install -m 755 vendor/ffmpeg/darwin-arm64/ffmpeg vendor/ffmpeg/darwin-x64/ffmpeg
fi
# Verify
file vendor/ffmpeg/darwin-arm64/ffmpeg || true
file vendor/ffmpeg/darwin-x64/ffmpeg || true
- name: Build Rust N-API for mac (both arch)
working-directory: rust_package
run: |
npx --yes @napi-rs/cli@2.18.4 build --platform --release --target x86_64-apple-darwin
npx --yes @napi-rs/cli@2.18.4 build --platform --release --target aarch64-apple-darwin
- name: Build (vite)
env:
CLOUD_SYNC_BASE_URL_PROD: ${{ secrets.CLOUD_SYNC_BASE_URL_PROD }}
CLOUD_SYNC_API_SECRET_KEY: ${{ secrets.CLOUD_SYNC_API_SECRET_KEY }}
run: pnpm build
- name: Package macOS (universal, no publish)
run: npx electron-builder --mac --universal --publish never
# 不再复制 rc.yml / rc-mac.yml,保持标准文件名
- name: Upload dist artifacts (macOS)
uses: actions/upload-artifact@v4
if: always()
with:
name: mac-artifacts
path: |
dist/*.dmg
dist/*.yml
dist/FRKB-*-mac-universal.zip
dist/FRKB-*-mac-universal.zip.blockmap
dist/*.blockmap
dist/*.zip
release:
needs: [build_win, build_mac]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Show downloaded files
run: ls -R artifacts | cat
- name: Create/Update GitHub Release and upload assets
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/FRKB-*-win32-x64.exe
artifacts/*.dmg
artifacts/*.yml
artifacts/*.zip
artifacts/*.blockmap
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}