|
69 | 69 | env: |
70 | 70 | GH_TOKEN: ${{ steps.prod-token.outputs.token }} |
71 | 71 | run: | |
| 72 | + # Regenerate the body on every promote. The release branch is |
| 73 | + # force-pushed, so a body written only at gh-pr-create time freezes at |
| 74 | + # whatever was pending the day the PR opened and never mentions |
| 75 | + # anything promoted since. |
| 76 | + git log --reverse --pretty=$'%H\t%s' production/main..origin/main > commits.tsv |
| 77 | + PROD_REPO="${PRODUCTION_REPO}" python3 - commits.tsv > body.md <<'PY' |
| 78 | + import os, re, sys |
| 79 | +
|
| 80 | + repo = os.environ["PROD_REPO"] |
| 81 | + rows = [l.rstrip("\n").split("\t", 1) for l in open(sys.argv[1]) if "\t" in l] |
| 82 | +
|
| 83 | + NAMED = [("feat", "### Features"), ("fix", "### Bug Fixes"), |
| 84 | + ("perf", "### Performance"), ("docs", "### Documentation"), |
| 85 | + ("refactor", "### Refactors")] |
| 86 | + CHORE = {"chore", "ci", "build", "test", "style", "release"} |
| 87 | + NOISE = re.compile(r"^(Build SDK|Merge pull request #\d+|Merge branch )") |
| 88 | +
|
| 89 | + named, chores, unconventional, generated = {}, [], [], [] |
| 90 | + for sha, subject in rows: |
| 91 | + m = re.match(r"^(\w+)(\([^)]*\))?!?:", subject) |
| 92 | + kind = m.group(1) if m else "" |
| 93 | + if kind in dict(NAMED): named.setdefault(kind, []).append((sha, subject)) |
| 94 | + elif kind in CHORE: chores.append((sha, subject)) |
| 95 | + elif NOISE.match(subject): generated.append((sha, subject)) |
| 96 | + else: unconventional.append((sha, subject)) |
| 97 | +
|
| 98 | + def rows_md(items): |
| 99 | + out = [] |
| 100 | + for sha, subject in items: |
| 101 | + # Five-digit refs are run-llama/platform PRs; GitHub would |
| 102 | + # otherwise autolink them to this repo's own issue numbers. |
| 103 | + subject = re.sub(r"\(#(\d{5,})\)", |
| 104 | + r"([#\1](https://github.com/run-llama/platform/pull/\1))", subject) |
| 105 | + out.append(f"- {subject} ([`{sha[:7]}`](https://github.com/{repo}/commit/{sha}))") |
| 106 | + return out |
| 107 | +
|
| 108 | + L = [f"Promotes `stainless/release` onto `main` — **{len(rows)} commits**. " |
| 109 | + "Merging this lets release-please cut the next release and write `CHANGELOG.md`.", ""] |
| 110 | + for kind, title in NAMED: |
| 111 | + if named.get(kind): |
| 112 | + L += [title, *rows_md(named[kind]), ""] |
| 113 | + if unconventional: |
| 114 | + L += ["### :warning: Not conventional-commit — release-please will DROP these from `CHANGELOG.md`", |
| 115 | + *rows_md(unconventional), ""] |
| 116 | + for items, title in ((chores, "Chores & CI"), (generated, "Codegen & merge commits")): |
| 117 | + if items: |
| 118 | + L += [f"<details><summary>{title} ({len(items)})</summary>", "", |
| 119 | + *rows_md(items), "", "</details>", ""] |
| 120 | + L.append("<sub>Regenerated by `stlc-promote.yml` on every promote, from " |
| 121 | + "`main...stainless/release`.</sub>") |
| 122 | + print("\n".join(L)) |
| 123 | + PY |
| 124 | +
|
72 | 125 | EXISTING_PR=$(gh pr list \ |
73 | 126 | --repo "${PRODUCTION_REPO}" \ |
74 | 127 | --head stainless/release \ |
|
81 | 134 | --base main \ |
82 | 135 | --head stainless/release \ |
83 | 136 | --title "Release SDK updates" \ |
84 | | - --body "$(git log --oneline production/main..origin/main)" |
| 137 | + --body-file body.md |
85 | 138 | else |
86 | | - echo "Release PR #${EXISTING_PR} already exists. Force-push has updated it." |
| 139 | + gh pr edit "${EXISTING_PR}" \ |
| 140 | + --repo "${PRODUCTION_REPO}" \ |
| 141 | + --body-file body.md |
87 | 142 | fi |
0 commit comments