File gitlab-runner.spec of Package gitlab-runner
#
# spec file for package gitlab-git-http-server
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define pkg_version 18.3.1
%define branch 18-3-stable
%define revision v%{pkg_version}
%define pkg gitlab.com/gitlab-org/gitlab-runner
%define common_pkg %{pkg}/common
%define go_ldflags -X %{common_pkg}.NAME=gitlab-runner -X %{common_pkg}.VERSION=%{version} \
-X %{common_pkg}.REVISION=%{revision} -X %{common_pkg}.BUILT=${SOURCE_DATE} \
-X %{common_pkg}.BRANCH=%{branch}
Name: gitlab-runner
Version: %{pkg_version}
Release: 0
License: MIT
Summary: GitLab Runner
ExclusiveArch: x86_64 aarch64
Url: https://gitlab.com/gitlab-org/gitlab-runner/-/tags
Group: Development/Tools/Version Control
Source0: https://gitlab.com/gitlab-org/%{name}/-/archive/v%{pkg_version}/%{name}-v%{pkg_version}.tar.bz2
Source2: %{name}.service
Source3: config.toml
Source98: vendor.tar.xz
Source99: series
Patch1: default-helper-image-to-our-image.patch
Requires(pre): gitlab-common >= 10.0.0
Requires: gitlab-common >= 10.0.0
BuildRequires: pkgconfig(systemd)
BuildRequires: golang-packaging
BuildRequires: golang(API) >= 1.22
#BuildRequires: go >= 1.22
BuildRequires: go1.24
BuildRequires: unzip
Provides: gitlab-ci-multi-runner = %{version}-%{release}
Obsoletes: gitlab-ci-multi-runner < %{version}-%{release}
%go_nostrip
Requires: ca-certificates-mozilla
Requires: hostname
Recommends: (gitlab-runner-podman if podman)
Recommends: (gitlab-runner-docker if docker)
%description
The official GitLab Runner written in Go. It runs tests and sends the results
to GitLab. GitLab CI is the open-source continuous integration service
included with GitLab that coordinates the testing. The old name of this
project was GitLab CI Multi Runner but please use "GitLab Runner" (without CI)
from now on.
%package docker
Summary: Run GitLab Runner jobs on local docker daemon
Group: Development/Tools/Version Control
Requires: %{name} = %{version}
Requires(post): docker
Requires: docker
BuildArch: noarch
%description docker
This subpackage depends on docker and also offers a clear-docker-cache script,
that are useful in order to run GitLab Runner jobs on a local docker daemon.
%package podman
Summary: Run GitLab Runner jobs on local podman
Group: Development/Tools/Version Control
Requires: %{name} = %{version}
Requires(post): podman
Requires: podman
BuildArch: noarch
%description podman
This subpackage depends on docker and also offers a clear-docker-cache script,
that are useful in order to run GitLab Runner jobs on a local docker daemon.
%package helper
Summary: gitlab-runner helper binary
Group: Development/Tools/Version Control
# taken from the docker file in gitlab-runner/dockerfiles/runner-helper/Dockerfile
Requires: gitlab-common >= 10.0.0
Requires: ca-certificates-mozilla
Requires: perl
Requires: hostname
Requires: findutils
%description helper
This package holds the helper binary for the the gitlab-runner-helper image
%prep
%autosetup -p1 -n %{name}-v%{pkg_version} -a98
%build
export SOURCE_DATE="$(TZ=UTC date -u '+%%Y-%%m-%%dT%%H:%%M:%%SZ' -r ${RPM_SOURCE_DIR}/%{name}.changes)"
go build -buildmode=pie -mod=vendor -ldflags="%{go_ldflags}" -o gitlab-runner-helper ./apps/...
go build -buildmode=pie -mod=vendor -ldflags="%{go_ldflags}" -o gitlab-runner .
for binary in gitlab-runner gitlab-runner-helper ; do
./${binary} --version
done
%install
install -m 0755 -d %{buildroot}%{_bindir} %{buildroot}%{_sbindir}
install -m 0755 gitlab-runner %{buildroot}%{_sbindir}/
install -m 0755 gitlab-runner-helper ./tests/dockerfiles/gitlab-runner-helper-entrypoint/scripts/gitlab-runner-build %{buildroot}%{_bindir}
install -D -m 0644 %{S:2} %{buildroot}%{_unitdir}/%{name}.service
%if 0%{?suse_version}
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif
#
install -D -m 0755 {./packaging/root,%{buildroot}}%{_datadir}/gitlab-runner/clear-docker-cache
cp -a %{buildroot}%{_datadir}/gitlab-runner/clear-{docker,podman}-cache
perl -p -i -e 's|docker|podman|g' %{buildroot}%{_datadir}/gitlab-runner/clear-podman-cache
diff -urN %{buildroot}%{_datadir}/gitlab-runner/clear-{docker,podman}-cache ||:
install -D -m 0644 %{S:3} %{buildroot}%{_sysconfdir}/%{name}/config.toml
chmod -R u=rwX,g=rX,o= %{buildroot}%{_sysconfdir}/
# START BIG SYSTEMD
%if 0%{?suse_version}
%pre
%service_add_pre %{name}.service
%endif
%preun
%if 0%{?suse_version}
%service_del_preun %{name}.service
%else
%systemd_preun %{name}.service
%endif
%post
%if 0%{?suse_version}
%service_add_post %{name}.service
%else
%systemd_post %{name}.service
%endif
%post docker
/usr/share/gitlab-runner/clear-docker-cache || :
%post podman
/usr/share/gitlab-runner/clear-podman-cache || :
%postun
%if 0%{?suse_version}
%service_del_postun %{name}.service
%else
%systemd_postun_with_restart %{name}.service
%endif
# /END BIG SYSTEMD
%files
%license LICENSE
%doc *.md
%doc docs/
%config(noreplace) %attr(-,root,%{name}) %{_sysconfdir}/%{name}/
%{_sbindir}/gitlab-runner
%if 0%{?suse_version}
%{_sbindir}/rc%{name}
%endif
%{_unitdir}/%{name}.service
%files helper
%license LICENSE
%{_bindir}/gitlab-runner-helper
%{_bindir}/gitlab-runner-build
%files docker
%dir %{_datadir}/%{name}/
%{_datadir}/%{name}/clear-docker-cache
%files podman
%dir %{_datadir}/%{name}/
%{_datadir}/%{name}/clear-podman-cache