11name : Promote SDKs
22
3- # Manually fast-forwards production main to the reviewed staging main. The
4- # ancestor check refuses divergent histories; this workflow never force-pushes.
3+ # Production requires pull requests, so staging is promoted through a merge-
4+ # commit PR. Never squash or rebase this cross-repo PR: preserving the incoming
5+ # commits keeps production and staging on one ancestry chain.
56on :
7+ push :
8+ branches : [main]
69 workflow_dispatch : {}
710
811permissions :
1215 promote :
1316 if : github.repository == 'kernel/kernel-python-sdk-staging'
1417 runs-on : ${{ vars.STLC_RUNNER || 'ubuntu-latest' }}
15- environment : production
18+ concurrency :
19+ group : stlc-promote
20+ cancel-in-progress : true
1621 steps :
1722 - name : Check out staging
1823 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3035 repositories : kernel-python-sdk
3136 permission-contents : write
3237 permission-workflows : write
38+ permission-pull-requests : write
3339
3440 - name : Fetch production main
3541 env :
@@ -51,11 +57,21 @@ jobs:
5157 echo "synced=false" >> "$GITHUB_OUTPUT"
5258 fi
5359
54- - name : Promote staging to production
60+ - name : Push the production release branch
5561 if : steps.diff.outputs.synced == 'false'
62+ env :
63+ GH_TOKEN : ${{ steps.production-token.outputs.token }}
64+ PRODUCTION_REPO : kernel/kernel-python-sdk
65+ run : git push production origin/main:refs/heads/stainless/release --force
66+
67+ - name : Open or update the promote PR
68+ if : steps.diff.outputs.synced == 'false'
69+ env :
70+ GH_TOKEN : ${{ steps.production-token.outputs.token }}
71+ PRODUCTION_REPO : kernel/kernel-python-sdk
5672 run : |
57- if ! git merge-base --is-ancestor production/main origin/main; then
58- echo "::error title=Promote blocked::production/main is not an ancestor of staging main. Back-sync production first."
59- exit 1
73+ existing=$(gh pr list --repo "$PRODUCTION_REPO" --head stainless/release --state open --json number --jq '.[0].number')
74+ if [ -z "$existing" ]; then
75+ gh pr create --repo "$PRODUCTION_REPO" --base main --head stainless/release --title "Release SDK updates" --body "$(git log --oneline production/main..origin/main)"
6076 fi
61- git push production origin/main:refs/heads/main
77+ gh pr merge stainless/release --repo "$PRODUCTION_REPO" --merge --auto || echo "Auto-merge unavailable; merge the promote PR manually with a merge commit."
0 commit comments