mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 17:05:32 +08:00
feat: Add GitHub Actions workflow for automated release artifact generation, update Vercel configuration, and document the release process.
This commit is contained in:
83
.github/workflows/release-artifacts.yml
vendored
Normal file
83
.github/workflows/release-artifacts.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
name: Release Artifacts
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-and-upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.25.x"
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
cache: "npm"
|
||||
cache-dependency-path: webui/package-lock.json
|
||||
|
||||
- name: Build WebUI
|
||||
run: |
|
||||
npm ci --prefix webui
|
||||
npm run build --prefix webui
|
||||
|
||||
- name: Build Multi-Platform Archives
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="${{ github.event.release.tag_name }}"
|
||||
mkdir -p dist
|
||||
|
||||
targets=(
|
||||
"linux/amd64"
|
||||
"linux/arm64"
|
||||
"darwin/amd64"
|
||||
"darwin/arm64"
|
||||
"windows/amd64"
|
||||
)
|
||||
|
||||
for target in "${targets[@]}"; do
|
||||
GOOS="${target%/*}"
|
||||
GOARCH="${target#*/}"
|
||||
PKG="ds2api_${TAG}_${GOOS}_${GOARCH}"
|
||||
STAGE="dist/${PKG}"
|
||||
BIN="ds2api"
|
||||
if [ "${GOOS}" = "windows" ]; then
|
||||
BIN="ds2api.exe"
|
||||
fi
|
||||
|
||||
mkdir -p "${STAGE}/static"
|
||||
CGO_ENABLED=0 GOOS="${GOOS}" GOARCH="${GOARCH}" \
|
||||
go build -trimpath -ldflags="-s -w" -o "${STAGE}/${BIN}" ./cmd/ds2api
|
||||
|
||||
cp config.example.json .env.example sha3_wasm_bg.7b9ca65ddd.wasm LICENSE README.MD README.en.md "${STAGE}/"
|
||||
cp -R static/admin "${STAGE}/static/admin"
|
||||
|
||||
if [ "${GOOS}" = "windows" ]; then
|
||||
(cd dist && zip -rq "${PKG}.zip" "${PKG}")
|
||||
else
|
||||
tar -C dist -czf "dist/${PKG}.tar.gz" "${PKG}"
|
||||
fi
|
||||
|
||||
rm -rf "${STAGE}"
|
||||
done
|
||||
|
||||
(cd dist && sha256sum *.tar.gz *.zip > sha256sums.txt)
|
||||
|
||||
- name: Upload Release Assets
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: |
|
||||
dist/*.tar.gz
|
||||
dist/*.zip
|
||||
dist/sha256sums.txt
|
||||
10
DEPLOY.en.md
10
DEPLOY.en.md
@@ -62,6 +62,7 @@ Notes:
|
||||
|
||||
- Serverless entry: `api/index.go`
|
||||
- Rewrites and cache headers: `vercel.json`
|
||||
- Legacy `builds` has been removed to avoid the `unused-build-settings` warning
|
||||
|
||||
Minimum environment variables:
|
||||
|
||||
@@ -84,6 +85,15 @@ After deploy, verify:
|
||||
- `/v1/models`
|
||||
- `/admin`
|
||||
|
||||
## 3.1 GitHub Release Automation
|
||||
|
||||
This repo includes `.github/workflows/release-artifacts.yml`:
|
||||
|
||||
- Triggers only on Release `published`
|
||||
- Does not run on `push`
|
||||
- Builds Linux/macOS/Windows archives and uploads them to Release Assets
|
||||
- Generates `sha256sums.txt` for integrity checks
|
||||
|
||||
## 4. Reverse Proxy (Nginx)
|
||||
|
||||
Disable buffering for SSE:
|
||||
|
||||
10
DEPLOY.md
10
DEPLOY.md
@@ -62,6 +62,7 @@ docker-compose up -d --build
|
||||
|
||||
- serverless 入口:`api/index.go`
|
||||
- 路由与缓存头:`vercel.json`
|
||||
- 已移除 legacy `builds` 字段,避免 `unused-build-settings` 警告
|
||||
|
||||
至少配置环境变量:
|
||||
|
||||
@@ -84,6 +85,15 @@ docker-compose up -d --build
|
||||
- `/v1/models`
|
||||
- `/admin`
|
||||
|
||||
## 3.1 GitHub Release 自动构建
|
||||
|
||||
仓库包含 `.github/workflows/release-artifacts.yml`:
|
||||
|
||||
- 仅在 Release `published` 时触发
|
||||
- 不在 `push` 时触发
|
||||
- 自动构建 Linux/macOS/Windows 二进制包并上传到 Release Assets
|
||||
- 生成 `sha256sums.txt` 供校验
|
||||
|
||||
## 4. 反向代理(Nginx)
|
||||
|
||||
如果在 Nginx 后挂载,建议关闭缓冲以保证 SSE:
|
||||
|
||||
32
README.MD
32
README.MD
@@ -89,6 +89,38 @@ docker-compose logs -f
|
||||
- `DS2API_ADMIN_KEY`
|
||||
- `DS2API_CONFIG_JSON`(JSON 字符串或 Base64)
|
||||
|
||||
说明:`vercel.json` 已移除 legacy `builds` 配置,避免部署时出现
|
||||
`unused-build-settings` 警告,并使用当前推荐的函数路由模式。
|
||||
|
||||
## Release 自动构建产物(GitHub Actions)
|
||||
|
||||
仓库内置工作流:`.github/workflows/release-artifacts.yml`
|
||||
|
||||
- 触发条件:仅在 GitHub Release `published` 时触发
|
||||
- 不会在普通 `push` 时构建
|
||||
- 构建内容:多平台二进制包(Linux/macOS/Windows)+ `sha256sums.txt`
|
||||
- 每个压缩包包含:
|
||||
- `ds2api` 可执行文件(Windows 为 `ds2api.exe`)
|
||||
- `static/admin`(WebUI 构建产物)
|
||||
- `sha3_wasm_bg.7b9ca65ddd.wasm`
|
||||
- `config.example.json`、`.env.example`
|
||||
- `README.MD`、`README.en.md`、`LICENSE`
|
||||
|
||||
维护者发布步骤:
|
||||
|
||||
1. 在 GitHub 创建并发布 Release(带 tag,如 `v1.7.0`)
|
||||
2. 等待 Actions 工作流 `Release Artifacts` 完成
|
||||
3. 在 Release 的 Assets 下载对应平台压缩包
|
||||
|
||||
下载后运行示例(Linux/macOS):
|
||||
|
||||
```bash
|
||||
tar -xzf ds2api_v1.7.0_linux_amd64.tar.gz
|
||||
cd ds2api_v1.7.0_linux_amd64
|
||||
cp config.example.json config.json
|
||||
./ds2api
|
||||
```
|
||||
|
||||
## 配置说明
|
||||
|
||||
### `config.json` 示例
|
||||
|
||||
32
README.en.md
32
README.en.md
@@ -89,6 +89,38 @@ docker-compose logs -f
|
||||
- `DS2API_ADMIN_KEY`
|
||||
- `DS2API_CONFIG_JSON` (raw JSON or Base64)
|
||||
|
||||
Note: legacy `builds` has been removed from `vercel.json` to avoid
|
||||
the `unused-build-settings` warning and to follow the current function routing model.
|
||||
|
||||
## Release Artifact Automation (GitHub Actions)
|
||||
|
||||
Built-in workflow: `.github/workflows/release-artifacts.yml`
|
||||
|
||||
- Trigger: only when a GitHub Release is `published`
|
||||
- No build on normal `push`
|
||||
- Outputs: multi-platform binaries (Linux/macOS/Windows) + `sha256sums.txt`
|
||||
- Each archive includes:
|
||||
- `ds2api` executable (`ds2api.exe` on Windows)
|
||||
- `static/admin` (built WebUI assets)
|
||||
- `sha3_wasm_bg.7b9ca65ddd.wasm`
|
||||
- `config.example.json`, `.env.example`
|
||||
- `README.MD`, `README.en.md`, `LICENSE`
|
||||
|
||||
Maintainer release flow:
|
||||
|
||||
1. Create and publish a GitHub Release (with tag, e.g. `v1.7.0`)
|
||||
2. Wait for the `Release Artifacts` workflow to finish
|
||||
3. Download the matching archive from Release Assets
|
||||
|
||||
Run from downloaded archive (Linux/macOS):
|
||||
|
||||
```bash
|
||||
tar -xzf ds2api_v1.7.0_linux_amd64.tar.gz
|
||||
cd ds2api_v1.7.0_linux_amd64
|
||||
cp config.example.json config.json
|
||||
./ds2api
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### `config.json` example
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
{
|
||||
"version": 2,
|
||||
"builds": [
|
||||
{
|
||||
"src": "api/index.go",
|
||||
"use": "@vercel/go"
|
||||
}
|
||||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/(.*)",
|
||||
"destination": "/api/index.go"
|
||||
"destination": "/api/index"
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
|
||||
Reference in New Issue
Block a user