feat: align with upstream 1.5.9.9

This commit is contained in:
2026-09-12 18:21:11 +08:00
commit 34f0679117
805 changed files with 376275 additions and 0 deletions
+125
View File
@@ -0,0 +1,125 @@
# .github/workflows/build-fpk.yml
# VoiceHub 飞牛 fnOS FPK 安装包自动构建
# 手动触发,版本号自动从 package.json 读取
name: Build VoiceHub FPK
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
build-fpk:
if: github.repository == 'laoshuikaixue/VoiceHub' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: 读取版本号 & 安装 fnpack
run: |
# 读取原始版本号
ORIGINAL_VER=$(node -p "require('./package.json').version")
echo "📦 原始版本: $ORIGINAL_VER"
# 转换为三段式版本号 (x.y.zw 格式,将第四段拼接到第三段)
FNOS_VER=$(echo "$ORIGINAL_VER" | awk -F. '{
if (NF >= 4) {
# 四段式版本号,拼接最后两段
printf "%s.%s.%s%s", $1, $2, $3, $4
} else if (NF == 3) {
# 已经是三段式,直接使用
printf "%s.%s.%s", $1, $2, $3
} else {
# 其他情况,保持原样
print $0
}
}')
echo "APP_VER=$FNOS_VER" >> "$GITHUB_ENV"
echo "📦 转换后版本: $FNOS_VER"
wget -q https://static2.fnnas.com/fnpack/fnpack-1.2.1-linux-amd64 -O /usr/local/bin/fnpack
chmod +x /usr/local/bin/fnpack
- name: 创建 FPK 目录
run: |
fnpack create voicehub --template docker
echo "📁 模板结构:"
find voicehub -type f | sort
- name: 写入 manifest & 准备图标
run: |
# 复制仓库中的 fnos 模板
cp -r fnos/* voicehub/
# 从 public 目录复制图标到构建目录
mkdir -p voicehub/app/ui/images
cp public/assets/logo.png voicehub/app/ui/images/icon-64.png
cp public/assets/logo.png voicehub/app/ui/images/icon-256.png
cp public/assets/logo.png voicehub/ICON.PNG
cp public/assets/logo.png voicehub/ICON_256.PNG
# 更新版本号
sed -i "s/^version=.*/version=${APP_VER}/" voicehub/manifest
chmod +x voicehub/cmd/main
echo "✅ manifest, cmd/main & icons 已就绪"
- name: 从仓库读取 docker-compose-prebuild-nju.yml 并写入
run: |
# 从项目根目录读取仓库内的 compose 文件
SRC_COMPOSE="docker-compose/docker-compose-prebuild-nju.yml"
# 目标路径
DST_COMPOSE="voicehub/app/docker/docker-compose.yaml"
# 创建目录
mkdir -p voicehub/app/docker
# 复制内容并进行修改:
# 1. 移除 postgres 服务的端口映射,以避免 fnOS 5432 端口冲突
# 2. 移除 voicehub 服务的代码挂载 (.:/app),避免覆盖镜像内的预构建代码导致 MODULE_NOT_FOUND
# 3. 确保容器间通过 service name 互联
# 直接使用 awk 工具更精确地过滤掉整个 volumes 块和 ports 块中我们不想要的行,或者删除空块
awk '
/^[[:space:]]+volumes:/ { in_volumes=1; print; next }
/^[[:space:]]+ports:/ { in_ports=1; print; next }
/^[[:space:]]+restart:/ { in_volumes=0; in_ports=0; print; next }
/^[[:space:]]+[a-zA-Z0-9_]+:/ { in_volumes=0; in_ports=0; print; next }
in_volumes && /^[[:space:]]+-[[:space:]]+.:\/app/ { next }
in_volumes && /^[[:space:]]+-[[:space:]]+\/app\/node_modules/ { next }
in_ports && /^[[:space:]]+-[[:space:]]+.5432:5432./ { next }
{ print }
' "$SRC_COMPOSE" > "$DST_COMPOSE.tmp"
# 清理由于上述删除可能产生的空的 volumes: 或 ports: 标签
# 使用 grep 检查下一行是否是配置项或空行
sed -E '/^[[:space:]]+volumes:[[:space:]]*$/{N;/\n[[:space:]]+-/!d}' "$DST_COMPOSE.tmp" > "$DST_COMPOSE.tmp2"
sed -E '/^[[:space:]]+ports:[[:space:]]*$/{N;/\n[[:space:]]+-/!d}' "$DST_COMPOSE.tmp2" > "$DST_COMPOSE"
rm "$DST_COMPOSE.tmp" "$DST_COMPOSE.tmp2"
echo "✅ 已处理 compose 文件:移除数据库端口暴露 & 移除应用代码挂载"
cat "$DST_COMPOSE"
- name: 最终目录 & 打包
run: |
echo "📦 FPK 结构:"
find voicehub -type f | sort
echo "---"
cd voicehub
fnpack build
ls -lh *.fpk 2>/dev/null || { echo "❌ 打包失败"; exit 1; }
mv *.fpk ../
- name: 上传 Artifact
uses: actions/upload-artifact@v7
with:
name: voicehub-fpk-${{ env.APP_VER }}
path: "*.fpk"
retention-days: 30
+222
View File
@@ -0,0 +1,222 @@
name: Build and Push Docker Image
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual trigger'
required: false
default: 'Manual trigger'
env:
REGISTRY: ghcr.io
jobs:
# 阶段1:优先构建并推送 amd64 架构,立即可用
build-amd64:
if: github.repository == 'laoshuikaixue/VoiceHub' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Prepare lowercase names
id: names
run: |
echo "image-name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
echo "actor-name=$(echo '${{ github.actor }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Extract version from package.json
id: extract-version
run: |
FULL_VERSION=$(node -p "require('./package.json').version")
MAJOR_MINOR_VERSION=$(echo "$FULL_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\.[0-9]+$/\1/')
echo "full-version=$FULL_VERSION" >> $GITHUB_OUTPUT
echo "major-minor-version=$MAJOR_MINOR_VERSION" >> $GITHUB_OUTPUT
echo "Extracted full version: $FULL_VERSION"
echo "Extracted major.minor version: $MAJOR_MINOR_VERSION"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ steps.names.outputs.actor-name }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ steps.names.outputs.image-name }}
tags: |
# 正式标签 - amd64 构建完成后立即可用
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=raw,value=${{ steps.extract-version.outputs.full-version }}
type=raw,value=${{ steps.extract-version.outputs.major-minor-version }}
# 架构后缀标签 - 用于后续多架构合并
type=raw,value=latest-amd64,enable={{is_default_branch}}
type=raw,value=${{ steps.extract-version.outputs.full-version }}-amd64
type=raw,value=${{ steps.extract-version.outputs.major-minor-version }}-amd64
- name: Build and push amd64 image
uses: docker/build-push-action@v7
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha,scope=amd64
cache-to: type=gha,mode=max,scope=amd64
# 阶段2:并行构建其余架构,各自推送带后缀的独立标签
build-other-arches:
if: github.repository == 'laoshuikaixue/VoiceHub' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
arch:
- { platform: linux/arm64, suffix: -arm64 }
- { platform: linux/arm/v7, suffix: -armv7 }
- { platform: linux/arm/v6, suffix: -armv6 }
- { platform: linux/ppc64le, suffix: -ppc64le }
- { platform: linux/s390x, suffix: -s390x }
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Prepare lowercase names
id: names
run: |
echo "image-name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
echo "actor-name=$(echo '${{ github.actor }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Extract version from package.json
id: extract-version
run: |
FULL_VERSION=$(node -p "require('./package.json').version")
MAJOR_MINOR_VERSION=$(echo "$FULL_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\.[0-9]+$/\1/')
echo "full-version=$FULL_VERSION" >> $GITHUB_OUTPUT
echo "major-minor-version=$MAJOR_MINOR_VERSION" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ steps.names.outputs.actor-name }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ steps.names.outputs.image-name }}
tags: |
type=raw,value=latest${{ matrix.arch.suffix }},enable={{is_default_branch}}
type=raw,value=${{ steps.extract-version.outputs.full-version }}${{ matrix.arch.suffix }}
type=raw,value=${{ steps.extract-version.outputs.major-minor-version }}${{ matrix.arch.suffix }}
- name: Build and push ${{ matrix.arch.platform }} image
uses: docker/build-push-action@v7
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.arch.platform }}
cache-from: type=gha,scope=${{ matrix.arch.suffix }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch.suffix }}
# 阶段3:所有架构构建完成后,合并为多架构 manifest 清单并推送正式标签
merge-manifests:
if: (github.repository == 'laoshuikaixue/VoiceHub' || github.event_name == 'workflow_dispatch') && github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: [build-amd64, build-other-arches]
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Prepare lowercase names
id: names
run: |
echo "image-name=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
echo "actor-name=$(echo '${{ github.actor }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Extract version from package.json
id: extract-version
run: |
FULL_VERSION=$(node -p "require('./package.json').version")
MAJOR_MINOR_VERSION=$(echo "$FULL_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\.[0-9]+$/\1/')
echo "full-version=$FULL_VERSION" >> $GITHUB_OUTPUT
echo "major-minor-version=$MAJOR_MINOR_VERSION" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ steps.names.outputs.actor-name }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-architecture manifest lists
env:
IMAGE_BASE: ${{ env.REGISTRY }}/${{ steps.names.outputs.image-name }}
FULL_VER: ${{ steps.extract-version.outputs.full-version }}
MAJOR_MINOR_VER: ${{ steps.extract-version.outputs.major-minor-version }}
run: |
# 所有架构后缀列表
ARCH_SUFFIXES=("-amd64" "-arm64" "-armv7" "-armv6" "-ppc64le" "-s390x")
# 生成指定标签的所有架构镜像参数
build_arch_args() {
local tag=$1
local args=""
for suffix in "${ARCH_SUFFIXES[@]}"; do
args="$args ${IMAGE_BASE}:${tag}${suffix}"
done
echo "$args"
}
# 合并 latest 标签(仅默认分支)
if [ "${{ github.ref == 'refs/heads/main' }}" = "true" ]; then
echo "Merging multi-arch manifest for latest tag"
docker buildx imagetools create -t "${IMAGE_BASE}:latest" $(build_arch_args "latest")
fi
# 合并完整版本号标签
echo "Merging multi-arch manifest for ${FULL_VER} tag"
docker buildx imagetools create -t "${IMAGE_BASE}:${FULL_VER}" $(build_arch_args "${FULL_VER}")
# 合并主次版本号标签
echo "Merging multi-arch manifest for ${MAJOR_MINOR_VER} tag"
docker buildx imagetools create -t "${IMAGE_BASE}:${MAJOR_MINOR_VER}" $(build_arch_args "${MAJOR_MINOR_VER}")
+79
View File
@@ -0,0 +1,79 @@
name: Build and Push PostgreSQL Docker Image
on:
push:
branches: [main]
paths:
- 'Dockerfile-postgres'
- '.github/workflows/docker-postgres.yml'
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual trigger'
required: false
default: 'Manual trigger'
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
if: github.repository == 'laoshuikaixue/VoiceHub' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: '0'
# 转换仓库名、用户名全小写,解决GHCR大写报错
- name: Generate lowercase image & actor name
id: lowercase
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
ACTOR_LOWER=$(echo "${{ github.actor }}" | tr '[:upper:]' '[:lower:]')
IMAGE_FULL="${REPO_LOWER}-postgres"
echo "repo_lower=$REPO_LOWER" >> $GITHUB_OUTPUT
echo "actor_lower=$ACTOR_LOWER" >> $GITHUB_OUTPUT
echo "image_name=$IMAGE_FULL" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ steps.lowercase.outputs.actor_lower }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ steps.lowercase.outputs.image_name }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=15-alpine,enable={{is_default_branch}}
- name: Build and push PostgreSQL Docker image
id: build-and-push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile-postgres
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x,linux/386,linux/riscv64
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
sbom: false
+32
View File
@@ -0,0 +1,32 @@
name: Nix CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
nix-check:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/determinate-nix-action@v3
- name: Setup Cachix binary cache
uses: cachix/cachix-action@v14
with:
name: voicehub
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Run nix flake check
run: nix flake check
- name: Build voicehub (validate hashes)
run: nix build .#voicehub
+110
View File
@@ -0,0 +1,110 @@
name: 更新 Nix pnpm 依赖哈希
on:
push:
paths:
- pnpm-lock.yaml
- flake.nix
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- pnpm-lock.yaml
- flake.nix
workflow_dispatch:
permissions:
contents: write
concurrency:
group: update-nix-pnpm-hash-${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}
cancel-in-progress: true
jobs:
update-hash:
name: 同步 pnpmDeps 哈希
if: github.actor != 'github-actions[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
env:
TARGET_BRANCH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}
CHECKOUT_REPOSITORY: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
steps:
- name: 检出触发分支
uses: actions/checkout@v4
with:
repository: ${{ env.CHECKOUT_REPOSITORY }}
ref: ${{ env.TARGET_BRANCH }}
- name: 安装 Nix
uses: DeterminateSystems/determinate-nix-action@v3
- name: 配置 Git 提交身份
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: 计算 pnpmDeps 哈希
shell: bash
run: |
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
path = Path("flake.nix")
text = path.read_text(encoding="utf-8")
marker = "pnpmDeps = pkgs.fetchPnpmDeps {"
start = text.index(marker)
key = 'hash = "'
hash_start = text.index(key, start) + len(key)
hash_end = text.index('"', hash_start)
path.write_text(text[:hash_start] + text[hash_end:], encoding="utf-8")
PY
set +e
nix build .#voicehub --no-link 2>&1 | tee nix-build.log
status="${PIPESTATUS[0]}"
set -e
if [ "$status" -eq 0 ]; then
echo "Nix 构建在空哈希下意外成功,无法提取新的 pnpmDeps 哈希。"
exit 1
fi
new_hash="$(grep -Eo 'got:[[:space:]]+sha256-[A-Za-z0-9+/=_-]+' nix-build.log | tail -n 1 | sed -E 's/got:[[:space:]]+//')"
if [ -z "$new_hash" ]; then
echo "没有在 Nix 输出中找到 got: sha256-...,请查看上方日志。"
exit 1
fi
HASH="$new_hash" python3 - <<'PY'
import os
from pathlib import Path
new_hash = os.environ["HASH"]
path = Path("flake.nix")
text = path.read_text(encoding="utf-8")
marker = "pnpmDeps = pkgs.fetchPnpmDeps {"
start = text.index(marker)
key = 'hash = "'
hash_start = text.index(key, start) + len(key)
hash_end = text.index('"', hash_start)
path.write_text(text[:hash_start] + new_hash + text[hash_end:], encoding="utf-8")
PY
echo "新的 pnpmDeps 哈希: $new_hash"
- name: 提交哈希更新
shell: bash
run: |
set -euo pipefail
if git diff --quiet -- flake.nix; then
echo "pnpmDeps 哈希已经是最新,无需提交。"
exit 0
fi
git add flake.nix
git commit -m "ci: 同步 pnpmDeps 哈希"
git push origin "HEAD:${TARGET_BRANCH}"