ci: 添加 Gitea Actions 的 CI 与发布流程,移除 .github/workflows
- ci.yml:push main 时起 postgres:16 服务容器,应用 schema.sql 并补建 llm_usage, 跑 go mod verify / go vet / go test -p 1 ./...;不接 PR 触发。 -skip 掉当前已失败的 TestGraphOverviewExpandsAssociatedCompanyScope。 - release.yml:v* tag 触发,只构建 linux/amd64 与 linux/arm64,从 CHANGELOG 提取说明,用 gitea-release-action 建 Release 上传 zip 与 SHA256SUMS, 再用 buildx 推多架构镜像到 gitea.bcde.io/wangdefa/artex。 - .dockerignore:排除 dist 下的 zip 与中间产物,只放 dist/<arch>/artex 进构建上下文。 - 删除 .github/workflows:本仓库 CI/CD 全部走 .gitea/workflows。留着的副本会被 Gitea 一并扫描,同一个 tag 触发两套发布流程、重复建 Release。
This commit is contained in:
1 parent
f782b612ec
commit
2511c2e041
4 files changed
+248
-135
No files matched your search
@@ -0,0 +1,129 @@
|
||||
# Gitea Actions:推送 v* tag 时构建 linux/amd64 + linux/arm64 发行包、发布 Release,
|
||||
# 并推送多架构镜像(两个架构都进镜像)。
|
||||
#
|
||||
# 产物:
|
||||
# - Release 附件:artex-<版本>-<os>-<arch>.zip + SHA256SUMS(selfupdate 约定的结构)
|
||||
# - 容器镜像:gitea.bcde.io/wangdefa/artex:<tag> 与 :latest(linux/amd64 + linux/arm64)
|
||||
#
|
||||
# 需要配置的仓库 Secret:
|
||||
# GITEA_TOKEN 由 Gitea 自动注入,无需手工创建;contents: write 即可建 Release。
|
||||
# BUILD_TOKEN 个人访问令牌,勾选 write:package。GITEA_TOKEN 不能推包仓库,
|
||||
# 所以镜像推送必须用它;不配的话这一步会失败并提示。
|
||||
#
|
||||
# 运行环境:带 ubuntu-latest-amd64 标签的 Gitea Runner(可换 ubuntu-latest-arm64)。
|
||||
# 二进制由 build.sh 交叉编译,镜像里只装工具链,arm64 只模拟 apt 层。
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
env:
|
||||
# 不生成 provenance/SBOM 附加清单:部分 registry 版本对上镜像 digest 会报错。
|
||||
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
||||
|
||||
permissions:
|
||||
contents: write # 建 Release + 传附件(Gitea 里 contents 覆盖 code 与 releases)
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest-amd64
|
||||
# arm64 那半程要在 QEMU 下跑 apt + Playwright,给足时间。
|
||||
timeout-minutes: 120
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.26"
|
||||
cache: false
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: false
|
||||
|
||||
- name: 补齐打包工具
|
||||
run: |
|
||||
missing=""
|
||||
for t in rsync zip git; do
|
||||
command -v "$t" >/dev/null 2>&1 || missing="$missing $t"
|
||||
done
|
||||
if [ -n "$missing" ]; then
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq $missing
|
||||
fi
|
||||
|
||||
- name: 构建并打包(linux/amd64 + linux/arm64)
|
||||
env:
|
||||
ARTEX_BUILD_VERSION: ${{ gitea.ref_name }}
|
||||
# build.sh --release 默认出 5 个平台,这里显式收窄到两个。
|
||||
ARTEX_TARGETS: linux/amd64,linux/arm64
|
||||
ARTEX_COMPRESS: "0"
|
||||
ARTEX_PACKAGE: "1"
|
||||
run: ./build.sh --release
|
||||
|
||||
- name: 输出校验和
|
||||
run: |
|
||||
ls -lh dist/*.zip
|
||||
cat dist/SHA256SUMS
|
||||
|
||||
- name: 从 CHANGELOG 提取本版说明
|
||||
run: |
|
||||
TAG="${{ gitea.ref_name }}"
|
||||
awk -v ver="${TAG#v}" '
|
||||
$0 ~ "^## \\[" ver "\\]" { flag = 1; next }
|
||||
/^## \[/ && flag { exit }
|
||||
flag { print }
|
||||
' CHANGELOG.md > release-notes.md
|
||||
[ -s release-notes.md ] || echo "Release ${TAG}" > release-notes.md
|
||||
echo "--- release-notes.md ---"
|
||||
cat release-notes.md
|
||||
|
||||
- name: 创建 Release 并上传附件
|
||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||
with:
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
body_path: release-notes.md
|
||||
files: |-
|
||||
dist/*.zip
|
||||
dist/SHA256SUMS
|
||||
|
||||
- name: 准备镜像构建上下文
|
||||
run: |
|
||||
# Dockerfile 只从 dist/<arch>/artex 取预编译二进制,这里按 TARGETARCH 摆好。
|
||||
mkdir -p dist/amd64 dist/arm64
|
||||
cp dist/artex-linux-amd64/artex dist/amd64/artex
|
||||
cp dist/artex-linux-arm64/artex dist/arm64/artex
|
||||
ls -lh dist/amd64/artex dist/arm64/artex
|
||||
|
||||
- name: 推送多架构镜像
|
||||
env:
|
||||
TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
REGISTRY="$(echo '${{ gitea.server_url }}' | sed 's|https\?://||')"
|
||||
# Docker 仓库名必须小写,仓库名是 ARTEX,这里统一转小写。
|
||||
IMAGE="$(echo "${REGISTRY}/${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
if [ -z "$TOKEN" ]; then
|
||||
echo "缺少 repository secret BUILD_TOKEN(需 write:package)——无法推送镜像。" >&2
|
||||
echo "GITEA_TOKEN 不能推包仓库,必须另外建一个 PAT。" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$TOKEN" | docker login "$REGISTRY" -u "${{ gitea.repository_owner }}" --password-stdin
|
||||
|
||||
# 多平台清单需要 docker-container driver;已存在则沿用。
|
||||
docker buildx create --use --driver docker-container --driver-opt network=host >/dev/null 2>&1 || true
|
||||
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t "${IMAGE}:${{ gitea.ref_name }}" \
|
||||
-t "${IMAGE}:latest" \
|
||||
--push .
|
||||
|
||||
echo "已推送 ${IMAGE}:${{ gitea.ref_name }} 与 ${IMAGE}:latest"
|
||||
Reference in new issue
Block a user