Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ version, or a main-branch dispatch with `publish=true`, publishes after the

Publishing uses GitHub OIDC and the repository's `release.yml` trusted publisher.
No registry token is stored in GitHub.

SDK patch releases can update packaging and publishing independently. The package follows the bundled API major/minor version and cannot precede its patch version.
7 changes: 5 additions & 2 deletions scripts/release-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
raise SystemExit("release requires main or a tag equal to the package version")
subprocess.run(["git", "fetch", "--quiet", "origin", "main"], check=True)
subprocess.run(["git", "merge-base", "--is-ancestor", "HEAD", "origin/main"], check=True)
if json.loads(Path("openapi.public.json").read_text())["info"]["version"] != version:
raise SystemExit("package and bundled public API versions differ")
api = json.loads(Path("openapi.public.json").read_text())["info"]["version"]
package_parts = tuple(map(int, version.split(".")))
api_parts = tuple(map(int, api.split(".")))
if package_parts[:2] != api_parts[:2] or package_parts[2] < api_parts[2]:
raise SystemExit("SDK must follow the public API major/minor and not precede its patch")
with Path(os.environ["GITHUB_OUTPUT"]).open("a") as output:
output.write(f"version={version}\n")
print(f"Release version: {version}")
25 changes: 25 additions & 0 deletions tests/test_release_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,31 @@ def git(*arguments: str) -> None:
self.assertEqual(output.read_text(), "version=1.2.3\n")
else:
self.assertFalse(output.exists())
for api, admitted in (
("1.2.2", True),
("1.2.4", False),
("1.1.3", False),
("2.2.3", False),
):
with self.subTest(api=api):
(root / "openapi.public.json").write_text(
json.dumps({"info": {"version": api}})
)
output = root / "api-output"
output.unlink(missing_ok=True)
result = subprocess.run(
[sys.executable, str(SCRIPT)],
cwd=root,
env={
**os.environ,
"GITHUB_REF": "refs/heads/main",
"GITHUB_OUTPUT": str(output),
},
capture_output=True,
text=True,
)
self.assertEqual(result.returncode == 0, admitted, result.stderr)
git("checkout", "--", "openapi.public.json")
git("checkout", "--quiet", "-b", "feature")
(root / "change").write_text("unmerged")
git("add", ".")
Expand Down
Loading