FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ci(release): verify a release tag matches the declared version by a7vinx · Pull Request #2 · 19PINE-AI/pine-assistant-python · GitHub

Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (2) .py  (1) .yml  (1) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
63 changes: 63 additions & 0 deletions .github/version.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Read and check the package version.

The version lives in two files that have to agree, and PyPI will not let a
version be replaced once uploaded — so a disagreement cannot be corrected in
place. This exists so the agreement does not depend on remembering.
"""

from __future__ import annotations

import argparse
import pathlib
import re
import sys

ROOT = pathlib.Path(__file__).resolve().parent.parent
PYPROJECT = ROOT / "pyproject.toml"
INIT = ROOT / "src" / "pine_assistant" / "__init__.py"

PYPROJECT_RE = re.compile(r'^(version\s*=\s*")([^"]+)(")', re.MULTILINE)
INIT_RE = re.compile(r'^(__version__\s*=\s*")([^"]+)(")', re.MULTILINE)
SOURCES = ((PYPROJECT, PYPROJECT_RE), (INIT, INIT_RE))


def read() -> dict[pathlib.Path, str]:
found = {}
for path, pattern in SOURCES:
match = pattern.search(path.read_text())
if match is None:
sys.exit(f"no version found in {path.relative_to(ROOT)}")
found[path] = match.group(2)
return found


def check(expected: str) -> None:
"""Fail unless both files carry `expected`.

Guards a tag build: a tag naming one version while the package declares
another publishes something no one can find, and it cannot be corrected in
place.
"""
mismatched = {p: v for p, v in read().items() if v != expected}
if mismatched:
for path, version in mismatched.items():
print(f"{path.relative_to(ROOT)}: {version} (tag says {expected})", file=sys.stderr)
sys.exit("version mismatch")
print(f"version {expected} agrees across {len(SOURCES)} files")


def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--check", metavar="VERSION", help="fail unless both files say VERSION")
group.add_argument("--show", action="store_true", help="print the current version")
args = parser.parse_args()

if args.check:
check(args.check)
else:
print(next(iter(read().values())))


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
with:
python-version: "3.12"

- name: Check the tag matches the declared version
run: python .github/version.py --check "${GITHUB_REF_NAME#v}"

- name: Install build tools
run: pip install build

Expand Down
6 changes: 6 additions & 0 deletions README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ pip install pine-assistant # SDK only
pip install pine-assistant[cli] # SDK + CLI
```

For unreleased work, install from the repository — any branch or commit:

```bash
pip install "git+https://github.com/19PINE-AI/pine-assistant-python@main"
```

## Quick Start (Async)

```python
Expand Down
4 changes: 4 additions & 0 deletions RELEASING.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ It installs, imports, builds, and verifies the package across Python 3.10 – 3.
git push && git push --tags
```
3. The `publish.yml` workflow triggers on the `v*` tag, runs CI first, then publishes to PyPI.

The workflow refuses a tag that disagrees with either file. PyPI will not let a
version be replaced once uploaded, so a tag naming one version while the package
declares another cannot be corrected in place — only yanked and re-cut.
Loading

Back | FazBrowse Home | New Git URL