Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions .github/workflows/aur-git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Builds packaging/efr-code-git, the AUR package "efr-code-git" that builds the newest
# commit of main, and publishes it to the AUR when its files change.
#
# Required repository secret (only to publish):
# AUR_SSH_PRIVATE_KEY the key of aur.yml; docs/releasing.md has the setup.
#
# Triggers:
# - pull_request that changes the package or this workflow: a test build of the
# commit of the pull request. Nothing is pushed.
# - push to main that changes the package or this workflow: a test build of the
# commit, then a push to ssh://aur@aur.archlinux.org/efr-code-git.git when the
# PKGBUILD, the install file or the LICENSE differ from the AUR. A new commit of
# main alone is no reason to push: an AUR -git package keeps its pkgver until its
# PKGBUILD changes, and makepkg finds the newest commit itself.
# - schedule, every Monday: a test build of main. It finds a change on main that
# breaks the package, such as a new pin in docs/ghostty-pin.md, before a user does.
# - workflow_dispatch: as a push to main.
#
# The test build always builds the checked-out commit: the source line of the PKGBUILD
# is pointed at the checkout. In an archlinux:base-devel container, makepkg runs
# prepare(), build(), check() and package(), and namcap checks the result. The PKGBUILD
# that goes to the AUR keeps its source line, with the pkgver of the test build.

name: aur-git

on:
pull_request:
paths:
- packaging/efr-code-git/**
- packaging/efr-code/efr-code.install
- .github/workflows/aur-git.yml
push:
branches:
- main
paths:
- packaging/efr-code-git/**
- packaging/efr-code/efr-code.install
- .github/workflows/aur-git.yml
schedule:
- cron: "17 5 * * 1"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: aur-git-${{ github.ref }}
cancel-in-progress: false

jobs:
build:
name: Build efr-code-git
runs-on: ubuntu-latest
container:
image: archlinux:base-devel
defaults:
run:
shell: bash
env:
PKG: efr-code-git
AUR_SSH: ssh://aur@aur.archlinux.org
# Only a push to main or a manual run publishes.
PUBLISH: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }}
steps:
- name: Install tooling
# git before checkout so the action produces a real git checkout. rust is
# installed here, so that makepkg -s finds cargo and does not pick rustup for
# it. The image's keyring may predate a packager key, so it is refreshed first.
run: |
pacman -Sy --noconfirm --needed archlinux-keyring
pacman -Su --noconfirm --needed git namcap openssh rust sudo

# The whole history, so that pkgver() counts the commits of main.
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Create non-root build user
# makepkg refuses to run as root. makepkg -s installs the dependencies of the
# PKGBUILD through pacman, so the user may run it. The checkout belongs to the
# user of the runner, so git must trust it for root and for the builder.
run: |
useradd -m builder
echo 'builder ALL=(ALL) NOPASSWD: /usr/bin/pacman' > /etc/sudoers.d/builder
git config --global --add safe.directory "$GITHUB_WORKSPACE"
su - builder -c "git config --global --add safe.directory '*'"

- name: Test build and namcap
id: build
run: |
set -euo pipefail
build="/home/builder/$PKG"
install -d -o builder -g builder "$build"
# install copies the target of a link: efr-code-git links efr-code.install
# from packaging/efr-code.
for file in "packaging/$PKG"/*; do
install -o builder -g builder -m 644 "$file" "$build/"
done
commit=$(git rev-parse HEAD)
sed -i "s|^source=.*|source=(\"\$pkgname::git+file://$GITHUB_WORKSPACE#commit=$commit\")|" "$build/PKGBUILD"
grep '^source=' "$build/PKGBUILD"

su - builder -c "cd '$build' && makepkg -sf --noconfirm"
pkgver=$(sed -n 's/^pkgver=//p' "$build/PKGBUILD")
echo "pkgver=$pkgver" >> "$GITHUB_OUTPUT"
echo "built $PKG $pkgver from $commit"

log=$(mktemp)
for target in "$build/PKGBUILD" "$build/$PKG"-[0-9]*.pkg.tar.zst; do
if [[ ! -f "$target" ]]; then
echo "::error::$target does not exist"
exit 1
fi
echo "::group::namcap $target"
namcap "$target" | tee -a "$log"
echo "::endgroup::"
done
echo "::group::files"
pacman -Qlp "$build/$PKG"-[0-9]*.pkg.tar.zst
echo "::endgroup::"
# namcap prints findings as "<name> E: ..." and its own failures to read a
# target as "Error: ...", always exiting 0; both must fail.
if grep -E '^([^ ]+( \([^)]*\))? E: |Error: )' "$log"; then
echo "::error::namcap reported errors or could not analyse a target (warnings above are informational)"
exit 1
fi

- name: Set up SSH for aur.archlinux.org
if: env.PUBLISH == 'true'
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
set -euo pipefail
if [[ -z "$AUR_SSH_PRIVATE_KEY" ]]; then
echo "::error::secret AUR_SSH_PRIVATE_KEY is not set"
exit 1
fi
ssh_dir="$HOME/.ssh"
install -d -m 700 "$ssh_dir"
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$ssh_dir/aur"
chmod 600 "$ssh_dir/aur"
ssh-keygen -y -f "$ssh_dir/aur" > /dev/null

# The pinned host keys of aur.archlinux.org, the same as in aur.yml; change
# both files together. Their fingerprints match the "SSH Fingerprints" box on
# https://aur.archlinux.org/.
cat > "$ssh_dir/aur_known_hosts" <<'KNOWN_HOSTS'
aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN
aur.archlinux.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow=
aur.archlinux.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKF9vAFWdgm9Bi8uc+tYRBmXASBb5cB5iZsB7LOWWFeBrLp3r14w0/9S2vozjgqY5sJLDPONWoTTaVTbhe3vwO8CBKZTEt1AcWxuXNlRnk9FliR1/eNB9uz/7y1R0+c1Md+P98AJJSJWKN12nqIDIhjl2S1vOUvm7FNY43fU2knIhEbHybhwWeg+0wxpKwcAd/JeL5i92Uv03MYftOToUijd1pqyVFdJvQFhqD4v3M157jxS5FTOBrccAEjT+zYmFyD8WvKUa9vUclRddNllmBJdy4NyLB8SvVZULUPrP3QOlmzemeKracTlVOUG1wsDbxknF1BwSCU7CmU6UFP90kpWIyz66bP0bl67QAvlIc52Yix7pKJPbw85+zykvnfl2mdROsaT8p8R9nwCdFsBc9IiD0NhPEHcyHRwB8fokXTajk2QnGhL+zP5KnkmXnyQYOCUYo3EKMXIlVOVbPDgRYYT/XqvBuzq5S9rrU70KoI/S5lDnFfx/+lPLdtcnnEPk=
KNOWN_HOSTS
chmod 600 "$ssh_dir/aur_known_hosts"
echo "GIT_SSH_COMMAND=ssh -i ${ssh_dir}/aur -o IdentitiesOnly=yes -o UserKnownHostsFile=${ssh_dir}/aur_known_hosts -o StrictHostKeyChecking=yes" >> "$GITHUB_ENV"

- name: Push to AUR
if: env.PUBLISH == 'true'
env:
PKGVER: ${{ steps.build.outputs.pkgver }}
run: |
set -euo pipefail
aur_dir="$HOME/aur-$PKG"
# A package that does not exist yet clones as an empty repository.
git clone "$AUR_SSH/$PKG.git" "$aur_dir"

# The files of packaging/ with the pkgver of the test build. The PKGBUILD keeps
# its source line.
stage="/home/builder/stage-$PKG"
install -d -o builder -g builder "$stage"
files=(.SRCINFO)
for file in "packaging/$PKG"/*; do
install -o builder -g builder -m 644 "$file" "$stage/"
files+=("${file##*/}")
done
sed -i "s/^pkgver=.*/pkgver=$PKGVER/" "$stage/PKGBUILD"
su - builder -c "cd '$stage' && makepkg --printsrcinfo > .SRCINFO"

# Only a change of the files counts; a different pkgver alone does not.
changed=false
for file in "${files[@]}"; do
[[ "$file" == .SRCINFO ]] && continue
if [[ ! -f "$aur_dir/$file" ]] ||
! diff -q <(sed '/^pkgver=/d' "$stage/$file") <(sed '/^pkgver=/d' "$aur_dir/$file") > /dev/null; then
changed=true
fi
done
if [[ "$changed" != true ]]; then
echo "$PKG: the AUR has these files already; nothing to push"
exit 0
fi

for file in "${files[@]}"; do
cp "$stage/$file" "$aur_dir/"
done
git -C "$aur_dir" config user.name "eggfriedrice"
git -C "$aur_dir" config user.email "eggfriedricew.g.o@gmail.com"
git -C "$aur_dir" add -- "${files[@]}"
git -C "$aur_dir" commit -m "upgpkg: $PKGVER-1"
git -C "$aur_dir" push origin HEAD:master
3 changes: 2 additions & 1 deletion .github/workflows/aur.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ jobs:
# Ed25519 SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4
# ECDSA SHA256:uTa/0PndEgPZTf76e1DFqXKJEXKsn7m9ivhLQtzGOCI
# RSA SHA256:5s5cIyReIfNNVGRFdDbe3hdYiI5OelHGpw2rOUud3Q8
# If the AUR rotates its keys, update these lines from that page.
# If the AUR rotates its keys, update these lines from that page, and the same
# lines in aur-git.yml.
cat > "$ssh_dir/aur_known_hosts" <<'KNOWN_HOSTS'
aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN
aur.archlinux.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow=
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ into the GitHub release notes, and it stops when the section is missing.

## [Unreleased]

### Added

- A third AUR package, `efr-code-git`. It builds the newest commit of `main`, so you
get changes before a release. It can break between releases. The install page tells
how to install and update it.

### Fixed

- A build of the `efr-code` AUR package on a computer with many cores no longer fails
in its tests. The package now runs them with `cargo-nextest`, as CI does, so each
test runs in a process of its own.

### Changed

- efrd reads the output of your shell with the terminal core of Ghostty 1.4 (a commit
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ The guide to install and use efr is in [`docs/`](docs/). mdBook builds the same

## Install

On Arch Linux, install a package from the AUR. `efr-code` builds from source, and `efr-code-bin` installs the release build. Then do the three steps as your own user:
On Arch Linux, install a package from the AUR. `efr-code` builds from source, `efr-code-bin` installs the release build, and `efr-code-git` builds the newest commit of `main`. Then do the three steps as your own user:

```sh
yay -S efr-code # or: yay -S efr-code-bin
yay -S efr-code # or: yay -S efr-code-bin, yay -S efr-code-git
echo "source /usr/share/zsh/plugins/efr/efr.plugin.zsh" >> ~/.zshrc
systemctl --user enable --now efrd # start the daemon now and at every login
efr login openai # log in to your ChatGPT plan in a browser
Expand Down Expand Up @@ -113,7 +113,7 @@ All settings are in one optional file, `config.toml` in the config root (`~/.con
| `crates/` | The Rust workspace, one crate for each bounded context |
| `shell/zsh/` | The zsh plugin |
| `systemd/` | The user unit for the daemon |
| `packaging/` | The AUR packages `efr-code` and `efr-code-bin`; `docs/releasing.md` tells how a release reaches them |
| `packaging/` | The AUR packages `efr-code`, `efr-code-bin` and `efr-code-git`; `docs/releasing.md` tells how they reach the AUR |

## Building

Expand Down
11 changes: 8 additions & 3 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Do these steps once, before the first release.
`"resultcount":0`, or show packages of the account `eggfriedrice`:

```sh
curl -s 'https://aur.archlinux.org/rpc/v5/info?arg[]=efr-code&arg[]=efr-code-bin'
curl -s 'https://aur.archlinux.org/rpc/v5/info?arg[]=efr-code&arg[]=efr-code-bin&arg[]=efr-code-git'
```

2. Give the AUR account `eggfriedrice` an SSH key for the workflow. You can use a key
Expand All @@ -37,8 +37,13 @@ Do these steps once, before the first release.
gh secret set AUR_SSH_PRIVATE_KEY < aur
```

The AUR makes the package repositories `efr-code` and `efr-code-bin` on the first
push.
The AUR makes the package repositories `efr-code`, `efr-code-bin` and `efr-code-git`
on the first push.

`efr-code-git` has no release step. `aur-git.yml` builds it on each pull request that
changes `packaging/efr-code-git/`, and each Monday from `main`. After a merge that
changes its files, it pushes them to the AUR. A new commit of `main` alone changes
nothing on the AUR: `makepkg` finds the newest commit itself.

For the docs site, do these steps once in the settings of the repository on GitHub:

Expand Down
8 changes: 6 additions & 2 deletions docs/start/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ These programs are optional. efr works without them, but some parts do not:

## Install from the AUR

There are two packages. Install one of them:
There are three packages. Install one of them:

- `efr-code` builds efr from the source of the release tag. For the build, it
downloads Zig 0.17.0 from ziglang.org. It does not use the Zig of the Arch
repositories.
- `efr-code-bin` installs the release build from GitHub.
- `efr-code-git` builds the newest commit of `main`. It gets the changes before a
release, and it can break between releases. For the build, it downloads the
Zig and the ghostty commit that `docs/ghostty-pin.md` of that commit names. To
update it, build it again, for example with `yay -S efr-code-git`.

```sh
yay -S efr-code # or: yay -S efr-code-bin
yay -S efr-code # or: yay -S efr-code-bin, yay -S efr-code-git
```

The packages install these files:
Expand Down
12 changes: 12 additions & 0 deletions packaging/efr-code-git/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (C) 2026 eggfriedrice

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Loading
Loading