Release the package automatically on push to main

This commit is contained in:
2026-11-27 12:41:35 -07:00
parent 7d9d2d6239
commit a302a0ed0b
3 changed files with 67 additions and 3 deletions
+48
View File
@@ -0,0 +1,48 @@
# Release the pacman package on every push to main that changes the extension
# or its package build, the same way `make release` does locally. CoreDesktop's
# update installs it from the [federated] repo.
#
# Needs an Actions secret named PACKAGE_TOKEN (repo or Federated_Computer org):
# a Gitea token with "package: Read and write" scope.
name: Release
on:
push:
branches: [main]
paths:
- "coredesktop@federated.computer/**"
- "build-aux/arch/PKGBUILD"
# Run it by hand from the Actions tab, e.g. after changing the secret
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
# makepkg needs Arch. The image has no Node, so this job doesn't use
# actions/checkout and clones with git instead.
container:
image: archlinux:base-devel
steps:
- name: Install git
run: pacman -Syu --noconfirm --needed git
# makepkg refuses to run as root
- name: Add a build user
run: useradd --create-home builder
- name: Build and upload
env:
GITEA_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}.git
SHA: ${{ github.sha }}
# A re-run for a commit that's already released succeeds
RELEASE_EXISTING_OK: "1"
# runuser without -l keeps this environment, GITEA_TOKEN included
run: |
runuser -u builder -- bash -euc '
cd ~
git clone --quiet "$REPO_URL" repo
git -C repo checkout --quiet "$SHA"
bash repo/build-aux/arch/release.sh
'
+8 -1
View File
@@ -51,7 +51,14 @@ it. CoreDesktop turns it on for each user (`gnome/gnome-extensions.sh` and a
migration). The package installs it to `/usr/share/gnome-shell/extensions`.
Updated code loads at your next login.
Users get a change only after it's released. To release, push to `main`, then:
Users get a change only after it's released. Releases are automatic:
`.gitea/workflows/release.yml` runs on each push to `main` that changes the
extension or its `PKGBUILD`. It builds the package in an Arch container and
uploads it. It needs an Actions secret named `PACKAGE_TOKEN` (the repo's or the
Federated_Computer org's) holding a token like the one described below. You
can also start it by hand from the repo's Actions tab.
To release by hand instead, push to `main`, then:
```sh
GITEA_TOKEN=... make release
+11 -2
View File
@@ -38,8 +38,11 @@ OUT="$(mktemp -d)"
trap 'rm -rf "$OUT"' EXIT
echo "Building the package from main..."
# -C starts from a fresh source tree, so nothing from an earlier build gets in
(cd "$SELF" && PKGDEST="$OUT" makepkg --force --cleanbuild)
# -C starts from a fresh source tree, so nothing from an earlier build gets in.
# --nodeps: the package only copies files, so building doesn't need its
# runtime dependencies (gnome-shell), which the release workflow's container
# doesn't have.
(cd "$SELF" && PKGDEST="$OUT" makepkg --force --cleanbuild --nodeps)
PKG="$(find "$OUT" -maxdepth 1 -name '*.pkg.tar.zst' | head -n 1)"
if [ -z "$PKG" ]; then
@@ -57,6 +60,12 @@ case "$STATUS" in
echo "Released $(basename "$PKG"). CoreDesktop's next update installs it."
;;
409)
# The release workflow sets this: re-running it for a commit that's already
# released isn't a failure
if [ -n "${RELEASE_EXISTING_OK:-}" ]; then
echo "[$REPO] already has $(basename "$PKG"); nothing to do."
exit 0
fi
echo "[$REPO] already has this version. Commit and push a change to main to release a new one." >&2
exit 1
;;