Skip to content

fix(ci): 优化 Windows 构建产物并修复更新器类型 #9

fix(ci): 优化 Windows 构建产物并修复更新器类型

fix(ci): 优化 Windows 构建产物并修复更新器类型 #9

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- os: macos-latest
platform: mac
- os: windows-latest
platform: win
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 pnpm
uses: pnpm/action-setup@v4
with:
# 显式使用与 package.json 中一致的 pnpm 版本
version: 9.15.0
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build for ${{ matrix.platform }}
run: pnpm electron:build:${{ matrix.platform }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove universal exe (keep only arch-specific)
if: matrix.platform == 'win'
shell: bash
run: |
# 删除通用 exe,只保留带架构标识的
find dist -name "*.exe" ! -name "*-x64.exe" ! -name "*-arm64.exe" -delete || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-build
path: |
dist/*.dmg
dist/*-x64.exe
dist/*-arm64.exe
if-no-files-found: ignore
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/*
draft: false
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
generate_release_notes: true
body: |
## 📦 下载安装
| 平台 | 芯片 | 下载 |
|------|------|------|
| macOS | Intel 芯片 | `PromptHub-${{ github.ref_name }}-x64.dmg` |
| macOS | M 系列芯片 | `PromptHub-${{ github.ref_name }}-arm64.dmg` |
| Windows | x64 | `PromptHub-Setup-${{ github.ref_name }}-x64.exe` |
### ⚠️ macOS 首次启动
如果提示"无法打开"或"已损坏",请在终端执行:
```bash
sudo xattr -rd com.apple.quarantine /Applications/PromptHub.app
```
---
## 🔄 本次更新
详细更新日志请查看 [更新日志](https://github.com/legeling/PromptHub#-更新日志)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}