29 Commits

Author SHA1 Message Date
5dd4492822 doc: update repo owner
All checks were successful
Continuous Integration / lint_n_build (push) Successful in 40s
2026-04-19 14:42:48 +02:00
0ebd1b0229 ci: change repo owner
All checks were successful
Continuous Delivery / build_n_upload (push) Successful in 21s
2026-04-19 12:46:05 +02:00
a6fb133216 fix: remove path for binaries in unit files
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-12 17:59:01 +02:00
fc6ce6f472 fix: stop services on postun scriptlet
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-12 17:01:55 +02:00
146da6bcea fix: typo in file name
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-12 16:40:52 +02:00
e2d80629f3 fix: add actrunner config with runner location 2026-04-12 13:08:01 +02:00
3499d1461c fix: change directory for act_runner register 2026-04-12 12:47:06 +02:00
b6d6e871b0 fix: use local gitea instance 2026-04-12 12:26:44 +02:00
26ae0ff6fd fix: set unit with type notify 2026-04-12 11:19:57 +02:00
0b71cf4c42 fix: add env vars in unit file 2026-04-12 10:12:16 +02:00
d12efca2e3 fix: create act runners after gitea start 2026-04-11 15:38:19 +02:00
28d629073a fix: create gitea db schema 2026-04-11 15:33:54 +02:00
7229529ad0 fix: add env variables 2026-04-11 14:37:51 +02:00
b9c55b9786 fix: bash_profile path
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 17:57:55 +02:00
5fdb221abc fix: export gitea home dir variable
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 17:44:07 +02:00
46df78d59e fix: add work dir variable
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 17:17:20 +02:00
0188b0cb2f fix: unxz does already remove file automatically
All checks were successful
Continuous Delivery / build_n_upload (push) Successful in 22s
2026-04-06 16:45:33 +02:00
c2b680c6df fix: typo in token generate command
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 11:01:33 +02:00
545898493c fix: add logos to files
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 10:47:25 +02:00
1f91ec0de9 fix: typo in wget command
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 10:43:24 +02:00
8805f6cddd fix: typo in wget
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 10:24:35 +02:00
9f31148f46 fix: remove cd command
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 10:08:19 +02:00
4d85b2a212 fix: change directory to tmppath
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 09:59:52 +02:00
3048ea2716 fix: use postgres drop commands
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 09:24:18 +02:00
d04bdce2f7 fix: delete users only if exist
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 09:05:27 +02:00
b91099579e fix: syntax error in for
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 08:45:21 +02:00
729b4bdd6e fix: create gitea user first
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-04 08:24:51 +02:00
f193f5a305 fix: exclude images
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-04 08:13:34 +02:00
682d4bc35c fix: exclude tmp files 2026-04-04 08:00:25 +02:00
7 changed files with 115 additions and 61 deletions

View File

@@ -9,12 +9,10 @@ jobs:
lint_n_build: lint_n_build:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
- name: Git checkout - uses: actions/checkout@v6
uses: actions/checkout@v6
with: with:
fetch-depth: 0 fetch-depth: 0
fetch-tags: true fetch-tags: true
- name: Build tarball - run: shellcheck files/sbin/gitea_web_notify
run: make tarball - run: make tarball
- name: Build rpm file - run: rpmbuild -ba "$(make name).spec"
run: rpmbuild -ba "$(make name).spec"

View File

@@ -2,7 +2,7 @@ NAME = netoik-git
VERSION = $(shell git describe --abbrev=0) VERSION = $(shell git describe --abbrev=0)
RELEASE = $(shell git rev-parse --short HEAD) RELEASE = $(shell git rev-parse --short HEAD)
ARCH = noarch ARCH = noarch
OWNER = samuel OWNER = netoik
SUMMARY = "Netoïk Git server" SUMMARY = "Netoïk Git server"
LICENSE = "MIT" LICENSE = "MIT"
URL = "https://git.netoik.io/$(OWNER)/$(NAME)" URL = "https://git.netoik.io/$(OWNER)/$(NAME)"
@@ -74,11 +74,12 @@ install: ## Install files into rpm dest (requires env var DESTDIR)
printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \ printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \
exit 1; \ exit 1; \
fi fi
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_TMPPATH)/gitea_images install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_TMPPATH)/gitea_images $(DESTDIR)$(RPM_SBINDIR)
install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d files/nginx/git.netoik.io.conf install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d files/nginx/git.netoik.io.conf
install --mode=640 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/gitea files/gitea/app.ini install --mode=640 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/gitea files/gitea/app.ini
install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR) files/systemd/gitea.service files/systemd/actrunner@.service install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR) files/systemd/gitea.service files/systemd/actrunner@.service
install --mode=644 --target-directory=$(DESTDIR)$(RPM_TMPPATH)/gitea_images files/img/* install --mode=644 --target-directory=$(DESTDIR)$(RPM_TMPPATH)/gitea_images files/img/{favicon,logo}.{svg,png}
install --mode=755 --target-directory=$(DESTDIR)$(RPM_SBINDIR) files/sbin/gitea_web_notify
.PHONY: upload .PHONY: upload
upload: ## Upload rpm package to Gitea repository (requires env var PKG_TOKEN) upload: ## Upload rpm package to Gitea repository (requires env var PKG_TOKEN)

View File

@@ -1,4 +1,4 @@
# Netoïk Git Server ![badge](https://git.netoik.io/samuel/netoik-git/actions/workflows/ci.yaml/badge.svg) # Netoïk Git Server ![badge](https://git.netoik.io/netoik/netoik-git/actions/workflows/ci.yaml/badge.svg)
Build an RPM package which will install the Git server called Gitea with custom configuration. Build an RPM package which will install the Git server called Gitea with custom configuration.
@@ -59,8 +59,8 @@ Some commands to deploy the RPM package on server
- Add Gitea repo to your repo list: - Add Gitea repo to your repo list:
```shell ```shell
dnf config-manager --add-repo https://git.netoik.io/api/packages/samuel/rpm.repo dnf config-manager --add-repo https://git.netoik.io/api/packages/netoik/rpm.repo
dnf repolist | grep gitea-samuel dnf repolist | grep gitea-netoik
``` ```
- Show available versions: - Show available versions:

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Display commands, exit on error and enable job control
set -xem
gitea web &
until curl --fail --head http://localhost:3000
do
sleep 1
done
systemd-notify --ready
fg %1

View File

@@ -4,8 +4,8 @@ Documentation=https://gitea.com/gitea/act_runner
After=gitea.service After=gitea.service
[Service] [Service]
ExecStart=/usr/sbin/act_runner daemon ExecStart=act_runner daemon
ExecReload=/bin/kill -s HUP $MAINPID ExecReload=kill -s HUP $MAINPID
WorkingDirectory=/var/lib/actrunner%i WorkingDirectory=/var/lib/actrunner%i
TimeoutSec=0 TimeoutSec=0
RestartSec=10 RestartSec=10

View File

@@ -4,12 +4,14 @@ After=network.target postgresql.service valkey.service
[Service] [Service]
RestartSec=2s RestartSec=2s
Type=simple Type=notify
User=gitea User=gitea
Group=gitea Group=gitea
WorkingDirectory=/var/lib/gitea/ WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/sbin/gitea web Environment=GITEA_WORK_DIR=/var/lib/gitea
ExecStart=gitea_web_notify
Restart=always Restart=always
NotifyAccess=all
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@@ -22,24 +22,15 @@ Install the Git server called Gitea.
%make_install %make_install
%post %post
# Download and install gitea binary # Display commands and exit on error
set -xe
# Set environment variables
export ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') export ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
export GITEA_BINARY=gitea-1.25.5-linux-$ARCH export GITEA_BINARY=gitea-1.25.5-linux-$ARCH
wget --directory-prefix %{_tmppath} https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY export GITEA_LUGIT_THEME=gitea-lugit-theme
wget --directory-prefix %{_tmppath} https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY.asc export GITEA_WORK_DIR=/var/lib/gitea
gpg --keyserver hkps://keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 export ACTRUNNER_BINARY=act_runner-0.3.0-linux-$ARCH
gpg --verify %{_tmppath}/$GITEA_BINARY.asc %{_tmppath}/$GITEA_BINARY
rm %{_tmppath}/$GITEA_BINARY.asc
chmod 755 %{_tmppath}/$GITEA_BINARY
mv %{_tmppath}/$GITEA_BINARY.asc %{_sbindir}/gitea
# Replace secrets in app.ini
export INTERNAL_TOKEN=$(runuser --user=gitea -- gitea generate secret INTERNAL_TOKEN)
export JWT_SECRET=$(runuser --user=gitea -- gitea generate secret JWT_SECRET)
export SECRET_KEY=$(runuser --user=gitea -- gitea generate secret SECRET_TOKEN)
envsubst < %{_sysconfdir}/gitea/app.ini > %{_sysconfdir}/gitea/.app.ini.new
mv %{_sysconfdir}/gitea/.app.ini.new %{_sysconfdir}/gitea/app.ini
chown root:gitea %{_sysconfdir}/gitea/app.ini
# Create gitea user # Create gitea user
if ! id gitea >/dev/null 2>&1; then if ! id gitea >/dev/null 2>&1; then
@@ -48,17 +39,39 @@ fi
runuser --user=gitea -- mkdir --parents %{_sharedstatedir}/gitea/{custom,data,log} %{_sharedstatedir}/gitea/custom/conf runuser --user=gitea -- mkdir --parents %{_sharedstatedir}/gitea/{custom,data,log} %{_sharedstatedir}/gitea/custom/conf
runuser --user=gitea -- ln --symbolic --force %{_sysconfdir}/gitea/app.ini %{_sharedstatedir}/gitea/custom/conf/app.ini runuser --user=gitea -- ln --symbolic --force %{_sysconfdir}/gitea/app.ini %{_sharedstatedir}/gitea/custom/conf/app.ini
usermod --groups postgres,valkey --append gitea usermod --groups postgres,valkey --append gitea
printf 'export GITEA_WORK_DIR=%{_sharedstatedir}/gitea\n' >> %{_sharedstatedir}/gitea/.bash_profile
# Download and install gitea binary
wget --output-document $GITEA_BINARY https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY
wget --output-document $GITEA_BINARY.asc https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY.asc
gpg --keyserver hkps://keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
gpg --verify $GITEA_BINARY.asc $GITEA_BINARY
rm $GITEA_BINARY.asc
chmod 755 $GITEA_BINARY
mv $GITEA_BINARY %{_sbindir}/gitea
# Replace secrets in app.ini
export INTERNAL_TOKEN=$(runuser --user=gitea -- gitea generate secret INTERNAL_TOKEN)
export JWT_SECRET=$(runuser --user=gitea -- gitea generate secret JWT_SECRET)
export SECRET_KEY=$(runuser --user=gitea -- gitea generate secret SECRET_KEY)
envsubst < %{_sysconfdir}/gitea/app.ini > %{_sysconfdir}/gitea/.app.ini.new
mv %{_sysconfdir}/gitea/.app.ini.new %{_sysconfdir}/gitea/app.ini
chmod 640 %{_sysconfdir}/gitea/app.ini
chown root:gitea %{_sysconfdir}/gitea/app.ini
# Add lugit theme # Add lugit theme
wget -O %{_tmppath}/gitea-lugit-theme.tar.gz https://github.com/lucas-labs/gitea-lugit-theme/releases/download/v1.0.1/gitea-lugit-theme.tar.gz wget --output-document %{_tmppath}/$GITEA_LUGIT_THEME.tar.gz https://github.com/lucas-labs/gitea-lugit-theme/releases/download/v1.0.1/$GITEA_LUGIT_THEME.tar.gz
runuser --user=gitea -- tar --extract --gzip --overwrite --directory=%{_sharedstatedir}/gitea/custom --file %{_tmppath}/gitea-lugit-theme.tar.gz runuser --user=gitea -- tar --extract --gzip --overwrite --directory=%{_sharedstatedir}/gitea/custom --file %{_tmppath}/$GITEA_LUGIT_THEME.tar.gz
runuser --user=gitea -- mv %{_tmppath}/gitea_images/* %{_sharedstatedir}/gitea/custom/public/assets/img rm %{_tmppath}/$GITEA_LUGIT_THEME.tar.gz
rm --recursive %{_tmppath}/gitea_images runuser --user=gitea -- cp %{_tmppath}/gitea_images/* %{_sharedstatedir}/gitea/custom/public/assets/img
# Create postgres user and db # Create postgres user and db
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then
runuser --user=postgres -- createuser gitea runuser --user=postgres -- createuser gitea
fi
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\l' | grep --quiet gitea; then
runuser --user=postgres -- createdb --owner=gitea gitea runuser --user=postgres -- createdb --owner=gitea gitea
runuser --user=gitea -- gitea migrate
fi fi
# Create admin user # Create admin user
@@ -68,40 +81,63 @@ if ! runuser --user=gitea -- gitea admin user list | grep --quiet samuel; then
fi fi
# Download and install act_runner binary # Download and install act_runner binary
export ACTRUNNER_BINARY=act_runner-0.3.0-linux-$ARCH wget --output-document $ACTRUNNER_BINARY.xz https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz
wget --directory-prefix %{_tmppath} https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz wget --output-document $ACTRUNNER_BINARY.xz.sha256 https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz.sha256
wget --directory-prefix %{_tmppath} https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz.sha256 cat $ACTRUNNER_BINARY.xz.sha256 | sha256sum --check --status
cat %{_tmppath}/$ACTRUNNER_BINARY.xz.sha256 | sha256sum --check --status rm $ACTRUNNER_BINARY.xz.sha256
unxz %{_tmppath}/$ACTRUNNER_BINARY.xz unxz $ACTRUNNER_BINARY.xz
chmod 755 $ACTRUNNER_BINARY chmod 755 $ACTRUNNER_BINARY
mv $ACTRUNNER_BINARY %{_sbindir}/act_runner mv $ACTRUNNER_BINARY %{_sbindir}/act_runner
rm %{_tmppath}/$ACTRUNNER_BINARY.*
# Create 4 actrunner users
export ACTRUNNER_TOKEN=$(runuser --user=gitea -- gitea actions generate-token-runner --scope samuel)
for i in $(seq 1 4); do
if ! id actrunner$i >/dev/null 2>&1; then
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system actrunner$i
fi
runuser --user=actrunner$i -- rpmdev-setuptree
runuser --user=actrunner$i -- act_runner register --instance https://git.netoik.io --labels self-hosted --name actrunner$i --no-interactive --token $ACTRUNNER_TOKEN
systemctl reenable actrunner@$i.service
systemctl restart actrunner@$i.service
done
# Restart gitea and nginx services # Restart gitea and nginx services
systemctl daemon-reload systemctl daemon-reload
systemctl reenable gitea.service systemctl reenable gitea.service
systemctl restart gitea.service nginx.service systemctl restart gitea.service nginx.service
%postun # Create 4 actrunner users
# If removing, delete users and db export ACTRUNNER_TOKEN=$(runuser --user=gitea -- gitea actions generate-runner-token)
if [ $1 == 0 ]; then for i in $(seq 1 4); do
userdel --force --remove gitea if ! id actrunner$i >/dev/null 2>&1; then
runuser --user=postgres -- psql --command='DROP DATABASE gitea; DROP USER gitea;' useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system actrunner$i
for i in $(seq 1 4); then
userdel --force --remove actrunner$i
fi fi
runuser --user=actrunner$i -- rpmdev-setuptree
printf "runner:\n file: %{_sharedstatedir}/actrunner$i/.runner\n" > %{_sharedstatedir}/actrunner$i/config.yaml
runuser --user=actrunner$i -- act_runner --config %{_sharedstatedir}/actrunner$i/config.yaml register --instance http://127.0.0.1:3000 --labels self-hosted --name actrunner$i --no-interactive --token $ACTRUNNER_TOKEN
systemctl reenable actrunner@$i.service
systemctl restart actrunner@$i.service
done
%postun
# Display commands and exit on error
set -xe
# Stop services
systemctl stop gitea.service
for i in $(seq 1 4); do
systemctl stop actrunner@$i
done
# If uninstalling, then delete users and db
if [ $1 == 0 ]; then
# Remove gitea user if existing
if id gitea >/dev/null 2>&1; then
userdel --force --remove gitea
fi
# Remove gitea database if existing
if runuser --user=postgres -- psql --quiet --tuples-only --command='\l' | grep --quiet gitea; then
runuser --user=postgres -- dropdb gitea
fi
if runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then
runuser --user=postgres -- dropuser gitea
fi
# Remove actrunner users if existing
for i in $(seq 1 4); do
if id actrunner$i >/dev/null 2>&1; then
userdel --force --remove actrunner$i
fi
done
fi fi
%files %files
@@ -116,5 +152,10 @@ fi
%ghost %attr(755, root, root) %{_sbindir}/gitea %ghost %attr(755, root, root) %{_sbindir}/gitea
%ghost %attr(755, root, root) %{_sbindir}/act_runner %ghost %attr(755, root, root) %{_sbindir}/act_runner
%dir %attr(755, root, root) %{_tmppath}/gitea_images
%attr(644, root, root) %{_tmppath}/gitea_images/{favicon,logo}.{png,svg}
%attr(755, root, root) %{_sbindir}/gitea_web_notify
%changelog %changelog
%autochangelog %autochangelog