Files
davidandClaude Opus 5.5 0704628992
package / package (push) Successful in 1m17s
Publish the Arch package from Gitea Actions
Every push to main builds build-aux/arch/PKGBUILD at that commit in an
Arch container, runs the tests, and uploads the package to the
"federated" pacman repository that CoreDesktop installs it from. Gitea
signs it with the repository's key. The debug package isn't uploaded.

Needs a PACKAGE_TOKEN secret with write:package scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 12:12:28 -07:00

66 lines
2.5 KiB
YAML

# Build the Arch package from build-aux/arch/PKGBUILD on every push to main and
# publish it to the [federated] pacman repo on this Gitea, where CoreDesktop
# installs and updates it from. pkgver counts commits, so every push is a new
# version. Gitea signs the package and the repo database with the repo's key.
#
# Needs a PACKAGE_TOKEN secret: a token with write:package scope from a user
# who can publish Federated_Computer's packages.
name: package
on:
push:
branches: [main]
workflow_dispatch:
env:
REPO_URL: https://gitea.federated.computer/api/packages/Federated_Computer/arch/federated
jobs:
package:
runs-on: ubuntu-latest
container: archlinux:latest
steps:
# nodejs is for actions/checkout itself
- name: Install tools
run: pacman -Syu --noconfirm --needed base-devel git nodejs
# All the history, as pkgver counts the commits
- uses: actions/checkout@v4
with:
fetch-depth: 0
# makepkg won't run as root. It installs the dependencies with sudo.
- name: Add a build user
run: |
useradd -m builder
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder
chown -R builder "$GITHUB_WORKSPACE"
# The PKGBUILD clones main from Gitea, which may have moved on since this
# push. Build this checkout at this commit instead.
- name: Build the package
run: |
mkdir /build
cp build-aux/arch/PKGBUILD /build/
echo "source=(\"federated-calendar::git+file://$GITHUB_WORKSPACE#commit=$GITHUB_SHA\")" >> /build/PKGBUILD
chown -R builder /build
su builder -c "cd /build && makepkg --syncdeps --noconfirm"
# Not the federated-calendar-debug package makepkg also makes.
# A run that's tried again finds its version already there: Gitea answers
# 409 Conflict, and the package is published, so that isn't a failure.
- name: Publish the package
env:
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
run: |
pkg=$(ls /build/federated-calendar-[0-9]*.pkg.tar.zst)
echo "Uploading ${pkg##*/}..."
status=$(curl -sS -o /tmp/response -w '%{http_code}' \
-H "Authorization: token $PACKAGE_TOKEN" \
--upload-file "$pkg" "$REPO_URL")
case $status in
201) echo "Published." ;;
409) echo "This version is already published." ;;
*) echo "Upload failed with HTTP $status:"; cat /tmp/response; exit 1 ;;
esac