This commit is contained in:
commit
db512f7633
8 files changed
+212
No files matched your search
@@ -0,0 +1,72 @@
|
|||||||
|
name: Build and publish gitea-runner via local runner
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Upstream version, without the v (e.g. 5.1.1)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
revision:
|
||||||
|
description: "Packaging revision"
|
||||||
|
required: false
|
||||||
|
default: "1"
|
||||||
|
type: string
|
||||||
|
|
||||||
|
env:
|
||||||
|
DISTRIBUTION: any
|
||||||
|
COMPONENT: main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Validate inputs
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: |
|
||||||
|
# Inputs may come from an external service, so never trust them blindly
|
||||||
|
echo "$VERSION" | grep -Eq '^[0-9]+(\.[0-9]+)*$' || { echo "Bad version"; exit 1; }
|
||||||
|
echo "$REVISION" | grep -Eq '^[0-9]+$' || { echo "Bad revision"; exit 1; }
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install build tools
|
||||||
|
run: |
|
||||||
|
if ! command -v make >/dev/null || ! command -v curl >/dev/null; then
|
||||||
|
apt-get update && apt-get install -y make curl
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
run: make VERSION="$VERSION" REVISION="$REVISION"
|
||||||
|
|
||||||
|
- name: Publish to Gitea package registry
|
||||||
|
env:
|
||||||
|
VERSION: ${{ inputs.version }}
|
||||||
|
REVISION: ${{ inputs.revision }}
|
||||||
|
UPLOADER: ${{ secrets.PACKAGE_UPLOAD_USERNAME }}
|
||||||
|
TOKEN: ${{ secrets.PACKAGE_UPLOAD_TOKEN }}
|
||||||
|
OWNER: ${{ GITHUB_REPOSITORY_OWNER }}
|
||||||
|
SERVER: ${{ GITHUB_SERVER_URL }}
|
||||||
|
run: |
|
||||||
|
DEB="build/gitea-runner_${VERSION}-${REVISION}_amd64.deb"
|
||||||
|
CODE=$(curl -sS -o /tmp/resp -w '%{http_code}' \
|
||||||
|
--user "${UPLOADER}:${TOKEN}" \
|
||||||
|
--upload-file "$DEB" \
|
||||||
|
"${SERVER}/api/packages/${OWNER}/debian/pool/${DISTRIBUTION}/${COMPONENT}/upload")
|
||||||
|
cat /tmp/resp; echo
|
||||||
|
case "$CODE" in
|
||||||
|
201) echo "Published $DEB" ;;
|
||||||
|
409) echo "This version/revision already exists; bump REVISION"; exit 1 ;;
|
||||||
|
*) echo "Upload failed with HTTP $CODE"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Keep the .deb as a workflow artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: gitea-runner-deb
|
||||||
|
path: build/*.deb
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
build/
|
||||||
|
cache/
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
VERSION ?= 5.1.1
|
||||||
|
REVISION ?= 1
|
||||||
|
|
||||||
|
NAME := gitea-runner-$(VERSION)-linux-amd64
|
||||||
|
BASE := https://gitea.com/gitea/runner/releases/download/v$(VERSION)
|
||||||
|
PKG := gitea-runner_$(VERSION)-$(REVISION)_amd64
|
||||||
|
STAGE := build/$(PKG)
|
||||||
|
BIN := cache/$(NAME)
|
||||||
|
SUMS := cache/checksums-$(VERSION).txt
|
||||||
|
|
||||||
|
.PHONY: deb clean
|
||||||
|
deb: build/$(PKG).deb
|
||||||
|
|
||||||
|
$(SUMS):
|
||||||
|
mkdir -p cache
|
||||||
|
curl -fsSL -o $@ $(BASE)/checksums.txt
|
||||||
|
|
||||||
|
$(BIN): $(SUMS)
|
||||||
|
curl -fsSL -o $@ $(BASE)/$(NAME)
|
||||||
|
cd cache && grep -E '[ *]$(NAME)$$' checksums-$(VERSION).txt | sha256sum -c - \
|
||||||
|
|| { rm -f $(NAME); echo "Checksum verification failed" >&2; exit 1; }
|
||||||
|
|
||||||
|
build/$(PKG).deb: $(BIN) $(shell find pkg -type f)
|
||||||
|
rm -rf $(STAGE)
|
||||||
|
mkdir -p $(STAGE)
|
||||||
|
cp -a pkg/. $(STAGE)/
|
||||||
|
install -D -m 0755 $(BIN) $(STAGE)/usr/bin/gitea-runner
|
||||||
|
sed -i -e 's|@VERSION@|$(VERSION)|' -e 's|@REVISION@|$(REVISION)|' \
|
||||||
|
$(STAGE)/DEBIAN/control
|
||||||
|
chmod 0755 $(STAGE)/DEBIAN/postinst $(STAGE)/DEBIAN/prerm $(STAGE)/DEBIAN/postrm
|
||||||
|
dpkg-deb --root-owner-group --build $(STAGE) $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
Package: gitea-runner
|
||||||
|
Version: @VERSION@-@REVISION@
|
||||||
|
Architecture: amd64
|
||||||
|
Maintainer: Florian@gansejunge.com
|
||||||
|
Section: devel
|
||||||
|
Priority: optional
|
||||||
|
Depends: adduser
|
||||||
|
Recommends: docker.io | docker-ce
|
||||||
|
Homepage: https://gitea.com/gitea/runner
|
||||||
|
Description: Runner for Gitea Actions
|
||||||
|
gitea-runner executes Gitea Actions workflow jobs, usually inside Docker
|
||||||
|
containers. It runs as the unprivileged gitea-runner user, with state in
|
||||||
|
/var/lib/gitea-runner and configuration in /etc/gitea-runner.
|
||||||
|
|
||||||
Executable
+35
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
configure)
|
||||||
|
if ! getent passwd gitea-runner >/dev/null; then
|
||||||
|
adduser --system --group --no-create-home \
|
||||||
|
--home /var/lib/gitea-runner --shell /usr/sbin/nologin \
|
||||||
|
--gecos "Gitea Actions runner" gitea-runner
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -d -o gitea-runner -g gitea-runner -m 0750 /var/lib/gitea-runner
|
||||||
|
install -d -o root -g gitea-runner -m 0750 /etc/gitea-runner
|
||||||
|
|
||||||
|
if [ ! -e /etc/gitea-runner/config.yaml ]; then
|
||||||
|
/usr/bin/gitea-runner generate-config > /etc/gitea-runner/config.yaml
|
||||||
|
chown root:gitea-runner /etc/gitea-runner/config.yaml
|
||||||
|
chmod 0640 /etc/gitea-runner/config.yaml
|
||||||
|
fi
|
||||||
|
|
||||||
|
if getent group docker >/dev/null; then
|
||||||
|
adduser --quiet gitea-runner docker || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /run/systemd/system ]; then
|
||||||
|
systemctl daemon-reload || true
|
||||||
|
systemctl enable gitea-runner.service >/dev/null 2>&1 || true
|
||||||
|
if systemctl is-active --quiet gitea-runner.service; then
|
||||||
|
systemctl restart gitea-runner.service || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
remove)
|
||||||
|
if [ -d /run/systemd/system ]; then
|
||||||
|
systemctl disable gitea-runner.service >/dev/null 2>&1 || true
|
||||||
|
systemctl daemon-reload || true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
purge)
|
||||||
|
rm -rf /etc/gitea-runner /var/lib/gitea-runner
|
||||||
|
if getent passwd gitea-runner >/dev/null; then
|
||||||
|
deluser --quiet --system gitea-runner || true
|
||||||
|
fi
|
||||||
|
if getent group gitea-runner >/dev/null; then
|
||||||
|
delgroup --quiet --system gitea-runner || true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
remove|deconfigure)
|
||||||
|
if [ -d /run/systemd/system ]; then
|
||||||
|
systemctl stop gitea-runner.service || true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Gitea Actions runner (gitea-runner)
|
||||||
|
Documentation=https://gitea.com/gitea/gitea-runner
|
||||||
|
After=network-online.target docker.service
|
||||||
|
Wants=network-online.target
|
||||||
|
ConditionPathExists=/var/lib/gitea-runner/.runner
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=gitea-runner
|
||||||
|
Group=gitea-runner
|
||||||
|
WorkingDirectory=/var/lib/gitea-runner
|
||||||
|
StateDirectory=gitea-runner
|
||||||
|
Environment=HOME=/var/lib/gitea-runner
|
||||||
|
ExecStart=/usr/bin/gitea-runner daemon --config /etc/gitea-runner/config.yaml
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=10
|
||||||
|
TimeoutSec=0
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in new issue
Block a user