# Copyright 2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # The Gitea Actions runner (formerly act_runner): a Go daemon that # registers with a Gitea instance and executes CI workflow jobs, normally # in containers via the Docker daemon. Its fork of the act workflow engine # is vendored in-tree by upstream, so the Go module cache tarball covers # every dependency. EAPI=8 inherit go-module systemd # The Go dependency tarball lives as a release asset on this repository, # tagged gitea-runner-v. GITEA_RUNNER_DISTFILES="https://git.ipnmod.org/packages/local-ai-overlay/releases/download/gitea-runner-v${PV}" DESCRIPTION="Daemon that connects to a Gitea instance and runs CI action jobs" HOMEPAGE="https://gitea.com/gitea/runner" SRC_URI=" https://gitea.com/gitea/runner/archive/v${PV}.tar.gz -> ${P}.tar.gz ${GITEA_RUNNER_DISTFILES}/${P}-deps.tar.xz " # Gitea archives extract to the bare repository name. S="${WORKDIR}/runner" LICENSE="MIT" SLOT="$(ver_cut 1)" KEYWORDS="~amd64" # Since 5.0 the runner fetches actions and reusable workflows over git # itself instead of through the act engine, so git becomes a runtime # requirement on the runner host (upstream floor: 2.34.1). RDEPEND=" acct-group/gitea-runner acct-user/gitea-runner >=dev-vcs/git-2.34.1 " BDEPEND=">=dev-lang/go-1.27.3" src_prepare() { default einfo "Pointing the systemd unit at the slot's binary, config and work dir" sed -i -e "s#/usr/local/bin/gitea-runner#/usr/bin/gitea-runner-${SLOT}#" \ -e "s#/etc/gitea-runner/#/etc/gitea-runner-${SLOT}/#" \ -e "s#/var/lib/gitea-runner#/var/lib/gitea-runner-${SLOT}#" examples/systemd/gitea-runner.service || die grep -q "/usr/bin/gitea-runner-${SLOT}" examples/systemd/gitea-runner.service || die "unit path fix did not apply" } src_compile() { # Version stamped the same way upstream's release builds do it. # Upstream's Makefile also adds -s -w; leave stripping to Portage # instead (it would flag the binary as pre-stripped otherwise). local ldflags=( -X "gitea.com/gitea/runner/internal/pkg/ver.version=v${PV}" ) ego build -ldflags "${ldflags[*]}" -o gitea-runner # The default configuration file, generated by the freshly built # binary so it always matches this version's options. ./gitea-runner generate-config > config.yaml || die } src_install() { newbin gitea-runner gitea-runner-${SLOT} insinto /etc/gitea-runner-${SLOT} doins config.yaml # The init script derives every path from its service name, so one # template serves every slot. newinitd "${FILESDIR}"/gitea-runner.initd gitea-runner-${SLOT} newconfd "${FILESDIR}"/gitea-runner.confd gitea-runner-${SLOT} systemd_newunit examples/systemd/gitea-runner.service gitea-runner-${SLOT}.service sed "s/gitea-runner/gitea-runner-${SLOT}/" "${FILESDIR}"/gitea-runner.logrotate > "${T}"/logrotate || die insinto /etc/logrotate.d newins "${T}"/logrotate gitea-runner-${SLOT} # The .runner registration file and job workspaces live here, one # directory per slot: each slot is its own registered runner. keepdir /var/lib/gitea-runner-${SLOT} fowners gitea-runner:gitea-runner /var/lib/gitea-runner-${SLOT} } pkg_postinst() { elog "Register the runner before first start (as the service user, so" elog "the registration lands in the slot's working directory):" elog " su -s /bin/sh gitea-runner -c 'cd /var/lib/gitea-runner-${SLOT} && \\" elog " gitea-runner-${SLOT} register --config /etc/gitea-runner-${SLOT}/config.yaml'" elog "Then adjust /etc/gitea-runner-${SLOT}/config.yaml and start the" elog "gitea-runner-${SLOT} service. Each slot is its own runner: two slots" elog "on one host register separately, usually under different labels." elog elog "Coming from the unslotted install: the registration keeps its" elog "identity when its file moves," elog " mv /var/lib/gitea-runner/.runner /var/lib/gitea-runner-${SLOT}/" elog "then swap gitea-runner for gitea-runner-${SLOT} in the runlevel and" elog "clean the old install (emerge --depclean dev-util/gitea-runner:0)." ewarn "5.0 changes the runner's requirements:" ewarn "- Reusable workflows and builtin:checkout are fetched via git, and" ewarn " actions fall back to git when the archive download fails (5.1.1):" ewarn " git >=2.34.1 is required on the host, every JOB environment must" ewarn " be able to reach the Gitea instance directly (and trust its TLS" ewarn " certificate), and the fetch credentials (token or SSH key)" ewarn " persist in the job environment for later steps unless checkout" ewarn " sets persist-credentials: false." ewarn "- \${NAME} references in config.yaml are expanded from the" ewarn " environment and FAIL when unset; a literal dollar sign must be" ewarn " escaped as \$\$. Review existing configs before upgrading." ewarn "- Jobs must set 'runs-on' explicitly." ewarn "- 5.3.0 scopes cache entries by ref like GitHub does: every cache" ewarn " starts cold once after this upgrade." }