diff --git a/.github/workflows/release-github.yml b/.github/workflows/release-github.yml index 7874ca4..c7a8943 100644 --- a/.github/workflows/release-github.yml +++ b/.github/workflows/release-github.yml @@ -19,6 +19,7 @@ jobs: name: Wait for SDK publishes if: github.event_name == 'push' runs-on: ubuntu-latest + timeout-minutes: 340 permissions: actions: read steps: @@ -28,7 +29,7 @@ jobs: run: | WORKFLOWS=("release-go.yml" "release-typescript.yml" "release-ruby.yml" "release-swift.yml" "release-kotlin.yml" "release-rust.yml") TAG="${GITHUB_REF#refs/tags/}" - MAX_WAIT=1800 # 30 minutes + MAX_WAIT=19800 # 5.5 hours: each publish now waits for a reviewer's approval POLL=30 ELAPSED=0 @@ -37,16 +38,23 @@ jobs: ANY_FAILED=false STATUS_LINE="" + # One request per poll for every run on this commit: a per-workflow + # `gh run list --workflow` costs two requests each, and six of them + # every 30s outruns GITHUB_TOKEN's 1,000 requests/hour well inside + # the approval wait. + RUNS_JSON=$(gh api \ + "repos/$GITHUB_REPOSITORY/actions/runs?head_sha=$GITHUB_SHA&event=push&per_page=100" \ + --jq '.workflow_runs') || { + # A transient API error shouldn't end a wait measured in hours + echo "::warning::Listing workflow runs failed; retrying next poll" + RUNS_JSON='[]' + } + for WF in "${WORKFLOWS[@]}"; do - # Fetch recent runs and find the one matching this tag push - RUN_JSON=$(gh run list \ - --repo "$GITHUB_REPOSITORY" \ - --workflow "$WF" \ - --branch "$TAG" \ - --event push \ - --limit 5 \ - --json conclusion,headSha \ - --jq "[.[] | select(.headSha == \"$GITHUB_SHA\")] | .[0] // empty") + # Newest run of this workflow for this tag push + RUN_JSON=$(echo "$RUNS_JSON" | jq -c \ + --arg path ".github/workflows/$WF" --arg tag "$TAG" \ + '[.[] | select((.path | sub("@.*$"; "")) == $path and .head_branch == $tag)] | .[0] // empty') if [ -z "$RUN_JSON" ]; then ALL_DONE=false