Add Gitea Alpine registry workflow

This commit is contained in:
Joachim Schlöffel
2026-06-07 23:27:06 +02:00
parent 772eba1e20
commit bb176142e5
12 changed files with 282 additions and 14 deletions

55
scripts/apk/ci-build.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
package_dir="${APKBUILD_DIR:-${repo_root}/packaging/alpine/local/seaweedfs}"
repo_name="${ALPINE_REPO_NAME:-local}"
arches="${ALPINE_ARCHES:-x86_64 aarch64}"
packager="${PACKAGER:-Joachim Schlöffel <me@joachim-schloeffel.com>}"
if [[ "${1:-}" != "--as-builder" && "$(id -u)" == "0" ]]; then
addgroup -g 1000 builder 2>/dev/null || addgroup builder
adduser -D -u 1000 -G builder builder 2>/dev/null || true
addgroup builder abuild
addgroup builder wheel
printf 'permit nopass :wheel\n' > /etc/doas.d/wheel.conf
printf '%%wheel ALL=(ALL) NOPASSWD: ALL\n' > /etc/sudoers.d/wheel
chown -R builder:builder "${repo_root}"
exec su builder -c "ALPINE_ARCHES='${arches}' ALPINE_REPO_NAME='${repo_name}' PACKAGER='${packager}' '${BASH_SOURCE[0]}' --as-builder"
fi
export PACKAGER="${packager}"
export REPODEST="${repo_root}/packages"
export SRCDEST="${repo_root}/.cache/apk-distfiles"
git config --global --add safe.directory "${repo_root}"
mkdir -p "${repo_root}/.cache/abuild" "${SRCDEST}" "${REPODEST}" "${HOME}/.abuild"
if [[ ! -e "${HOME}/.abuild/abuild.conf" && -d "${repo_root}/.cache/abuild" ]]; then
rmdir "${HOME}/.abuild" 2>/dev/null || true
ln -s "${repo_root}/.cache/abuild" "${HOME}/.abuild"
fi
if ! compgen -G "${HOME}/.abuild/*.rsa" > /dev/null; then
abuild-keygen -a -n
fi
doas cp "${HOME}"/.abuild/*.rsa.pub /etc/apk/keys/
for arch in ${arches}; do
case "${arch}" in
x86_64|aarch64) ;;
*) printf 'unsupported Alpine architecture: %s\n' "${arch}" >&2; exit 2 ;;
esac
printf 'Building %s for %s\n' "$(basename "${package_dir}")" "${arch}"
(
export ALPINE_ARCH="${arch}"
export CARCH="${arch}"
cd "${package_dir}"
abuild -r
)
mkdir -p "${REPODEST}/${repo_name}/${arch}"
cp "${HOME}"/.abuild/*.rsa.pub "${REPODEST}/${repo_name}/${arch}/"
done