Added RPM packaging for RHEL 8 and 9 based distros

This commit is contained in:
Toastie 2025-03-27 11:59:21 +13:00
parent e130c96cb2
commit f2cf4d01a9
Signed by: toastie_t0ast
GPG key ID: 74226CF45EEE5AAF
9 changed files with 225 additions and 30 deletions

7
.gitignore vendored
View file

@ -7,4 +7,9 @@
/config.yml
/transcripts
/Linux-x64
/Windows-x64
/Windows-x64
Folder.DotSettings.user
packaging/rpmbuild-nightly/
packaging/rpmbuild/

110
Jenkinsfile vendored
View file

@ -1,41 +1,95 @@
pipeline {
pipeline
{
agent any
stages {
stage('Setup Dependencies') {
steps {
stages
{
stage('Setup Dependencies')
{
steps
{
sh 'dotnet restore'
}
}
stage('Build') {
parallel {
stage('Linux') {
steps {
sh 'dotnet publish -r linux-x64 -c Release -p:PublishTrimmed=true --self-contained true --no-restore --output Linux-x64/'
sh 'mv Linux-x64/SupportChild Linux-x64/SupportChild-SC'
sh 'dotnet publish -r linux-x64 -c Release --self-contained false --no-restore --output Linux-x64/'
stage('Build')
{
parallel
{
stage('Linux')
{
steps
{
sh 'dotnet publish -r linux-x64 -c Release -p:PublishTrimmed=true --self-contained true --no-restore --output linux-x64/'
sh 'mv linux-x64/supportchild linux-x64/supportchild-sc'
sh 'dotnet publish -r linux-x64 -c Release --self-contained false --no-restore --output linux-x64/'
archiveArtifacts(artifacts: 'linux-x64/supportchild', caseSensitive: true)
archiveArtifacts(artifacts: 'linux-x64/supportchild-sc', caseSensitive: true)
}
}
stage('Windows') {
steps {
sh 'dotnet publish -r win-x64 -c Release -p:PublishTrimmed=true --self-contained true --no-restore --output Windows-x64/'
sh 'mv Windows-x64/SupportChild.exe Windows-x64/SupportChild-SC.exe'
sh 'dotnet publish -r win-x64 -c Release --self-contained false --no-restore --output Windows-x64/'
stage('Windows')
{
steps
{
sh 'dotnet publish -r win-x64 -c Release -p:PublishTrimmed=true --self-contained true --no-restore --output windows-x64/'
sh 'mv windows-x64/supportchild.exe windows-x64/supportchild-sc.exe'
sh 'dotnet publish -r win-x64 -c Release --self-contained false --no-restore --output windows-x64/'
archiveArtifacts(artifacts: 'windows-x64/supportchild.exe', caseSensitive: true)
archiveArtifacts(artifacts: 'windows-x64/supportchild-sc.exe', caseSensitive: true)
}
}
}
}
stage('Archive') {
parallel {
stage('Linux') {
steps {
archiveArtifacts(artifacts: 'Linux-x64/SupportChild', caseSensitive: true)
archiveArtifacts(artifacts: 'Linux-x64/SupportChild-SC', caseSensitive: true)
stage('RHEL9')
{
agent
{
dockerfile
{
filename 'packaging/RHEL9.Dockerfile'
}
}
environment
{
DOTNET_CLI_HOME = "/tmp/.dotnet"
}
when
{
expression
{
return env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'beta' || env.BRANCH_NAME == 'jenkins-testing';
}
}
steps
{
sh 'rpmbuild -bb packaging/supportchild-nightly.spec --define "_topdir $PWD/.rpmbuild-el9"'
sh 'mkdir linux-x64'
sh 'cp .rpmbuild-el9/RPMS/x86_64/supportchild-nightly-*.el9.x86_64.rpm linux-x64/'
archiveArtifacts(artifacts: 'linux-x64/supportchild-nightly-*.el9.x86_64.rpm', caseSensitive: true)
}
}
stage('Windows') {
steps {
archiveArtifacts(artifacts: 'Windows-x64/SupportChild.exe', caseSensitive: true)
archiveArtifacts(artifacts: 'Windows-x64/SupportChild-SC.exe', caseSensitive: true)
stage('RHEL8')
{
agent
{
dockerfile
{
filename 'packaging/RHEL8.Dockerfile'
}
}
environment
{
DOTNET_CLI_HOME = "/tmp/.dotnet"
}
when
{
expression
{
return env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'beta' || env.BRANCH_NAME == 'jenkins-testing';
}
}
steps
{
sh 'rpmbuild -bb packaging/supportchild-nightly.spec --define "_topdir $PWD/.rpmbuild-el8"'
sh 'mkdir linux-x64'
sh 'cp .rpmbuild-el8/RPMS/x86_64/supportchild-nightly-*.el8.x86_64.rpm linux-x64/'
archiveArtifacts(artifacts: 'linux-x64/supportchild-nightly-*.el8.x86_64.rpm', caseSensitive: true)
}
}
}

View file

@ -5,6 +5,7 @@
<Version>4.0.1</Version>
<ApplicationIcon>ellie_icon.ico</ApplicationIcon>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>supportchild</AssemblyName>
<StartupObject>SupportChild.SupportChild</StartupObject>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<PublishSingleFile>true</PublishSingleFile>

View file

@ -4,6 +4,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.Entities;
@ -102,7 +103,7 @@ public static class Utilities
throw new InvalidOperationException("Could not load manifest resource stream.");
}
using StreamReader reader = new StreamReader(stream);
using StreamReader reader = new StreamReader(stream, Encoding.Unicode);
return reader.ReadToEnd();
}

View file

@ -0,0 +1,2 @@
FROM redhat/ubi8:latest
RUN dnf install dotnet-sdk-9.0 rpm-build git -y

View file

@ -0,0 +1,2 @@
FROM redhat/ubi9:latest
RUN dnf install dotnet-sdk-9.0 rpm-build git -y

View file

@ -0,0 +1,58 @@
%global debug_package %{nil}
%global repo_root %{_topdir}/..
Summary: A support ticket Discord bot
Name: supportchild-nightly
Version: %(sed -ne '/Version/{s/.*<Version>\(.*\)<\/Version>.*/\1/p;q;}' < SupportChild.csproj)
Release: %(date "+%%Y%%m%%d%%H%%M%%S")%{?dist}
License: GPLv3
URL: https://toastielab.dev/toastie-stuff/SupportChild
Source: https://toastielab.dev/toastie-stuff/SupportChild/archive/main.zip
Packager: Toastie_t0ast
BuildRequires: systemd-rpm-macros
Requires: dotnet-runtime-9.0
%{?systemd_requires}
%description
A support ticket Discord bot. Uses a MySQL database for storage of ticket
information. Creates formatted HTML ticket transcripts when tickets are closed.
%prep
%setup -T -c
%build
dotnet publish %{repo_root}/SupportChild.csproj -p:PublishSingleFile=true -r linux-x64 -c Release --self-contained false --output %{_builddir}/out
%install
%{__install} -d %{buildroot}/usr/bin
%{__install} %{_builddir}/out/supportchild %{buildroot}/usr/bin/supportchild
# rpmbuild post-processing using the strip command breaks dotnet binaries, remove the executable bit to avoid it
chmod 644 %{buildroot}/usr/bin/supportchild
%{__install} -d %{buildroot}/usr/lib/systemd/system
%{__install} %{repo_root}/packaging/supportchild.service %{buildroot}/usr/lib/systemd/system/
%{__install} -d %{buildroot}/etc/supportchild/
%{__install} %{repo_root}/default_config.yml %{buildroot}/etc/supportchild/config.yml
%pre
getent group supportchild > /dev/null || groupadd supportchild
getent passwd supportchild > /dev/null || useradd -r -s /sbin/nologin -g supportchild supportchild
%post
%systemd_post supportchild.service
%preun
%systemd_preun supportchild.service
%postun
%systemd_postun_with_restart supportchild.service
if [[ "$1" == "0" ]]; then
getent passwd supportchild > /dev/null && userdel supportchild
fi
%files
%attr(0755,root,root) /usr/bin/supportchild
%attr(0644,root,root) /usr/lib/systemd/system/supportchild.service
%config %attr(0600, supportchild, supportchild) /etc/supportchild/config.yml

View file

@ -0,0 +1,14 @@
[Unit]
Description=SupportChild Ticket Discord Bot
Documentation=https://toastielab.dev/toastie-stuff/SupportChild
After=network.target
Wants=network.target
[Service]
User=supportchild
ExecStart=/usr/bin/supportchild --config /etc/supportchild/config.yml
Restart=no
Type=exec
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,58 @@
%global debug_package %{nil}
%global repo_root %{_topdir}/..
Summary: A support ticket Discord bot
Name: supportchild
Version: %(sed -ne '/Version/{s/.*<Version>\(.*\)<\/Version>.*/\1/p;q;}' < SupportChild.csproj)
Release: 1%{?dist}
License: GPLv3
URL: https://toastielab.dev/toastie-stuff/SupportChild
Source: https://toastielab.dev/toastie-stuff/SupportChild/archive/main.zip
Packager: Toastie_t0ast
BuildRequires: systemd-rpm-macros
Requires: dotnet-runtime-9.0
%{?systemd_requires}
%description
A support ticket Discord bot. Uses a MySQL database for storage of ticket
information. Creates formatted HTML ticket transcripts when tickets are closed.
%prep
%setup -T -c
%build
dotnet publish %{repo_root}/SupportChild.csproj -p:PublishSingleFile=true -r linux-x64 -c Release --self-contained false --output %{_builddir}/out
%install
%{__install} -d %{buildroot}/usr/bin
%{__install} %{_builddir}/out/supportchild %{buildroot}/usr/bin/supportchild
# rpmbuild post-processing using the strip command breaks dotnet binaries, remove the executable bit to avoid it
chmod 644 %{buildroot}/usr/bin/supportchild
%{__install} -d %{buildroot}/usr/lib/systemd/system
%{__install} %{repo_root}/packaging/supportchild.service %{buildroot}/usr/lib/systemd/system/
%{__install} -d %{buildroot}/etc/supportchild/
%{__install} %{repo_root}/default_config.yml %{buildroot}/etc/supportchild/config.yml
%pre
getent group supportchild > /dev/null || groupadd supportchild
getent passwd supportchild > /dev/null || useradd -r -s /sbin/nologin -g supportchild supportchild
%post
%systemd_post supportchild.service
%preun
%systemd_preun supportchild.service
%postun
%systemd_postun_with_restart supportchild.service
if [[ "$1" == "0" ]]; then
getent passwd supportchild > /dev/null && userdel supportchild
fi
%files
%attr(0755,root,root) /usr/bin/supportchild
%attr(0644,root,root) /usr/lib/systemd/system/supportchild.service
%config %attr(0600, supportchild, supportchild) /etc/supportchild/config.yml