From db88774b4d49d5667db476cef1fe125d3adc9059 Mon Sep 17 00:00:00 2001 From: Viet Anh Nguyen Date: Mon, 20 Jul 2026 14:33:22 +0700 Subject: [PATCH] fix(aur): first publish of a new package pushed nothing, and said success The v0.2.0 AUR publish reported success and produced a 404 package. warning: You appear to have cloned an empty repository. No change to publish. The AUR repo for a package that has never been published is empty, so the copied PKGBUILD and .SRCINFO are UNTRACKED. `git diff --quiet` compares tracked files only, saw nothing, printed "No change to publish" and exited 0 -- so the workflow went green having pushed nothing at all. It would silently skip the first publish of ANY new AUR package. Stages first, then tests with git status --porcelain, which counts untracked and staged entries and works in a repo with no HEAD to diff against. Reproduced against a real empty repo before and after: the old form reports no change with both files present, the new one commits. Also verifies the push actually landed by comparing HEAD against ls-remote. A push that resolves to a no-op exits 0, and this workflow has now demonstrated once that reporting success while publishing nothing is a state it can reach -- so exit codes alone are not sufficient evidence that a package is live. --- .github/workflows/publish-aur.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-aur.yml b/.github/workflows/publish-aur.yml index 7a93bd9..6036a83 100644 --- a/.github/workflows/publish-aur.yml +++ b/.github/workflows/publish-aur.yml @@ -130,17 +130,39 @@ jobs: cp /tmp/aur/PKGBUILD /tmp/aur/.SRCINFO /tmp/aur-repo/ cd /tmp/aur-repo - if git diff --quiet; then + # Stage FIRST, then ask whether anything is staged. + # + # `git diff --quiet` before staging compares tracked files only, so on + # a brand-new AUR package -- an empty repo, where PKGBUILD and .SRCINFO + # are untracked -- it sees no change, prints "No change to publish" and + # exits 0. The workflow then reports success having pushed nothing, + # which is precisely what happened on the first v0.2.0 publish: green + # run, 404 package. + # + # git status --porcelain counts untracked and staged entries, and works + # in a repo with no HEAD to diff against. + git add PKGBUILD .SRCINFO + if [ -z "$(git status --porcelain)" ]; then echo "No change to publish." exit 0 fi - git add PKGBUILD .SRCINFO git commit -m "Update to ${{ inputs.version }}" # AUR's default branch is master; a local `main` needs the explicit # refspec or the push is silently accepted into the wrong ref. git push origin HEAD:master + # Confirm the remote actually moved. A push that resolves to a no-op + # exits 0, and this workflow has already reported success once while + # publishing nothing. + local_sha="$(git rev-parse HEAD)" + remote_sha="$(git ls-remote origin refs/heads/master | cut -f1)" + if [ "${local_sha}" != "${remote_sha}" ]; then + echo "::error::push did not land - local ${local_sha} but remote master is ${remote_sha:-}" + exit 1 + fi + echo "published ${local_sha} to AUR master" + - name: Dry run notice if: ${{ inputs.dry_run }} run: echo "Dry run - nothing was pushed. Re-run with dry_run unchecked to publish."