Skip to content

fix: 修复打包后 better-sqlite3 NODE_MODULE_VERSION 不匹配导致 Windows 启动失败 #65

fix: 修复打包后 better-sqlite3 NODE_MODULE_VERSION 不匹配导致 Windows 启动失败

fix: 修复打包后 better-sqlite3 NODE_MODULE_VERSION 不匹配导致 Windows 启动失败 #65

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 2.9.53)'
required: false
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
platform: win
- os: macos-latest
platform: mac
- os: ubuntu-latest
platform: linux
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Python for node-gyp (Windows)
if: matrix.platform == 'win'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup Python for node-gyp (macOS/Linux)
if: matrix.platform != 'win'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup build tools (macOS)
if: matrix.platform == 'mac'
run: |
# xcode-select --install opens a GUI dialog and always fails in CI.
# GitHub macOS runners already have CLT pre-installed; just verify.
xcode-select --print-path
xcrun --show-sdk-path
echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
- name: Install pnpm
run: npm install -g pnpm
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
id: pnpm-cache
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Install web dependencies
working-directory: web
run: pnpm install
- name: Build all
run: pnpm run build:all
- name: Rebuild native modules for Electron
shell: bash
run: |
echo "Node version: $(node --version)"
echo "npm version: $(npm --version)"
PYTHON_BIN=$(command -v python3 || command -v python)
echo "Python: $PYTHON_BIN"
"$PYTHON_BIN" --version
ELECTRON_VERSION=$(node -p "require('./node_modules/electron/package.json').version")
echo "Rebuilding better-sqlite3 against Electron $ELECTRON_VERSION"
pnpm exec electron-rebuild -f -w better-sqlite3 --version "$ELECTRON_VERSION" --python "$PYTHON_BIN"
- name: Build Electron app (Windows)
if: matrix.platform == 'win'
run: pnpm run dist:win
- name: Build Electron app (macOS)
if: matrix.platform == 'mac'
run: pnpm run dist:mac
- name: Build Electron app (Linux)
if: matrix.platform == 'linux'
run: pnpm run dist:linux
- name: Upload artifacts (Windows)
if: matrix.platform == 'win'
uses: actions/upload-artifact@v4
with:
name: windows-build
path: release/*.exe
- name: Upload artifacts (macOS)
if: matrix.platform == 'mac'
uses: actions/upload-artifact@v4
with:
name: macos-build
path: release/*.dmg
- name: Upload artifacts (Linux)
if: matrix.platform == 'linux'
uses: actions/upload-artifact@v4
with:
name: linux-build
path: release/*.AppImage
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Display structure of downloaded files
run: ls -R release-artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
release-artifacts/windows-build/*
release-artifacts/macos-build/*
release-artifacts/linux-build/*
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}