add linux release binaries for ci consumers#2
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Free Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR introduces a release binary distribution pipeline for version 0.1.2. It adds infrastructure to build, verify, test, and publish prebuilt PyInstaller binaries alongside PyPI packages, updates GitHub Actions workflows to perform these steps, and changes example workflows to consume prebuilt binaries instead of installing from PyPI. ChangesRelease Binary Distribution Pipeline
Sequence DiagramssequenceDiagram
participant GitHub as GitHub Release
participant Checkout as Checkout Repo
participant Verify as Verify Tag
participant Build as Build Artifacts
participant Test as Run Tests
participant Binary as Build Binary
participant Upload as Upload Assets
GitHub->>Checkout: on: published
Checkout->>Verify: verify RELEASE_TAG matches version
Verify->>Build: tag is valid
Build->>Test: wheel/sdist artifacts
Test->>Binary: tests passed
Binary->>Upload: binary + .sha256
Upload->>GitHub: upload to release
sequenceDiagram
participant Example as Example Workflow
participant Release as GitHub Release
participant Verify as sha256sum
participant Binary as ./cooldown-guard
Example->>Release: download cooldown-guard-linux-x86_64
Release->>Verify: provide binary + COOLDOWN_GUARD_SHA256
Verify->>Binary: checksum valid
Binary->>Example: executable ready
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the release process for cooldown-guard by introducing standalone binary builds using PyInstaller. It includes new scripts for building binaries and verifying release tags, updates example workflows to use these binaries with SHA256 verification, and bumps the project version to 0.1.2. The reviewer provided feedback on improving robustness in the release scripts by suggesting the use of .get() for environment variables to avoid KeyErrors and ensuring the distribution directory exists before writing checksum files.
| pyproject = pathlib.Path("pyproject.toml") | ||
| version = tomllib.loads(pyproject.read_text())["project"]["version"] | ||
| expected_tag = f"v{version}" | ||
| release_tag = os.environ["RELEASE_TAG"] |
There was a problem hiding this comment.
Accessing os.environ["RELEASE_TAG"] directly will raise a KeyError if the environment variable is missing. It is better to handle this gracefully with a clear error message to help debug CI configuration issues.
release_tag = os.environ.get("RELEASE_TAG")
if not release_tag:
raise SystemExit("RELEASE_TAG environment variable is required")| def main() -> None: | ||
| binary_name = get_binary_name() | ||
| build_binary(binary_name) | ||
| binary_path = DIST_DIR / binary_name | ||
| checksum_path = DIST_DIR / f"{binary_name}.sha256" | ||
| checksum_path.write_text(f"{sha256(binary_path)} {binary_name}\n") | ||
| print(binary_path) | ||
| print(checksum_path) |
There was a problem hiding this comment.
The script writes the checksum file to DIST_DIR (line 20), but it doesn't explicitly ensure that this directory exists. While PyInstaller usually creates dist/ during the build process, if the build fails or if PyInstaller is configured differently in the future, the write_text call might fail with a FileNotFoundError. It's safer to ensure the directory exists before writing to it.
| def main() -> None: | |
| binary_name = get_binary_name() | |
| build_binary(binary_name) | |
| binary_path = DIST_DIR / binary_name | |
| checksum_path = DIST_DIR / f"{binary_name}.sha256" | |
| checksum_path.write_text(f"{sha256(binary_path)} {binary_name}\n") | |
| print(binary_path) | |
| print(checksum_path) | |
| def main() -> None: | |
| binary_name = get_binary_name() | |
| build_binary(binary_name) | |
| binary_path = DIST_DIR / binary_name | |
| checksum_path = DIST_DIR / f"{binary_name}.sha256" | |
| DIST_DIR.mkdir(parents=True, exist_ok=True) | |
| checksum_path.write_text(f"{sha256(binary_path)} {binary_name}\n") | |
| print(binary_path) | |
| print(checksum_path) |
summary
cooldown-guardto0.1.2pyinstallerverification
uv lockuv run pytestuv sync --group dev --group releaseuv run python scripts/build_release_binary.pyCOOLDOWN_GUARD_BINARY=dist/cooldown-guard-darwin-arm64 uv run pytest tests/smoke_binary_test.pynotes
cooldown-guard-linux-x86_64andcooldown-guard-linux-x86_64.sha256Need help on this PR? Tag
@codesmithwith what you need.Summary by CodeRabbit
New Features
Documentation
Tests
Chores