From 2ded49be02e1471bef0968f422c1cbf19314119b Mon Sep 17 00:00:00 2001 From: rogersXie Date: Thu, 28 May 2026 16:42:59 -0700 Subject: [PATCH 1/4] chore: add release-please workflow --- .github/workflows/release-please.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..6dbc4dc6 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,23 @@ +name: Release Please + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + name: release please + runs-on: ubuntu-latest + if: github.repository == 'RetellAI/retell-python-sdk' + + steps: + - uses: googleapis/release-please-action@5c625bfb5d1ff62eadeeb3772007f7f66fdcf071 # v4.4.1 + id: release + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} From 0966b89b08dcb1ab507511b480270961bf8332b0 Mon Sep 17 00:00:00 2001 From: rogersXie Date: Thu, 28 May 2026 19:28:00 -0700 Subject: [PATCH 2/4] chore: add SDK auto-merge workflow --- .github/workflows/stlc-auto-merge.yml | 93 +++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/stlc-auto-merge.yml diff --git a/.github/workflows/stlc-auto-merge.yml b/.github/workflows/stlc-auto-merge.yml new file mode 100644 index 00000000..4c7f9e54 --- /dev/null +++ b/.github/workflows/stlc-auto-merge.yml @@ -0,0 +1,93 @@ +name: Auto-merge SDK release PRs + +on: + pull_request_target: + types: [opened, synchronize, reopened, ready_for_review] + branches: [main] + workflow_run: + workflows: ["CI", "Release Doctor"] + types: [completed] + workflow_dispatch: + inputs: + pr_number: + description: "Optional PR number to evaluate" + required: false + +permissions: + contents: write + pull-requests: write + checks: read + statuses: read + actions: read + +jobs: + auto-merge: + if: github.repository == 'RetellAI/retell-python-sdk' + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }} + REPO: ${{ github.repository }} + steps: + - name: Merge qualifying green PRs + shell: bash + run: | + set -euo pipefail + + pr_numbers=() + if [ "${{ github.event_name }}" = "pull_request_target" ]; then + pr_numbers+=("${{ github.event.pull_request.number }}") + elif [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.pr_number }}" ]; then + pr_numbers+=("${{ inputs.pr_number }}") + else + while IFS= read -r number; do + pr_numbers+=("$number") + done < <(gh pr list --repo "$REPO" --base main --state open --json number --jq '.[].number') + fi + + for pr in "${pr_numbers[@]}"; do + echo "Evaluating PR #$pr" + pr_json=$(gh pr view "$pr" --repo "$REPO" --json title,isDraft,headRefName,headRefOid,baseRefName,mergeStateStatus) + title=$(jq -r '.title' <<<"$pr_json") + is_draft=$(jq -r '.isDraft' <<<"$pr_json") + head_ref=$(jq -r '.headRefName' <<<"$pr_json") + head_sha=$(jq -r '.headRefOid' <<<"$pr_json") + base_ref=$(jq -r '.baseRefName' <<<"$pr_json") + + if [ "$base_ref" != "main" ] || [ "$is_draft" = "true" ]; then + echo "Skipping PR #$pr: not a ready PR to main." + continue + fi + + merge_flag="" + if [ "$head_ref" = "stainless/release" ] && [ "$title" = "Release SDK updates" ]; then + merge_flag="--merge" + elif [[ "$head_ref" == release-please--* ]] && [[ "$title" == release:* ]]; then + merge_flag="--squash" + else + echo "Skipping PR #$pr: not an automated SDK release PR." + continue + fi + + check_runs=$(gh api "/repos/$REPO/commits/$head_sha/check-runs?per_page=100") + check_count=$(jq '.total_count' <<<"$check_runs") + if [ "$check_count" -eq 0 ]; then + echo "Skipping PR #$pr: no check runs found yet." + continue + fi + + bad_checks=$(jq '[.check_runs[] | select(.status != "completed" or (.conclusion != "success" and .conclusion != "neutral" and .conclusion != "skipped"))] | length' <<<"$check_runs") + if [ "$bad_checks" -ne 0 ]; then + echo "Skipping PR #$pr: checks are pending or failed." + continue + fi + + statuses=$(gh api "/repos/$REPO/commits/$head_sha/status") + status_count=$(jq '.total_count' <<<"$statuses") + status_state=$(jq -r '.state' <<<"$statuses") + if [ "$status_count" -gt 0 ] && [ "$status_state" != "success" ]; then + echo "Skipping PR #$pr: commit statuses are $status_state." + continue + fi + + gh pr merge "$pr" --repo "$REPO" "$merge_flag" --delete-branch + done From be57a3f70524d1f4bad69b37b73b383efb4c48d6 Mon Sep 17 00:00:00 2001 From: rogersXie Date: Thu, 28 May 2026 19:46:55 -0700 Subject: [PATCH 3/4] chore: harden SDK auto-merge workflow --- .github/workflows/stlc-auto-merge.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stlc-auto-merge.yml b/.github/workflows/stlc-auto-merge.yml index 4c7f9e54..2a66ebd1 100644 --- a/.github/workflows/stlc-auto-merge.yml +++ b/.github/workflows/stlc-auto-merge.yml @@ -5,12 +5,12 @@ on: types: [opened, synchronize, reopened, ready_for_review] branches: [main] workflow_run: - workflows: ["CI", "Release Doctor"] + workflows: ['CI', 'Release Doctor'] types: [completed] workflow_dispatch: inputs: pr_number: - description: "Optional PR number to evaluate" + description: 'Optional PR number to evaluate' required: false permissions: @@ -89,5 +89,10 @@ jobs: continue fi - gh pr merge "$pr" --repo "$REPO" "$merge_flag" --delete-branch + echo "Merging PR #$pr with ${merge_flag}." + if gh pr merge "$pr" --repo "$REPO" "$merge_flag" --delete-branch --match-head-commit "$head_sha"; then + echo "Merged PR #$pr." + else + echo "Skipping PR #$pr: GitHub did not consider it mergeable yet." + fi done From 4644075b17cc17443e67bc8fafa3ffe8e0e65e85 Mon Sep 17 00:00:00 2001 From: rogersXie Date: Thu, 28 May 2026 19:51:29 -0700 Subject: [PATCH 4/4] chore: restrict SDK auto-merge to same-repo branches --- .github/workflows/stlc-auto-merge.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stlc-auto-merge.yml b/.github/workflows/stlc-auto-merge.yml index 2a66ebd1..6b07d0d6 100644 --- a/.github/workflows/stlc-auto-merge.yml +++ b/.github/workflows/stlc-auto-merge.yml @@ -46,11 +46,13 @@ jobs: for pr in "${pr_numbers[@]}"; do echo "Evaluating PR #$pr" - pr_json=$(gh pr view "$pr" --repo "$REPO" --json title,isDraft,headRefName,headRefOid,baseRefName,mergeStateStatus) + pr_json=$(gh pr view "$pr" --repo "$REPO" --json title,isDraft,headRefName,headRefOid,headRepository,isCrossRepository,baseRefName,mergeStateStatus) title=$(jq -r '.title' <<<"$pr_json") is_draft=$(jq -r '.isDraft' <<<"$pr_json") head_ref=$(jq -r '.headRefName' <<<"$pr_json") head_sha=$(jq -r '.headRefOid' <<<"$pr_json") + head_repo=$(jq -r '.headRepository.nameWithOwner // ""' <<<"$pr_json") + is_cross_repository=$(jq -r '.isCrossRepository' <<<"$pr_json") base_ref=$(jq -r '.baseRefName' <<<"$pr_json") if [ "$base_ref" != "main" ] || [ "$is_draft" = "true" ]; then @@ -58,6 +60,11 @@ jobs: continue fi + if [ "$is_cross_repository" = "true" ] || [ "$head_repo" != "$REPO" ]; then + echo "Skipping PR #$pr: head branch is not in $REPO." + continue + fi + merge_flag="" if [ "$head_ref" = "stainless/release" ] && [ "$title" = "Release SDK updates" ]; then merge_flag="--merge"