跳到主要内容

Gitea Runner 3.0.0 已发布

· 阅读需 10 分钟
bircni
Technical Oversight Committee
本文由 AI 翻译,如有歧义请以 英文原文 为准。
Banner for blog post with title "Gitea Runner 3.0.0 已发布"

我们很高兴宣布 Gitea Runner 3.0.0 发布。

本次发布的亮点是 缓存服务 v2:标准的 actions/upload-artifactactions/download-artifactactions/cache 现在可以直接在 Gitea Runner 上使用,无需 gitea-upload-artifact 分支。除此之外,3.0.0 还新增了容器逃逸加固、编码 secret 掩码、作业钩子、代理传播,以及针对两个守护进程共享同一个 runner 文件的安全防护。

这是一个 runner 端的发布。它与现有 Gitea 版本保持兼容;主版本号提升体现了三项破坏性变更,而非对服务器的新依赖。

3.0.0 亮点

内置制品和缓存 actions — 无需 fork

Gitea Runner 现在在现有 v1 缓存 API 的基础上提供 GitHub Actions github.actions.results.api.v1.CacheService (v2) 服务,共享同一存储,并支持 @actions/toolkit 上传器所用的 Azure blob 协议子集 (#1110)。

实际上这意味着未经修改的上游 actions 可以直接使用:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache
key: deps-${{ hashFiles('**/lockfile') }}
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

actions/upload-artifact / actions/download-artifact(v4.4.0 及更新版本)和 actions/cache 不再需要 gitea-upload-artifact fork 或自行编写的变通方案。runner 在加载时会修补 action 包,以开启 GHES 入口并从 ACTIONS_CACHE_URL 读取缓存端点;这一机制已通过 118 个真实 action 包(涵盖 16 个 actions)的验证。

信息

默认启用。 缓存服务 v2 由 runner 内置的缓存服务器通过 cache.v2 设置提供,同时兼容 external_server 缓存配置。如果你当前部署了 gitea-upload-artifact fork,请参阅下方的破坏性变更说明。

强化容器逃逸防护

当特权模式禁用时,工作流控制的容器选项不再未经处理地合并到 Docker 的 HostConfig 中。runner 现在会剥离可用于突破容器隔离的选项 (#1058):

PidModeIpcModeUTSModeCgroupnsModeUsernsModeCapAddSecurityOptDevicesDeviceCgroupRulesDeviceRequestsVolumesFromRuntimeCgroupParentSysctls

当管理员显式启用特权模式时,这些选项会被保留,因为这本身就意味着允许扩展的主机访问。对于依赖非特权 runner 上这些选项的工作流而言,这是一项破坏性变更 —— 请参阅破坏性变更

编码后的 secret 遮蔽

此前,只有 secret 的原始值会被遮蔽,因此若某个 action 将 secret 序列化后泄露,日志中仍可读取。现在,每个 secret 和 ::add-mask:: 值在其编码形式下也会被遮蔽,匹配 GitHub runner 中的值编码器 (#1108):

  • JSON — 通过 toJSON(secrets) 转义的值
  • Base64 — 例如承载在 Authorization 头中的 secret
  • URL 百分比编码 — 嵌入 URL 的 secret

不会改变值的编码将被跳过,因此一个明文令牌仍然只需一个替换对。

作业钩子

运维人员现在可以在作业环境的两个生命周期点运行主机脚本,类似于 GitHub 的 ACTIONS_RUNNER_HOOK_JOB_STARTED / ACTIONS_RUNNER_HOOK_JOB_COMPLETED (#1111):

runner:
hooks:
job_started: /hooks/started.sh
job_completed: /hooks/completed.sh

job_started 在作业的第一个步骤之前运行,job_completed 在最后一个步骤之后运行。两者都会扫描其输出以获取工作流命令,读取 $GITHUB_ENV$GITHUB_PATH,并在非零退出码时使作业失败。这对于预热缓存、预置凭证或为每个作业发出遥测数据非常有用。

代理传播

runner 现在会设置 http_proxyhttps_proxyno_proxy(小写和大写),使其控制的所有组件都使用它们 —— 作业、服务容器和 Dockerfile action 构建#1112)。

对于作业,合理的地址会自动添加到 no_proxy:缓存服务器、回环地址、作业服务容器和 Docker 守护进程(以确保 docker-in-docker 继续工作)。当你使用 dind 镜像时,守护进程会读取相同的代理变量,而 runner 在启动时若检测到代理不一致会发出警告。

工具缓存重定位和挂载修复

设置 RUNNER_TOOL_CACHE 现在会实际重定位工具缓存,而不仅仅是更改变量,因此 ${{ runner.tool_cache }} 和环境变量保持一致(#1122)。同一变更使得作业和服务卷可以在相同目标上替换冲突的挂载,修复了 name:/target:ro 在逐字路径 /target:ro 上被挂载为读写的问题,并让 config.yaml 中的未知键产生警告,而不是静默消失。

破坏性变更

1. 缓存服务 v2 默认启用(#1110)。 Runner 现在开箱即用地提供 v2 CacheService。如果你之前部署了 gitea-upload-artifact fork 或自定义的 artifact/cache 垫片,请将其移除,并将你的工作流切换到原生的 actions/upload-artifact@v4actions/download-artifact@v4actions/cache@v4。如果必须保留旧行为,可通过 cache.v2: false 将其禁用。

2. 非特权模式下会剥离主机逃逸容器选项(#1058)。 工作流如果在 container.options 中设置了诸如 PidModeCapAddSecurityOptDevicesSysctls 等选项,在非特权 runner 上将不再被应用。如果工作流确实需要这些选项,请将其运行在管理员明确启用了特权模式的 runner 上 — 此边界现在是强制执行的,而不是悄悄绕过的。

3. 每个 .runner 文件一个 runner 进程(#1099)。 守护进程和 register 现在在启动时会对同级的 <runner-file>.lock 加锁,使用非阻塞建议锁。两个进程如果共享同一个 .runner 文件,之前会展示相同的 UUID+令牌凭据,因此 Gitea 将其视为一个 runner,导致它们互相取消对方的任务。现在同一主机上的第二个进程会快速失败,并显示明确的错误。为每个守护进程提供其自己的 .runner 文件。操作系统在退出时会自动释放锁,即使是强行终止,因此不会累积过期的锁。通过 NFS 共享 runner 文件的跨主机设置,仍然依赖 Gitea 服务端的检测。

升级说明

  • 在 Docker Compose、Kubernetes 资源清单以及服务单元中,将 gitea/runner:2.x 替换为 gitea/runner:3.0.0
  • 如果你使用了 gitea-upload-artifact 分支或产物/缓存相关变通方案,请将其移除,并迁移至上游标准 actions(破坏性变更 1)。
  • 审查所有设定了 container.options 主机命名空间或设备标志的工作流;在确实需要这些权限的 runner 上启用特权模式(破坏性变更 2)。
  • 在推广部署前,确保每个 runner 守护进程都有自己的 .runner 文件(破坏性变更 3)。
  • 如果你在代理后运行,请检查自动生成的 no_proxy 条目,并针对 dind 确认守护进程与 runner 的代理设置保持一致。
  • 在全面推广前,在预发布环境中测试产物的上传/下载、缓存恢复以及工作流取消功能。

下载

预编译二进制文件可在 Gitea Runner 下载页面 获取。

该版本也提供在 Gitea Runner 发布页面

致谢

感谢所有自 2.0.0 发布以来,通过贡献代码、参与测试、提交错误报告、完善文档以及提供反馈而做出贡献的每一个人。


以下 Changelog 保留英文原文,未作翻译,请与上游逐字核对。

Changelog

3.0.0 - 2026-08-05

  • BREAKING

    • Add cache service v2 next to the v1 cache API so stock actions/upload-artifact/download-artifact (v4.4.0+) and actions/cache work without the fork (#1110)
    • Strip host-escape container options (PidMode, CapAdd, SecurityOpt, Devices, Sysctls, …) when privileged mode is disabled (#1058)
    • Guard against two runner processes sharing one .runner file with an advisory lock (#1099)
  • FEATURES

    • Add job hooks runner.hooks.job_started / runner.hooks.job_completed (#1111)
    • Propagate http_proxy/https_proxy/no_proxy to jobs, services, and Dockerfile action builds (#1112)
    • Mask secrets that reach the log in JSON, base64, and URL-encoded forms (#1108)
  • BUGFIXES

    • Relocate the tool cache with RUNNER_TOOL_CACHE, allow mounting over runner paths, and warn on unknown config keys (#1122)
    • Stop leaking per-job docker networks (#1124)
    • Copy action directories into job containers when the target path is symlinked (e.g. /var/run/run), including on Docker 29.7 (#1130, #1129)
    • Fix panics and enable the forcetypeassert lint (#1123)
    • Update github.com/ulikunitz/xz to v0.5.15 (security) (#1127)

2.3.0 - 2026-07-28

  • FEATURES

    • Run pre-entrypoint and post-entrypoint of docker actions (#1106)
    • Report runner name, environment, workspace, and debug info to jobs (#1105)
    • Support --platform and --pull in container.options (#1104)
    • Read cache.external_secret from a file (#1100)
  • BUGFIXES

    • Escape command data the runner writes itself (#1120)
    • Clean up service containers after failed job setup (#1066)

2.2.0 - 2026-07-22

  • FEATURES

    • Add runner health admission checks (#1090)
    • Report a GitHub-style "Set up job" section (#1089)
  • BUGFIXES

    • Repair the free-disk-space build on FreeBSD (#1098)
    • Stop host-mode jobs from leaking processes on Windows (#1080)
    • Classify a cancelled step as an interruption, not a failure (#1095)
    • Stop racing the daemon when removing containers (#1093)
    • Guard status-check functions against a nil job context (#1092)

2.1.0 - 2026-07-16

  • FEATURES

    • Honor GITEA_RUNNER_LABELS on daemon start with colon-containing labels (#1085)
    • Add --token-file flag to the register command (#1076)
    • Add bug-report subcommand, exec --eventpath, and runner.set_act_env (#1075)
  • BUGFIXES

    • Ignore blank lines and decode UTF-16 in runner env files (#1084)
    • Prevent service containers from overwriting job container credentials (#1083)
    • Support natively typed boolean workflow inputs (#1087)
    • Remove action outputs exceeding size limits (#1070)

2.0.1 - 2026-07-09

  • BUGFIXES
    • Skip service containers with an empty image (#1074)
    • Prevent exponential growth of RunContext masks in composite actions (#1059)
    • Attach task token when cloning actions from a self-hosted instance on a different host (#1056)
    • Install nftables in dind images to silence nft cleanup errors (#1064)