diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bbc3aaf..52bbc62 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -71,8 +71,17 @@ jobs: found=$(curl -fsS -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github+json" \ "https://api.github.com/repos/${{ github.repository }}/actions/artifacts?name=$label&per_page=5" \ | jq -r '[.artifacts[] | select(.expired|not)] | sort_by(.created_at) | last | select(. != null) | "run \(.workflow_run.id), expires \(.expires_at)"') + # The plan the publish job makes, made here before a runner is + # asked for: a tree the channel already holds at master's version + # (a re-run, or a dispatch naming a package that is fine) needs + # no build, and an x86 rebuild would wait minutes for a droplet + # to find that out in seconds. + plan="" + [[ -n "$found" ]] || plan=$(bin/build --dry-run --mirror edge --arch "$arch" --package "$package" 2>&1 | grep -E '^==> Plan complete' || true) if [[ -n "$found" ]]; then decision="reuse the build artifact ($found)" + elif [[ -n "$plan" && -z "$(sed -E 's/.*would build: *//' <<<"$plan" | tr -d '[:space:]')" ]]; then + decision="already published at master's version, nothing to build" elif [[ $arch == aarch64 ]]; then decision="no build artifact: rebuild natively on ubuntu-24.04-arm" rebuild+=("$(jq -c '. + {runner: "[\"ubuntu-24.04-arm\"]"}' <<<"$entry")")