🐞 fix: fix some bugs #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cd for ez-cursor-free | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
# Windows 构建 | |
build-windows: | |
name: Build for Windows | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: Install Dependencies | |
run: pnpm install | |
- name: Build Electron App | |
run: pnpm run build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Windows Package | |
run: pnpm run build:win | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: List Build Output | |
run: dir dist | |
shell: cmd | |
- name: Upload Windows Artifacts | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
dist/*.* | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fail_on_unmatched_files: false | |
# Mac 构建 | |
build-macos: | |
name: Build for macOS | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: Install Dependencies | |
run: pnpm install | |
# 添加 Rosetta 2 支持 | |
- name: Install Rosetta 2 | |
run: softwareupdate --install-rosetta --agree-to-license | |
- name: Build Electron App | |
run: pnpm run build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 分别构建 Intel 和 ARM 版本 | |
- name: Build macOS Intel Package | |
run: pnpm run build:mac --x64 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build macOS ARM Package | |
run: pnpm run build:mac --arm64 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: List Build Output | |
run: ls -la dist | |
- name: Upload macOS Artifacts | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
dist/*.* | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fail_on_unmatched_files: false | |
# Linux 构建 | |
build-linux: | |
name: Build for Linux | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.x" | |
# 更新 Ubuntu 软件源 | |
- name: Ubuntu Update with sudo | |
run: sudo apt-get update | |
# 安装依赖 | |
- name: Install RPM & Pacman | |
run: | | |
sudo apt-get install --no-install-recommends -y rpm && | |
sudo apt-get install --no-install-recommends -y libarchive-tools && | |
sudo apt-get install --no-install-recommends -y libopenjp2-tools | |
# 安装项目依赖 | |
- name: Install Dependencies | |
run: npm install | |
# 构建 Electron App | |
- name: Build Electron App for Linux | |
run: npm run build:linux || true | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 上传构建产物 | |
- name: Upload Linux Artifacts | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
dist/*.* | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fail_on_unmatched_files: false | |
# 创建 Release | |
create-release: | |
needs: [build-windows, build-macos, build-linux] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # 获取完整的 git 历史记录 | |
- name: Generate Release Notes | |
id: release_notes | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/v} | |
echo "Processing version: $VERSION" | |
# 首先尝试从 CHANGELOG.md 获取 | |
if [ -f CHANGELOG.md ]; then | |
CHANGES=$(awk -v ver="$VERSION" ' | |
BEGIN { found=0; content="" } | |
/^## \[?'$VERSION'\]?/ { found=1; next } | |
/^## \[?[0-9]+\.[0-9]+\.[0-9]+/ { if (found) exit } | |
{ if (found) content = content $0 "\n" } | |
END { printf "%s", content } | |
' CHANGELOG.md) | |
fi | |
# 如果 CHANGELOG 中没有找到,则使用 git log | |
if [ -z "$CHANGES" ]; then | |
echo "No changelog entry found, using git log..." | |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
if [ -n "$PREV_TAG" ]; then | |
CHANGES=$(git log --pretty=format:"* %s" $PREV_TAG..HEAD) | |
else | |
CHANGES=$(git log --pretty=format:"* %s" -n 10) | |
fi | |
fi | |
# 如果还是空的,使用默认消息 | |
if [ -z "$CHANGES" ]; then | |
CHANGES="Release version $VERSION" | |
fi | |
# 添加版本标题 | |
FINAL_NOTES="## Release v$VERSION\n\n$CHANGES" | |
# 输出到 GITHUB_OUTPUT | |
{ | |
echo "CHANGES<<EOF" | |
echo -e "$FINAL_NOTES" | |
echo "EOF" | |
} >> $GITHUB_OUTPUT | |
# 调试输出 | |
echo "Generated release notes:" | |
echo -e "$FINAL_NOTES" | |
shell: bash | |
- name: Update Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
name: Release ${{ github.ref_name }} | |
body: ${{ steps.release_notes.outputs.CHANGES }} | |
draft: false | |
prerelease: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
generate_release_notes: false # 不使用 GitHub 自动生成的发布说明 |