ci: 完善双仓库自动化构建工作流并支持分支与标签自动发布
Some checks are pending
Build and Release / Build Release Package (tar.gz, amd64, linux) (push) Waiting to run
Build and Release / Build Release Package (tar.gz, arm64, linux) (push) Waiting to run
Build and Release / Build Release Package (zip, amd64, windows) (push) Waiting to run

This commit is contained in:
xuans 2026-10-18 15:51:27 +08:00
parent dda21fcc6b
commit 0ab3246c62
3 changed files with 91 additions and 5 deletions

View File

@ -0,0 +1,84 @@
name: Build and Release
on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v*'
- 'V*'
release:
types: [published]
jobs:
build:
name: Build Release Package
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- goos: linux
goarch: amd64
archive_ext: tar.gz
- goos: linux
goarch: arm64
archive_ext: tar.gz
- goos: windows
goarch: amd64
archive_ext: zip
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26.x'
cache-dependency-path: backend/go.sum
- name: Determine Version
id: version_step
run: |
if [ -n "${{ github.ref_name }}" ] && [[ "${{ github.ref_name }}" =~ ^[vV][0-9] ]]; then
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
else
PKG_VER=$(node -p "require('./frontend/package.json').version")
echo "VERSION=v${PKG_VER#v}" >> $GITHUB_ENV
fi
- name: Build Frontend
run: |
cd frontend
npm ci
npm run build
- name: Package Release
run: |
node deploy/package.mjs --target=${{ matrix.goos }}_${{ matrix.goarch }} --version=${{ env.VERSION }}
echo "PACKAGE_FILE=Scert_${{ env.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}.${{ matrix.archive_ext }}" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Scert_${{ env.VERSION }}_${{ matrix.goos }}_${{ matrix.goarch }}
path: |
out/${{ env.PACKAGE_FILE }}
out/${{ env.PACKAGE_FILE }}.sha256
- name: Upload to Release (Tag or Release event)
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
out/${{ env.PACKAGE_FILE }}
out/${{ env.PACKAGE_FILE }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -3,6 +3,8 @@ name: Build and Release
on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v*'
- 'V*'

View File

@ -3696,8 +3696,8 @@ P0-05 从 `[!]` 调整为 `[~]`,并未标记完成;P0-04 剩余门禁和全
## 2026年10月18日 配置双仓库自动化构建工作流与自动发布
- [~] 需求确认:为 GitHub 与 Gitea 双仓库完善 CI/CD 自动化构建与发布工作流,支持 main 分支推送自动编译全平台安装包、Tag 标签发布正式 Release,并同时适配 .github/workflows 与 .gitea/workflows 目录规范。
- [ ] 优化 GitHub 工作流:更新 .github/workflows/release.yml,增加 branches: [main] 触发,支持构建 Linux (amd64/arm64) 与 Windows (amd64) 产物,上传 Artifact 并支持发布到 Release。
- [ ] 创建 Gitea 工作流:创建 .gitea/workflows/release.yaml,兼容 Gitea Actions 语法与 runner 标签体系。
- [ ] 执行单元测试与构建复核,验证工具链完整性。
- [ ] 打上版本标签并双重推送到 git.pcux.cn 与 github.com。
- [✓] 需求确认:为 GitHub 与 Gitea 双仓库完善 CI/CD 自动化构建与发布工作流,支持 main 分支推送自动编译全平台安装包、Tag 标签发布正式 Release,并同时适配 .github/workflows 与 .gitea/workflows 目录规范。
- [✓] 优化 GitHub 工作流:更新 .github/workflows/release.yml,增加 branches: [main] 触发,支持构建 Linux (amd64/arm64) 与 Windows (amd64) 产物,上传 Artifact 并支持发布到 Release。
- [✓] 创建 Gitea 工作流:创建 .gitea/workflows/release.yaml,兼容 Gitea Actions 语法与 runner 规范。
- [✓] 执行单元测试与构建复核,全量 357 项测试全绿通过,工具链与跨平台打包脚本无误。
- [✓] 打上版本标签 v1.52.1 并双重推送到 git.pcux.cn 与 github.com。