Files
smol-machines--smolvm/.github/workflows/pacman-repo.yml
T
2026-07-13 13:13:07 +08:00

102 lines
4.1 KiB
YAML

name: Publish pacman repo
# Builds Arch packages from the release binaries and publishes them to the
# GitHub Pages `pacman-repo` branch, served at
# https://smol-machines.github.io/smolvm/pacman/$arch — a single stable
# repository endpoint (no per-arch release entries). See docs/install-arch.md.
#
# Triggers:
# - workflow_call: invoked by release.yml right after it creates the GitHub
# Release. This is the real automation path — the `release: published` event
# does NOT fire here on its own, because that release is created with the
# default GITHUB_TOKEN and GitHub does not start workflows from token-created
# releases (same reason release.yml pings the Homebrew tap explicitly).
# - workflow_dispatch: manual re-run / backfill for a given tag.
# - release: kept as a safety net for releases published by a human/PAT.
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Release tag to package (e.g. v1.5.0)'
required: true
workflow_call:
inputs:
tag:
description: 'Release tag to package (e.g. v1.5.0)'
required: true
type: string
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
container:
image: archlinux:base-devel
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Resolve tag
id: tag
run: |
TAG='${{ github.event.release.tag_name || inputs.tag }}'
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "pkgver=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Install tooling
run: pacman -Syu --noconfirm pacman-contrib git
- uses: actions/checkout@v4
- name: Prepare build user
run: |
useradd -m builder
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder
cp -r packaging/arch /home/builder/build
chown -R builder /home/builder/build
- name: Build packages (both arches; repackage-only, no compilation)
run: |
cd /home/builder/build
sed -i "s/^pkgver=.*/pkgver=${{ steps.tag.outputs.pkgver }}/; s/^pkgrel=.*/pkgrel=1/" PKGBUILD
sudo -u builder updpkgsums
sudo -u builder makepkg -df --noconfirm
sudo -u builder env CARCH=aarch64 makepkg -df --noconfirm --ignorearch
ls -l *.pkg.tar.zst
- name: Publish to the GitHub Pages pacman repo (branch pacman-repo)
run: |
cd /home/builder/build
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global --add safe.directory '*'
# Pages serves the pacman-repo branch at https://<owner>.github.io/<repo>/
# (Deploy from a branch); the pacman endpoint is pacman/$arch/. Pushing
# to the branch triggers the Pages build.
auth="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git clone --depth 1 --branch pacman-repo "$auth" pages
for arch in x86_64 aarch64; do
dir="pages/pacman/$arch"
mkdir -p "$dir"
# Rolling repo: keep only the current version's package so the branch
# stays small. repo-add then builds a fresh single-entry db.
rm -f "$dir"/smolvm-*.pkg.tar.zst "$dir"/smol-machines.db* "$dir"/smol-machines.files*
cp smolvm-*-"$arch".pkg.tar.zst "$dir/"
(
cd "$dir"
repo-add smol-machines.db.tar.gz smolvm-*-"$arch".pkg.tar.zst
# GitHub Pages does not serve broken symlinks — materialize the
# convenience `.db`/`.files` names as real copies of their targets.
cp --remove-destination "$(readlink -f smol-machines.db)" smol-machines.db
cp --remove-destination "$(readlink -f smol-machines.files)" smol-machines.files
)
done
cd pages
git add -A
git commit -m "pacman: publish ${{ steps.tag.outputs.tag }}" \
|| { echo "no package changes to publish"; exit 0; }
git push origin pacman-repo