| name: release |
|
|
| |
| |
| |
| |
| on: |
| push: |
| branches: |
| - main |
| - 'release/**' |
|
|
| jobs: |
| |
| |
| |
| |
| |
| |
| |
| await-required-checks: |
| runs-on: ubuntu-latest |
| permissions: |
| checks: read |
| steps: |
| - name: Wait for test-and-build (ubuntu) on the release commit |
| env: |
| GH_TOKEN: ${{ github.token }} |
| HEAD_MSG: ${{ github.event.head_commit.message }} |
| REQUIRED_CHECK: test-and-build (ubuntu) |
| COMMIT_SHA: ${{ github.sha }} |
| TIMEOUT_SECONDS: "2400" |
| POLL_SECONDS: "20" |
| run: | |
| set -euo pipefail |
| |
| |
| subject="${HEAD_MSG%%$'\n'*}" |
| case "$subject" in |
| chore\(*\):\ release\ *) : ;; |
| *) |
| echo "::notice::'$subject' is not a release commit; release-please will only upsert the release PR. Not waiting." |
| exit 0 |
| ;; |
| esac |
|
|
| echo "Release commit detected; waiting for '$REQUIRED_CHECK' to pass on $COMMIT_SHA." |
| deadline=$(( $(date +%s) + TIMEOUT_SECONDS )) |
| while :; do |
| |
| state="$(gh api --method GET "repos/$GITHUB_REPOSITORY/commits/$COMMIT_SHA/check-runs" \ |
| -f per_page=100 \ |
| --jq '([.check_runs[] | select(.name == env.REQUIRED_CHECK)] | sort_by(.started_at) | last) as $r |
| | if $r == null then "missing none" else "\($r.status) \($r.conclusion // "none")" end')" |
| check_status="${state%% *}" |
| check_conclusion="${state#* }" |
|
|
| case "$check_status" in |
| completed) |
| if [ "$check_conclusion" = "success" ]; then |
| echo "::notice::'$REQUIRED_CHECK' passed on $COMMIT_SHA." |
| exit 0 |
| fi |
| echo "::error::'$REQUIRED_CHECK' concluded '$check_conclusion' on $COMMIT_SHA; not releasing." |
| exit 1 |
| ;; |
| missing) echo "Check not created yet; waiting…" ;; |
| *) echo "Check status: $check_status; waiting…" ;; |
| esac |
|
|
| if [ "$(date +%s)" -ge "$deadline" ]; then |
| echo "::error::Timed out after ${TIMEOUT_SECONDS}s waiting for '$REQUIRED_CHECK' on $COMMIT_SHA." |
| exit 1 |
| fi |
| sleep "$POLL_SECONDS" |
| done |
|
|
| release-please: |
| needs: await-required-checks |
| permissions: |
| contents: write |
| pull-requests: write |
| |
| |
| |
| secrets: inherit |
| uses: OpenHands/release-actions/.github/workflows/release-please.yml@main |
|
|