Skip to content

清理意外混杂的代码(此版本暂时不可用) #113

清理意外混杂的代码(此版本暂时不可用)

清理意外混杂的代码(此版本暂时不可用) #113

Workflow file for this run

# 在主分支上构建
name: build
on:
push: # push 触发
branches:
- next
jobs:
<<<<<<< HEAD

Check failure on line 9 in .github/workflows/build-app.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-app.yml

Invalid workflow file

You have an error in your yaml syntax on line 9
# ========================= 准备项目 =========================
init:
name: 初始化构建
runs-on: ubuntu-latest
outputs:
build_web: ${{ steps.step_init.outputs.BUILD_WEB }}
build_electron: ${{ steps.step_init.outputs.BUILD_ELECTRON }}
version: ${{ steps.step_init.outputs.VERSION }}
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
# 初始化一些流程需要的环境变量
- name: Init Env
id: step_init
run: |
# 获取版本号
echo VERSION=$(node -p "require('./package.json').version") >> $GITHUB_OUTPUT
=======
# ========================= 准备项目 =========================
init:
name: 初始化构建
runs-on: ubuntu-latest
outputs:
version: ${{ steps.step_init.outputs.VERSION }}
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
# 初始化一些流程需要的环境变量
- name: Init Env
id: step_init
run: echo VERSION=$(node -p "require('./package.json').version") >> $GITHUB_OUTPUT
>>>>>>> 6fae082 (初始化 vite(此版本不可用))
# ========================= 构建 Web 版本 =========================
build-root-web:
name: 构建 Web 版本(根目录)
runs-on: ubuntu-latest
needs: init
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
# 设置 Node.js 版本
- name: Load Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
# 更新依赖
- name: Install
run: yarn
# 构建
- name: Build
run: yarn build
# 将 dist 目录压缩为 zip
- name: Zip
run: zip -r Stapxs.QQ.Lite-${{ needs.init.outputs.version }}-web.zip dist
# 上传构建结果
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ needs.init.outputs.version }}-web
path: Stapxs.QQ.Lite-${{ needs.init.outputs.version }}-web.zip
# ==================== 构建 Github Pages 版本 =====================
build-pages:
name: 构建 Github Pages 版本
runs-on: ubuntu-latest
needs: init
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
# 设置 Node.js 版本
- name: Load Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
# 更新依赖
- name: Install
run: yarn
# 构建
- name: Build
run: yarn build
env:
NODEJS_ENV: github-actions
# 部署 Web 版本
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.ACCESS_TOKEN }}
branch: gh-pages
folder: dist
# ========================= 构建 Electron 版本 =========================
build-electron:
name: 构建 Electron 版本
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019, ubuntu-latest]
outputs:
version: ${{ needs.init.outputs.version }}
needs: init
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
# 设置 Node.js 版本
- name: Load Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
# 更新依赖
- name: Install
run: yarn
# 构建 electron 版本(Windows)
- name: Build Electron (Windows)
if: matrix.os == 'windows-2019'
run: yarn electron:build --win
env:
NODEJS_ENV: github-actions
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 构建 electron 版本(Linux)
- name: Build Electron (Linux)
if: matrix.os == 'ubuntu-latest'
run: yarn electron:build --linux
env:
NODEJS_ENV: github-actions
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 上传构建结果
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ needs.init.outputs.version }}-${{ matrix.os }}
path: dist_electron/out
# ========================= 发布构建结果 =========================
release:
name: 发布构建结果
runs-on: ubuntu-latest
needs:
- build-root-web
- build-electron
steps:
# 下载构建结果
- name: Download Artifacts
id: download-artifact
uses: actions/download-artifact@v4
with:
path: ${{ needs.build-electron.outputs.version }}
pattern: ${{ needs.build-electron.outputs.version }}-*
merge-multiple: true
- name: Artifacts List
run: ls -R
# 发布构建结果
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
files: ./${{ needs.build-electron.outputs.version }}/*
tag_name: v${{ needs.build-electron.outputs.version }}
body: |
# Release 自动构建
`这是一个自动构建版本,由 GitHub Actions 自动构建并发布。`
## 更新内容
${{ github.event.head_commit.message }}
## 自动构建信息
- 构建时间:${{ github.event.head_commit.timestamp }}
- 构建提交:${{ github.event.head_commit.id }}
- 构建分支:${{ github.event.head_commit.tree_id }}
draft: false
prerelease: false
token: ${{ secrets.ACCESS_TOKEN }}