Files
wangdefa ba2f4b4b06
ci / frontend (push) Successful in 52s
ci / backend (push) Failing after 1m31s
ci: 修复首次运行的两处失败
- backend:日志显示服务名 postgres 无法解析(runner 为 host 网络,services 只
  发布端口、不提供容器别名)。给 service 加 55432:5432 端口映射,并改为依次
  探测 postgres:5432 与 127.0.0.1:55432,连上后写入 PG* 与 ARTEX_PG_DSN;
  都不通时打印解析结果,便于判断网络模式。
- frontend/release:setup-node 的 cache 只接受 npm/yarn/pnpm,之前的
  cache: false 会导致 "Caching for 'false' is not supported" 直接失败,去掉该键。
2026-10-20 21:54:06 -07:00

130 lines
4.7 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 只接受 npm / yarn / pnpm,写 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"