push-aur.sh: mktemp -d creates the work directory as 0700 root, so the
builder user could not enter it to run makepkg ('cd: Permission denied'),
and the git steps afterwards would refuse a tree owned by another user. Give
builder the whole tree for makepkg and hand it back to root before git.
record-state.sh: 'git diff --quiet' ignores untracked files, so the first
state.json was reported as unchanged and never committed, which would have
rebuilt and republished every night. Stage it before comparing.
Both were found by the first publishing run; push-aur.sh was then tested end
to end in a clean Arch container with a dummy key.
Claude-Session: https://claude.ai/code/session_01GGe7kUhooMFuzY6GaDb2w9
50 lines
1.6 KiB
Bash
Executable File
50 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Commit state.json back to this repo so the next scheduled run knows what was
|
|
# already built. Without this the daily check would rebuild every night.
|
|
#
|
|
# STATE_PUSH_TOKEN token with write access to this repo (required)
|
|
|
|
set -euo pipefail
|
|
|
|
: "${STATE_PUSH_TOKEN:?STATE_PUSH_TOKEN is required}"
|
|
|
|
python3 - <<'PY'
|
|
import json
|
|
|
|
meta = json.load(open("release-meta.json"))
|
|
state = {
|
|
"jasp_tag": meta["jasp_tag"],
|
|
"jasp_version": meta["jasp_version"],
|
|
"pkgrel": meta["pkgrel"],
|
|
"bundled_r_version": meta["bundled_r_version"],
|
|
"qt6_minor": meta["qt6_minor"],
|
|
"qt6_major": meta["qt6_major"],
|
|
"sha256": meta["sha256"],
|
|
"download_url": meta["download_url"],
|
|
}
|
|
with open("state.json", "w") as fh:
|
|
json.dump(state, fh, indent=2)
|
|
fh.write("\n")
|
|
print(json.dumps(state, indent=2))
|
|
PY
|
|
|
|
# Stage first: `git diff` ignores untracked files, so on the very first run
|
|
# (no state.json in the repo yet) it reported "unchanged" and nothing was ever
|
|
# recorded, which would have rebuilt and republished every night.
|
|
git add state.json
|
|
if git diff --cached --quiet -- state.json; then
|
|
echo ":: state.json unchanged"
|
|
exit 0
|
|
fi
|
|
|
|
git config user.name "jasp-bin autobuilder"
|
|
git config user.email "noreply@weircon.dk"
|
|
git commit -m "Record build of ${GITHUB_REF_NAME:-build}: $(python3 -c 'import json;print(json.load(open("state.json"))["jasp_version"])')"
|
|
|
|
origin="$(git remote get-url origin)"
|
|
host_path="${origin#*://}"
|
|
host_path="${host_path#*@}"
|
|
git push "https://x-access-token:${STATE_PUSH_TOKEN}@${host_path}" HEAD:"${GITHUB_REF_NAME:-master}"
|
|
|
|
echo ":: state recorded"
|