Skip to content

Commit de6d571

Browse files
cliffhallclaude
andcommitted
fix: stamp on a license change; keep the Python release PR on v2/main and its body current
- A license file ships in both distributions, so a change to one now counts as a shipped change. - prepare-python-release.yml refuses a dispatch from any ref but v2/main, since the dispatch ref becomes the PR's base. - A same-day rerun rewrites the open PR's body to match the force-updated branch. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 40dff0c commit de6d571

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎.github/workflows/prepare-python-release.yml‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ jobs:
3333
contents: write
3434
pull-requests: write
3535
steps:
36+
# The ref this was dispatched on becomes the PR's base, and every PR
37+
# targets `v2/main`. A run from `main` would open a version PR straight
38+
# against the release branch, around the milestone merge.
39+
- name: Refuse a dispatch from any branch but v2/main
40+
run: |
41+
if [ "$GITHUB_REF" != "refs/heads/v2/main" ]; then
42+
echo "::error::Dispatch this workflow on v2/main, not $GITHUB_REF."
43+
exit 1
44+
fi
45+
3646
# Full history: the script finds each package's last version bump with
3747
# `git log`, and a shallow clone would make every package look new.
3848
- uses: actions/checkout@v6
@@ -92,8 +102,13 @@ jobs:
92102
echo "> [!NOTE]"
93103
echo "> A PR opened with the workflow token does not trigger CI. Close and reopen this PR to run it."
94104
} > "$RUNNER_TEMP/pr-body.md"
95-
if [ "$(gh pr list --head "$BRANCH" --state open --json number --jq length)" != "0" ]; then
96-
echo "A PR for $BRANCH is already open; its branch was updated"
105+
# A second run on the same day force-updates the branch, and may
106+
# stamp a different set of packages; the open PR's body is rewritten
107+
# to match what the branch now holds.
108+
EXISTING=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number // empty')
109+
if [ -n "$EXISTING" ]; then
110+
gh pr edit "$EXISTING" --body-file "$RUNNER_TEMP/pr-body.md"
111+
echo "PR #$EXISTING for $BRANCH was already open; its branch and body were updated"
97112
else
98113
gh pr create \
99114
--base "$BASE" \

‎scripts/prepare-python-release.mjs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
// version and is installed `--locked` in CI.
2222
//
2323
// "Ships in the package" is read off the path: Python sources, the `py.typed`
24-
// marker, Markdown (the README is the sdist's long description) and
25-
// `pyproject.toml` itself (a dependency change). A test-only change does not
24+
// marker, Markdown (the README is the sdist's long description), a license
25+
// file, and `pyproject.toml` itself (a dependency change). A test-only change does not
2626
// count: nothing a user installs is different. Over-stamping would be harmless
2727
// anyway, since the registry guard in `release.yml` decides what publishes;
2828
// under-stamping is the failure that matters, because a changed package whose
@@ -66,7 +66,12 @@ export function shipsInPackage(file) {
6666
const parts = file.split("/");
6767
if (parts.some((p) => p === "tests" || p === "test")) return false;
6868
const name = parts.at(-1) ?? "";
69-
return name === "pyproject.toml" || /\.(?:py|md|typed)$/.test(name);
69+
return (
70+
name === "pyproject.toml" ||
71+
/\.(?:py|md|typed)$/.test(name) ||
72+
// Hatchling puts a license file in both distributions.
73+
/^(?:LICEN[CS]E|COPYING|NOTICE)(?:\.|$)/i.test(name)
74+
);
7075
}
7176

7277
/**

‎scripts/prepare-python-release.test.mjs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ test("shipsInPackage counts what a user installs, not the tests", () => {
5151
"src/mcp_server_git/py.typed",
5252
"README.md",
5353
"pyproject.toml",
54+
"LICENSE",
55+
"LICENSE.txt",
56+
"licence",
5457
])
5558
assert.equal(shipsInPackage(file), true, file);
5659
for (const file of [
5760
"tests/test_server.py",
5861
"test/time_server_test.py",
5962
"uv.lock",
6063
"Dockerfile",
64+
"src/mcp_server_git/licenses.json",
6165
".python-version",
6266
])
6367
assert.equal(shipsInPackage(file), false, file);

0 commit comments

Comments
 (0)