hex/.github/release/push-aur.sh
Dax Raad c5338422a0 ci(release): split building from signing and publishing, like OpenCode
Build jobs (Linux, Windows x64/ARM64, macOS, Windows installers, AUR and Homebrew staging) run repository code with no environment, secret, or id-token and produce unsigned files. Sign and publish jobs run in the release environment, check out only .github/release/, and run only those scripts and SHA-pinned actions on artifacts treated as data: macOS Developer ID signing, notarization, and stapling (from APPLE_SIGNING_CERTIFICATE, APPLE_NOTARY_KEY, and the APPLE_NOTARY_KEY_ID/ISSUER_ID variables), Azure Authenticode, the release service, the GitHub release, and the AUR and Homebrew pushes. Every artifact carries a SHA256SUMS whose digest its job reports; every job that downloads it checks that digest. Signed macOS builds are verified and launched in a job without secrets. macos-signed.yml is gone (a check run covers it); the site deploy is no longer part of Release.
2026-10-27 17:02:44 -04:00

37 lines
1.9 KiB
Shell
Executable file

#!/usr/bin/env bash
# push-aur.sh <dir> | check: pushes the staged hex-bin package (PKGBUILD,
# .SRCINFO, and its files, staged and tested by scripts/release-aur.sh in a
# job without secrets) to the AUR with AUR_SSH_PRIVATE_KEY, or with `check`
# confirms the AUR accepts the key.
. "$(dirname "$0")/lib.sh"
package=hex-bin
files=(PKGBUILD .SRCINFO hex.desktop hex.service LICENSE "$package.install")
: "${AUR_SSH_PRIVATE_KEY:?Set AUR_SSH_PRIVATE_KEY to the AUR SSH private key}"
temporary=$(mktemp -d)
trap 'rm -rf "$temporary"' EXIT
(umask 077 && printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$temporary/key")
# aur.archlinux.org's published ED25519 host key.
echo 'aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN' > "$temporary/known_hosts"
export GIT_SSH_COMMAND="ssh -i $temporary/key -o IdentitiesOnly=yes -o UserKnownHostsFile=$temporary/known_hosts -o StrictHostKeyChecking=yes"
if [ "${1:-}" = check ]; then
# list-repos succeeds only for a registered key; it names the account's packages.
$GIT_SSH_COMMAND aur@aur.archlinux.org list-repos
exit 0
fi
dir=$(posix "${1:?Usage: push-aur.sh <dir> | check}")
for file in "${files[@]}"; do [ -f "$dir/$file" ] || die "The staged package lacks $file."; done
[ "$(find "$dir" -type f ! -name SHA256SUMS | wc -l | tr -d ' ')" = "${#files[@]}" ] || die "The staged package has unexpected files."
version=$(sed -n 's/^pkgver=//p' "$dir/PKGBUILD")
git clone -q "ssh://aur@aur.archlinux.org/$package.git" "$temporary/aur"
for file in "${files[@]}"; do cp "$dir/$file" "$temporary/aur/$file"; done
cd "$temporary/aur"
git add "${files[@]}"
if git diff --cached --quiet; then
echo "The AUR already has $package $version." >&2
exit 0
fi
git -c user.name='Hex release' -c user.email='hex@anoma.ly' commit -qm "Update to $version"
git push -q origin HEAD:master
echo "https://aur.archlinux.org/packages/$package"