Skip to content

Commit bccf2c5

Browse files
authored
fix(aur): do not fail a successful publish when AUR drops the connection (#47)
The v0.2.0 AUR publish succeeded and the workflow reported failure: [master (root-commit) 6785b0b] Update to 0.2.0 * [new branch] HEAD -> master Connection closed by 209.126.35.78 port 22 fatal: Could not read from remote repository. The push landed -- aur.archlinux.org/packages/thinkutils shows "thinkutils 0.2.0-1" -- and it was the verification step I added one commit earlier that failed, because AUR closes the SSH connection immediately after accepting a push. Reporting failure on a successful publish is not the harmless direction of this mistake. It invites a re-run, and re-running a publish is not always harmless. So: retry ls-remote with backoff, and if AUR still cannot be reached, emit a warning naming the package page rather than failing -- git push already reported success, and an unreachable remote is not evidence the push did not land. A genuine mismatch, where the remote IS readable and disagrees, still fails. Verification steps need to distinguish "this did not work" from "I could not tell". This one conflated them.
1 parent be8622f commit bccf2c5

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

.github/workflows/publish-aur.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,32 @@ jobs:
155155
# Confirm the remote actually moved. A push that resolves to a no-op
156156
# exits 0, and this workflow has already reported success once while
157157
# publishing nothing.
158+
#
159+
# Retried, because AUR closes the SSH connection immediately after a
160+
# push: the first attempt at this got "Connection closed by ... port
161+
# 22" and failed a run whose push had in fact succeeded. Reporting
162+
# failure on a successful publish is its own hazard -- it invites a
163+
# re-run, and re-running a publish is not always harmless.
158164
local_sha="$(git rev-parse HEAD)"
159-
remote_sha="$(git ls-remote origin refs/heads/master | cut -f1)"
160-
if [ "${local_sha}" != "${remote_sha}" ]; then
161-
echo "::error::push did not land - local ${local_sha} but remote master is ${remote_sha:-<empty>}"
165+
remote_sha=""
166+
for attempt in 1 2 3 4 5; do
167+
remote_sha="$(git ls-remote origin refs/heads/master 2>/dev/null | cut -f1)"
168+
[ -n "${remote_sha}" ] && break
169+
echo " ls-remote attempt ${attempt} got nothing (AUR often drops the connection after a push); retrying"
170+
sleep $((attempt * 5))
171+
done
172+
173+
if [ -z "${remote_sha}" ]; then
174+
# Could not reach AUR to confirm. The push itself reported success,
175+
# so do NOT fail -- say plainly that it is unconfirmed and let the
176+
# package page be the check.
177+
echo "::warning::could not reach AUR to confirm the push landed; git push reported success. Verify at https://aur.archlinux.org/packages/thinkutils"
178+
elif [ "${local_sha}" != "${remote_sha}" ]; then
179+
echo "::error::push did not land - local ${local_sha} but remote master is ${remote_sha}"
162180
exit 1
181+
else
182+
echo "published ${local_sha} to AUR master"
163183
fi
164-
echo "published ${local_sha} to AUR master"
165184
166185
- name: Dry run notice
167186
if: ${{ inputs.dry_run }}

0 commit comments

Comments
 (0)