File webhook.spec of Package webhook

#
# spec file for package webhook
#
# Copyright (c) 2024 Georg Pfuetzenreuter <mail+rpm@georg-pfuetzenreuter.net>
# Copyright (c) 2020-2021, Martin Hauke <mardnh@gmx.de>
#
# 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 https://bugs.opensuse.org/
#


Name:           webhook
Version:        0
Release:        0
Summary:        Lightweight incoming webhook server
License:        MIT
Group:          Productivity/Networking/Other
URL:            https://github.com/adnanh/webhook
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        %{name}.sysuser
Source3:        %{name}.service
Source4:        %{name}.sysconfig
BuildRequires:  dos2unix
BuildRequires:  golang(API) >= 1.14
BuildRequires:  golang-packaging
BuildRequires:  pkgconfig
BuildRequires:  sysuser-tools
BuildRequires:  pkgconfig(systemd)
%systemd_ordering

%description
Webhook is a lightweight configurable tool written in Go, that allows
you to easily create HTTP endpoints (hooks) on your server, which you
can use to execute configured commands. You can also pass data from
the HTTP request (such as headers, payload or query variables) to
your commands. webhook also allows you to specify rules which have to
be satisfied in order for the hook to be triggered.

For example, if you're using Github or Bitbucket, you can use webhook
to set up a hook that runs a redeploy script for your project on your
staging server, whenever you push changes to the master branch of
your project.

%prep
%autosetup -a1

# wrong-file-end-of-line-encoding
dos2unix README.md

%build
go build -mod=vendor -v -p 4 -x -buildmode=pie -ldflags='-s -w'
%sysusers_generate_pre %{SOURCE2} %{name}

%install
install -dv %{buildroot}%{_bindir} %{buildroot}%{_fillupdir} %{buildroot}%{_sbindir} %{buildroot}%{_sysconfdir}/%{name} %{buildroot}%{_sysusersdir} %{buildroot}%{_unitdir} %{buildroot}%{_localstatedir}/log/%{name}

install -v %{name} %{buildroot}%{_bindir}/%{name}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}

install -vm0644 %{SOURCE2} %{buildroot}%{_sysusersdir}/%{name}.conf
install -vm0644 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}.service
install -vm0644 %{SOURCE4} %{buildroot}%{_fillupdir}/sysconfig.%{name}

%pre -f %{name}.pre
%service_add_pre %{name}.service

%post
%{fillup_only -n %{name}}
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%license LICENSE
%doc hooks.*.example README.md
%{_bindir}/%{name}
%{_sbindir}/rc%{name}
%{_sysusersdir}/%{name}.conf
%{_unitdir}/%{name}.service
%{_fillupdir}/sysconfig.%{name}
%attr(0750,-,%{name}) %dir %{_sysconfdir}/%{name}

%changelog
openSUSE Build Service is sponsored by