mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-12-06 08:03:46 +00:00
- moejs 迁到 github.com/MoeForge/moejs v0.1.0,Dockerfile、Electron 构建与发布流程的 PGO 路径同步更新;发布附带 THIRD-PARTY-LICENSES.md,并补充 moejs 附带的第三方声明。 - moego 升级到 v0.1.0-alpha.2:宿主 JSON 编解码经 common/kitutil 封装改用 moego/json,根模块和 relaykit 生产代码的 regexp 改用 moego/regexp。 - 内存中的请求体由校验器零拷贝解析;磁盘缓存的请求体经独立文件读取器解码,且只接受一个 JSON 值,尾随内容会被拒绝。 - 模型/分组提取与重复 model 键检测、渠道亲和 JSON 路径、任务协议 stream/background 标志、multipart 解析在磁盘模式下不再把整份请求体读进内存。图片透传直接转发已存储的请求体,并校验最终发往上游的 n。 - 出站请求体各自持有读取位置。此前透传重试共用存储游标,上一次尝试仍在发送时,下一次尝试可能发出残缺的请求体。收到响应头后不再提前关闭请求体,避免中断仍在发送的请求体。 - 表达式计费只在表达式使用 param() 时冻结请求体,其余情况不再读取并保留整份请求体。
142 lines
4.3 KiB
YAML
142 lines
4.3 KiB
YAML
name: Build Electron App
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*' # Triggers on version tags like v1.0.0
|
|
- '!*-*' # Ignore pre-release tags like v1.0.0-beta
|
|
- '!*-alpha*' # Ignore alpha tags like v1.0.0-alpha
|
|
workflow_dispatch: # Allows manual triggering
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
# os: [macos-latest, windows-latest]
|
|
os: [windows-latest]
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
|
with:
|
|
bun-version: '1.4.4'
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Build frontend
|
|
env:
|
|
CI: ""
|
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
|
run: |
|
|
cd web
|
|
bun install --frozen-lockfile
|
|
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags) bun run build
|
|
cd ..
|
|
|
|
# - name: Build Go binary (macos/Linux)
|
|
# if: runner.os != 'Windows'
|
|
# run: |
|
|
# go mod download
|
|
# go build -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o new-api
|
|
|
|
- name: Build Go binary (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
go mod download
|
|
go build -pgo="$(go list -m -f '{{.Dir}}' github.com/MoeForge/moejs)/default.pgo" -ldflags "-s -w -X 'github.com/QuantumNous/new-api/common.Version=$(git describe --tags)'" -o new-api.exe
|
|
|
|
- name: Update Electron version
|
|
run: |
|
|
cd electron
|
|
VERSION=$(git describe --tags)
|
|
VERSION=${VERSION#v} # Remove 'v' prefix if present
|
|
# Convert to valid semver: take first 3 components and convert rest to prerelease format
|
|
# e.g., 0.9.3-patch.1 -> 0.9.3-patch.1
|
|
if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$ ]]; then
|
|
MAJOR=${BASH_REMATCH[1]}
|
|
MINOR=${BASH_REMATCH[2]}
|
|
PATCH=${BASH_REMATCH[3]}
|
|
REST=${BASH_REMATCH[4]}
|
|
|
|
VERSION="$MAJOR.$MINOR.$PATCH"
|
|
|
|
# If there's extra content, append it without adding -dev
|
|
if [[ -n "$REST" ]]; then
|
|
VERSION="$VERSION$REST"
|
|
fi
|
|
fi
|
|
npm version $VERSION --no-git-tag-version --allow-same-version
|
|
|
|
- name: Install Electron dependencies
|
|
run: |
|
|
cd electron
|
|
npm install
|
|
|
|
# - name: Build Electron app (macOS)
|
|
# if: runner.os == 'macOS'
|
|
# run: |
|
|
# cd electron
|
|
# npm run build:mac
|
|
# env:
|
|
# CSC_IDENTITY_AUTO_DISCOVERY: false # Skip code signing
|
|
|
|
- name: Build Electron app (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
cd electron
|
|
npm run build:win
|
|
|
|
# - name: Upload artifacts (macOS)
|
|
# if: runner.os == 'macOS'
|
|
# uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
# with:
|
|
# name: macos-build
|
|
# path: |
|
|
# electron/dist/*.dmg
|
|
# electron/dist/*.zip
|
|
|
|
- name: Upload artifacts (Windows)
|
|
if: runner.os == 'Windows'
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: windows-build
|
|
path: |
|
|
electron/dist/*.exe
|
|
|
|
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@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
|
|
- name: Upload to Release
|
|
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
|
|
with:
|
|
files: |
|
|
windows-build/*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|