mirror of
https://github.com/timeshiftsauce/CeruMusic.git
synced 2025-11-25 19:37:38 +08:00
Update main.yml
This commit is contained in:
59
.github/workflows/main.yml
vendored
59
.github/workflows/main.yml
vendored
@@ -1,76 +1,63 @@
|
|||||||
name: AutoBuild
|
name: AutoBuild # 工作流的名称
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write # 给予写入仓库内容的权限
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # 确保引号包裹模式
|
- v* # 当推送以v开头的标签时触发此工作流
|
||||||
workflow_dispatch: # 添加手动触发选项用于测试
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
name: Build and Release Electron App
|
name: build and release electron app # 任务名称
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }} # 在matrix.os定义的操作系统上运行
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false # 如果一个任务失败,其他任务继续运行
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, macos-latest]
|
os: [windows-latest, macos-latest] # 在Windows和macOS上运行任务
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out git repository
|
- name: Check out git repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4 # 检出代码仓库
|
||||||
with:
|
|
||||||
fetch-depth: 0 # 获取所有历史记录和标签
|
|
||||||
|
|
||||||
- name: Debug - Print context information
|
|
||||||
run: |
|
|
||||||
echo "GitHub Ref: ${{ github.ref }}"
|
|
||||||
echo "GitHub Event Name: ${{ github.event_name }}"
|
|
||||||
echo "Tag: ${GITHUB_REF#refs/tags/}"
|
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 18 # 安装Node.js 18 (这里node环境是能够运行代码的环境)
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
npm i -g yarn
|
npm i -g yarn
|
||||||
yarn install --frozen-lockfile
|
yarn install # 安装项目依赖
|
||||||
|
|
||||||
- name: Build Electron App for Windows
|
- name: Build Electron App for windows
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest' # 只在Windows上运行
|
||||||
run: yarn build:win
|
run: yarn run build:win # 构建Windows版应用
|
||||||
|
|
||||||
- name: Build Electron App for macOS
|
- name: Build Electron App for macos
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-latest' # 只在macOS上运行
|
||||||
run: |
|
run: |
|
||||||
yarn run build:mac
|
yarn run build:mac
|
||||||
|
|
||||||
- name: List dist directory contents
|
|
||||||
run: ls -la dist/ || echo "dist directory does not exist"
|
|
||||||
|
|
||||||
- name: Cleanup Artifacts for Windows
|
- name: Cleanup Artifacts for Windows
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: |
|
||||||
npx del-cli "dist/*" "!dist/*.exe" "!dist/*.zip" "!dist/*.yml" || echo "Cleanup failed"
|
npx del-cli "dist/*" "!dist/*.exe" "!dist/*.zip" "!dist/*.yml" # 清理Windows构建产物,只保留特定文件
|
||||||
|
|
||||||
- name: Cleanup Artifacts for MacOS
|
- name: Cleanup Artifacts for MacOS
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-latest'
|
||||||
run: |
|
run: |
|
||||||
npx del-cli "dist/*" "!dist/(*.dmg|*.zip|latest*.yml)" || echo "Cleanup failed"
|
npx del-cli "dist/*" "!dist/(*.dmg|*.zip|latest*.yml)" # 清理macOS构建产物,只保留特定文件
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: electron-build-${{ matrix.os }}
|
name: ${{ matrix.os }}
|
||||||
path: dist/
|
path: dist # 上传构建产物作为工作流artifact
|
||||||
|
|
||||||
- name: Create Release
|
- name: release
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: dist/**/*
|
files: 'dist/**' # 将dist目录下所有文件添加到release
|
||||||
|
|||||||
Reference in New Issue
Block a user