From b22c4afc63c829cf7b0c0f0f93ac029ce3a359b9 Mon Sep 17 00:00:00 2001 From: Twan Nooitmeer Date: Wed, 12 Aug 2026 22:40:28 +0200 Subject: [PATCH] Make the README mksync check runnable on macOS The check normalised both sides with `sed -z '$s/\n*$//'` before diffing. `-z` is a GNU extension. BSD sed, which is what macOS ships, rejects it: sed: illegal option -- z Because the flag failed on *both* sides of the diff, the step compared two empty streams and exited 0. On a Mac it did not merely fail to work, it reported success on a README that was actually stale, so a contributor checking locally before pushing got a green result and a red CI. `$(...)` already strips every trailing newline, and `printf '%s\n'` puts exactly one back, so the same normalisation happens with no GNU-only flag and the readable `diff -u` output is kept. Verified on macOS: the new command exits 0 on the current README, and exits 1 with the expected one-line table-of-contents diff once a heading is added without regenerating. The old command exits 0 in both cases. Co-Authored-By: Claude Opus 5 --- .github/workflows/publish-pypi.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index c99b2b3e..ead812ef 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -37,7 +37,13 @@ jobs: - name: Mypy type check run: uv run mypy . - name: Check if README.md automatically generated content is up to date - run: diff -u <(cat README.md | sed -z '$s/\n*$//') <(uvx mksync@0.1.5 README.md | sed -z '$s/\n*$//') + # Both sides are normalised to end in exactly one newline before comparing. + # `$(...)` strips every trailing newline and `printf` puts one back, which is + # what `sed -z '$s/\n*$//'` did here, minus the `-z`: that flag is GNU-only, so + # on BSD/macOS sed it failed on both sides and the step compared two empty + # streams and always passed. Contributors could not reproduce this check + # locally, and it reported success on a README that was in fact stale. + run: diff -u <(printf '%s\n' "$(cat README.md)") <(printf '%s\n' "$(uvx mksync@0.1.5 README.md)") build-n-publish: name: Build and publish Python distributions to PyPI