%global _build_id_links none %global debug_package %{nil} %undefine source_date_epoch_from_changelog %global upstream_version 1.0.8 %global software_name gitea-runner Name: %{software_name} Version: %{upstream_version} Release: 1%{?dist} Summary: A runner for Gitea Actions License: MIT URL: https://gitea.com/gitea/runner # Upstream module path is gitea.com/gitea/runner; the produced binary is named # "gitea-runner" via the -o flag below (the bare `go build` default is "runner"). # Source0 unpacks to gitea-runner-%{upstream_version}/ (archive prefix set by the # vendor workflow). Source0: v%{upstream_version}.tar.gz # Vendored Go modules for offline/limited-network builds. Source1: %{software_name}-%{upstream_version}-vendor.tar.gz # Systemd service file Source2: %{software_name}.service # Sysusers configuration Source3: %{software_name}.sysusers BuildRequires: tar, golang, systemd-rpm-macros %{?systemd_requires} %description Gitea Actions runner runs jobs defined in Gitea Actions workflows. It supports both host and container (Docker) execution backends. %prep %autosetup -p1 -n %{software_name}-%{upstream_version} # Use vendored Go modules to minimize network access during build. tar -xf %{SOURCE1} if [ ! -d vendor ]; then echo "ERROR: vendor/ directory not found. Provide a vendored modules tarball via Source1." >&2 exit 1 fi %build export GOPROXY=off export GOSUMDB=off export GOMODCACHE="$PWD/.gomodcache" # Default `go build` would name the binary after the module's last element # ("runner"); force the upstream/release name with -o. The version variable # matches what upstream's Makefile sets (prefixed with "v"). CGO_ENABLED=0 go build \ -v \ -trimpath \ -mod=vendor \ -modcacherw \ -buildvcs=false \ -ldflags="-s -w -X 'gitea.com/gitea/runner/internal/pkg/ver.version=v%{upstream_version}'" \ -o %{software_name} \ . # Chicken-and-egg: the sample config is produced by the program itself # (`gitea-runner generate-config`, which prints the embedded config.example.yaml). # Generate it here from the freshly built binary so it always tracks the binary's # options. OBS builds natively per-arch, so running the just-compiled binary is fine. ./%{software_name} generate-config > config.yaml.generated %install # Install binary install -Dsm755 %{software_name} -t %{buildroot}%{_bindir} # Install systemd service file install -Dm644 %{SOURCE2} -t %{buildroot}%{_unitdir} # Install sysusers configuration install -Dm644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{software_name}.conf # Place the generated config as the initial /etc/gitea-runner/config.yaml, # marked %%config(noreplace) so local edits survive package upgrades. No separate # .example is shipped: the binary embeds the sample and can reprint it any time # with `gitea-runner generate-config`. install -Dm640 config.yaml.generated %{buildroot}%{_sysconfdir}/%{software_name}/config.yaml # State directory for the runner (.runner registration file lives here). install -d -m750 %{buildroot}%{_sharedstatedir}/%{software_name} %check %pre %if 0%{?suse_version} %service_add_pre %{software_name}.service %sysusers_create %{SOURCE3} %else %sysusers_create_compat %{SOURCE3} %endif %post %if 0%{?suse_version} %service_add_post %{software_name}.service %else %systemd_post %{software_name}.service %endif %preun %if 0%{?suse_version} %service_del_preun %{software_name}.service %else %systemd_preun %{software_name}.service %endif %postun %if 0%{?suse_version} %service_del_postun %{software_name}.service %else %systemd_postun_with_restart %{software_name}.service %endif %files %license LICENSE %doc README.md %{_bindir}/%{software_name} %{_unitdir}/%{software_name}.service %{_sysusersdir}/%{software_name}.conf %dir %{_sysconfdir}/%{software_name} %config(noreplace) %attr(0640,root,%{software_name}) %{_sysconfdir}/%{software_name}/config.yaml %dir %attr(0750,%{software_name},%{software_name}) %{_sharedstatedir}/%{software_name} %changelog