From 89af50a63f4c557feeaf3a9ada360a12c04de667 Mon Sep 17 00:00:00 2001 From: samuel Date: Tue, 24 Feb 2026 01:33:07 +0100 Subject: [PATCH] feat: first commit --- .gitattributes | 2 ++ .gitea/workflows/cd.yaml | 27 +++++++++++++++++ .gitea/workflows/ci.yaml | 21 +++++++++++++ .gitignore | 3 ++ Makefile | 51 ++++++++++++++++++++++++++++++++ README.md | 4 +-- files/gitea/app.ini | 33 +++++++++++++++++++++ files/systemd/actrunner@.service | 17 +++++++++++ files/systemd/gitea.service | 15 ++++++++++ netoik-git.spec | 38 ++++++++++++++++++++++++ 10 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitea/workflows/cd.yaml create mode 100644 .gitea/workflows/ci.yaml create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 files/gitea/app.ini create mode 100644 files/systemd/actrunner@.service create mode 100644 files/systemd/gitea.service create mode 100644 netoik-git.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..de2f316 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitignore export-ignore +.gitattributes export-ignore diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml new file mode 100644 index 0000000..217d4de --- /dev/null +++ b/.gitea/workflows/cd.yaml @@ -0,0 +1,27 @@ +name: Continuous Delivery + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +jobs: + build_n_upload: + runs-on: linux + steps: + - name: Git checkout + uses: actions/checkout@v6 + with: + fetch-tags: true + - name: Build tarball + run: make tarball + env: + GIT_REFERENCE: ${{ github.ref }} + - name: Build rpm package + run: rpmbuild -ba "$(make name).spec" + - name: Upload rpm package + run: make upload + env: + GIT_PACKAGES_USERNAME: ${{ vars.GIT_PACKAGES_USERNAME }} + GIT_PACKAGES_TOKEN: ${{ secrets.GIT_PACKAGES_TOKEN }} + diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..71184a5 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,21 @@ +name: Continuous Integration + +on: + push: + branches: + - main + +jobs: + lint_n_build: + runs-on: linux + steps: + - name: Git checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + fetch-tags: true + - name: Build tarball + run: make tarball + - name: Build rpm file + run: rpmbuild -ba "$(make name).spec" + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1128d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.swp +*.env +/.idea diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c01d7b0 --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +NAME = netoik-git +VERSION = $(shell git describe --abbrev=0) +RELEASE = $(shell git rev-parse --short HEAD) +REFERENCE = $(if $(GIT_REFERENCE),$(GIT_REFERENCE),$(shell git branch --show-current)) +BUILD_ARCH = noarch + +RPM_RPMDIR = $(shell rpm --eval '%{_rpmdir}') +RPM_SBINDIR = $(shell rpm --eval '%{_sbindir}') +RPM_SOURCEDIR = $(shell rpm --eval '%{_sourcedir}') +RPM_SYSCONFDIR = $(shell rpm --eval '%{_sysconfdir}') +RPM_UNITDIR = $(shell rpm --eval '%{_unitdir}') +RPM_TARBALL_PATH = $(RPM_SOURCEDIR)/$(NAME)-$(VERSION).tar.gz +RPM_BUILD_PATH = $(RPM_RPMDIR)/$(BUILD_ARCH)/$(NAME)-$(VERSION)-$(RELEASE).$(BUILD_ARCH).rpm + +.PHONY: name +name: + @echo "$(NAME)" + +.PHONY: version +version: + @echo "$(VERSION)" + +.PHONY: release +release: + @echo "$(RELEASE)" + +.PHONY: build_arch +build_arch: + @echo "$(BUILD_ARCH)" + +.PHONY: install +install: + install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)/actrunners + install --mode=644 --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 + +$(RPM_TARBALL_PATH): * + git archive --format=tar.gz \ + --output="$@" \ + --prefix="$(NAME)-$(VERSION)/" \ + --verbose \ + "$(REFERENCE)" + +.PHONY: tarball +tarball: $(RPM_TARBALL_PATH) + +.PHONY: upload +upload: + curl --fail-with-body --upload-file "$(RPM_BUILD_PATH)" --user "$(GIT_PACKAGES_USERNAME):$(GIT_PACKAGES_TOKEN)" https://git.netoik.io/api/packages/$(GIT_PACKAGES_USERNAME)/rpm/upload + + diff --git a/README.md b/README.md index 87c62c9..44519ba 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# netoik-git +# Netoïk Git ![badge](https://git.netoik.io/samuel/netoik-git/actions/workflows/ci.yaml/badge.svg) -Netoïk Git server \ No newline at end of file +Build an RPM package which will install the Git UI server called Gitea. diff --git a/files/gitea/app.ini b/files/gitea/app.ini new file mode 100644 index 0000000..002ffb3 --- /dev/null +++ b/files/gitea/app.ini @@ -0,0 +1,33 @@ +# Do not edit this file unless you are aware about what you are doing! +# See official doc here: https://docs.gitea.com/next/administration/config-cheat-sheet + +APP_NAME = Netoïk Git Server +RUN_USER = gitea +RUN_MODE = prod +WORK_PATH = /var/lib/gitea + +[server] +DOMAIN = git.netoik.io +ROOT_URL = https://git.netoik.io/ +HTTP_ADDR = 127.0.0.1 +HTTP_PORT = 3000 +SSH_DOMAIN = git.netoik.io +SSH_PORT = 22222 + +[database] +DB_TYPE = postgres +HOST = /run/postgresql +NAME = gitea +USER = gitea + +[security] +INSTALL_LOCK = true +SECRET_KEY = $SECRET_KEY +INTERNAL_TOKEN = $INTERNAL_TOKEN + +[service] +DISABLE_REGISTRATION = true + +[session] +PROVIDER = redis +PROVIDER_CONFIG = /run/redis/redis.sock diff --git a/files/systemd/actrunner@.service b/files/systemd/actrunner@.service new file mode 100644 index 0000000..787be65 --- /dev/null +++ b/files/systemd/actrunner@.service @@ -0,0 +1,17 @@ +[Unit] +Description=Gitea Actions runner #%i +Documentation=https://gitea.com/gitea/act_runner +After=network.target gitea.service + +[Service] +ExecStartPre=/usr/bin/rpmdev-setuptree +ExecStart=/usr/local/bin/act_runner daemon +ExecReload=/bin/kill -s HUP $MAINPID +WorkingDirectory=/opt/actrunners/actrunner%i +TimeoutSec=0 +RestartSec=10 +Restart=always +User=actrunner%i + +[Install] +WantedBy=multi-user.target diff --git a/files/systemd/gitea.service b/files/systemd/gitea.service new file mode 100644 index 0000000..e026c54 --- /dev/null +++ b/files/systemd/gitea.service @@ -0,0 +1,15 @@ +[Unit] +Description=Gitea (Git with a cup of tea) +After=network.target postgresql.service + +[Service] +RestartSec=2s +Type=simple +User=gitea +Group=gitea +WorkingDirectory=/var/lib/gitea/ +ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/netoik-git.spec b/netoik-git.spec new file mode 100644 index 0000000..fc17e8e --- /dev/null +++ b/netoik-git.spec @@ -0,0 +1,38 @@ +%define debug_package %{nil} + +Name: %(make name) +Version: %(make version) +Release: %(make release) +Summary: Netoik Reverse Proxy +License: MIT +URL: https://git.netoik.io/samuel/%(make name) + +Source0: %{name}-%{version}.tar.gz +Buildarch: %(make build_arch) +BuildRequires: make +Requires: netoik-db git + +%description +Install the Git UI server called Gitea. + +%prep +%autosetup -v + +%install +%make_install + +%post + +%files +%dir %attr(755, root, root) %{_sysconfdir}/gitea +%attr(600, root, root) %{_sysconfdir}/gitea/app.ini + +%attr(644, root, root) %{_unitdir}/gitea.service +%attr(644, root, root) %{_unitdir}/actrunner@.service + +%dir %attr(755, root, root) /opt/actrunners + +%changelog +%autochangelog + +