-
Notifications
You must be signed in to change notification settings - Fork 3
bump to 0.8 #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bump to 0.8 #47
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: Nightly SDK Version Bump | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 3 * * *" # 03:00 UTC every night | ||
| workflow_dispatch: {} | ||
|
|
||
| jobs: | ||
| bump: | ||
| name: Update SDK versions and create PR | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.x" | ||
|
|
||
| - name: Install Python dependencies for script | ||
| run: pip install requests | ||
|
|
||
| - name: Run update_versions.py | ||
| run: python scripts/update_versions.py | ||
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@v5 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: "chore: bump kernel sdk versions to latest" | ||
| title: "chore: nightly SDK version bump" | ||
| body: | | ||
| This PR updates Python `kernel` and TypeScript `@onkernel/sdk` version constraints to the latest published releases. | ||
| branch: "github-actions/nightly-sdk-bump" | ||
| signoff: false | ||
| delete-branch: true | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| #!/usr/bin/env python3 | ||
| """update_versions.py | ||
|
|
||
| Fetch the latest released versions of: | ||
| * PyPI package `kernel` | ||
| * npm package `@onkernel/sdk` | ||
|
|
||
| and update every version constraint inside: | ||
| * templates/python/*/pyproject.toml -> "kernel>=<latest>" | ||
| * templates/typescript/*/package.json -> "@onkernel/sdk": ">=<latest>" | ||
|
|
||
| If a file is modified, it is overwritten in-place. The script exits with code 0 | ||
| whether or not modifications were required. However, it prints a summary that is | ||
| useful inside CI to decide if a commit is necessary. | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| import os | ||
| import re | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import List | ||
|
|
||
| try: | ||
| import requests # type: ignore | ||
| except ImportError: | ||
| subprocess.check_call([sys.executable, "-m", "pip", "install", "requests"]) | ||
| import requests # type: ignore | ||
|
|
||
| REPO_ROOT = Path(__file__).resolve().parent.parent | ||
| PY_TEMPLATES_GLOB = REPO_ROOT / "templates" / "python" / "*" / "pyproject.toml" | ||
| TS_TEMPLATES_GLOB = REPO_ROOT / "templates" / "typescript" / "*" / "package.json" | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Helpers to fetch latest versions | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| def _get_latest_pypi_version(package: str) -> str: | ||
| url = f"https://pypi.org/pypi/{package}/json" | ||
| resp = requests.get(url, timeout=10) | ||
| resp.raise_for_status() | ||
| data = resp.json() | ||
| return data["info"]["version"] | ||
|
|
||
|
|
||
| def _get_latest_npm_version(package: str) -> str: | ||
| # NPM package names are url-encoded | ||
| import urllib.parse as _up | ||
|
|
||
| encoded = _up.quote(package, safe="") | ||
| url = f"https://registry.npmjs.org/{encoded}" | ||
| resp = requests.get(url, timeout=10) | ||
| resp.raise_for_status() | ||
| data = resp.json() | ||
| return data["dist-tags"]["latest"] | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Updaters | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| _KERN_DEP_REGEX = re.compile(r"(\"kernel)([^\"]*)(\")") | ||
|
|
||
|
|
||
| def _update_pyproject(file_path: Path, new_version: str) -> bool: | ||
| """Return True if file changed.""" | ||
| text = file_path.read_text() | ||
|
|
||
| # Replace any appearance like "kernel>=0.8.0", "kernel==0.5.0", "kernel~=0.7" | ||
| new_constraint = f'"kernel>={new_version}"' | ||
| new_text = re.sub(r'"kernel[<>=~!0-9.]*"', new_constraint, text) | ||
|
|
||
| if new_text != text: | ||
| file_path.write_text(new_text) | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
| def _update_package_json(file_path: Path, new_version: str) -> bool: | ||
| data = json.loads(file_path.read_text()) | ||
| changed = False | ||
|
|
||
| for section in ("dependencies", "peerDependencies" , "devDependencies"): | ||
| deps = data.get(section) | ||
| if deps and "@onkernel/sdk" in deps: | ||
| if deps["@onkernel/sdk"] != f">={new_version}": | ||
| deps["@onkernel/sdk"] = f">={new_version}" | ||
| changed = True | ||
|
|
||
| if changed: | ||
| file_path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n") | ||
| return changed | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Main execution | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| def main() -> None: | ||
| latest_kernel = _get_latest_pypi_version("kernel") | ||
| latest_sdk = _get_latest_npm_version("@onkernel/sdk") | ||
|
|
||
| print(f"Latest kernel version on PyPI: {latest_kernel}") | ||
| print(f"Latest @onkernel/sdk version on npm: {latest_sdk}") | ||
|
|
||
| modified_files: List[Path] = [] | ||
|
|
||
| # Python templates | ||
| for file_path in REPO_ROOT.glob("templates/python/*/pyproject.toml"): | ||
| if _update_pyproject(file_path, latest_kernel): | ||
| modified_files.append(file_path.relative_to(REPO_ROOT)) | ||
|
|
||
| # Typescript templates | ||
| for file_path in REPO_ROOT.glob("templates/typescript/*/package.json"): | ||
| if _update_package_json(file_path, latest_sdk): | ||
| modified_files.append(file_path.relative_to(REPO_ROOT)) | ||
|
|
||
| if modified_files: | ||
| print("Updated the following files:") | ||
| for p in modified_files: | ||
| print(f" - {p}") | ||
| else: | ||
| print("All template files already up-to-date. No changes made.") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| "build": "tsc" | ||
| }, | ||
| "dependencies": { | ||
| "@onkernel/sdk": "^0.6.0", | ||
| "@onkernel/sdk": ">=0.8.0", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change from While this aligns with the automated nightly bump strategy, consider if this could introduce instability in template projects. You might want to either:
Type: Logic | Severity: Medium |
||
| "dotenv": "^16.5.0", | ||
| "openai": "^5.7.0", | ||
| "playwright": "^1.53.0", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
secrets.GITHUB_TOKENhere may cause permission issues. The defaultGITHUB_TOKENhas limited permissions and PRs created with it typically don't trigger other workflows (like CI). Consider using a personal access token or GitHub App token stored as a secret (e.g.,secrets.PAT_TOKEN) if you need the created PR to trigger other workflows.Type: Logic | Severity: Medium