From 0e0541c11ca2a915a33195b12dcaa553d9248144 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Mon, 13 Apr 2026 16:56:20 +0800 Subject: [PATCH] feat: dynamic version from VCS and release notes auto-generation Signed-off-by: Frost Ming --- .github/workflows/on-release-main.yml | 33 +++++++++++---------------- .gitignore | 1 + pyproject.toml | 10 ++++++-- src/bub/__init__.py | 13 ++++++++++- uv.lock | 1 - 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/.github/workflows/on-release-main.yml b/.github/workflows/on-release-main.yml index b42cf7ab..00363298 100644 --- a/.github/workflows/on-release-main.yml +++ b/.github/workflows/on-release-main.yml @@ -6,32 +6,25 @@ on: jobs: - set-version: - runs-on: ubuntu-24.04 + release-note: + runs-on: ubuntu-latest + permissions: + contents: write steps: - - uses: actions/checkout@v6 - - - name: Export tag - id: vars - run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT - if: ${{ github.event_name == 'release' }} - - - name: Update project version - run: | - sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml - env: - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} - if: ${{ github.event_name == 'release' }} + - name: Check out + uses: actions/checkout@v6 + with: + fetch-depth: 0 - - name: Upload updated pyproject.toml - uses: actions/upload-artifact@v6 + - uses: actions/setup-node@v6 with: - name: pyproject-toml - path: pyproject.toml + node-version: lts/* + + - run: npx changelogithub + continue-on-error: true publish: runs-on: ubuntu-latest - needs: [set-version] steps: - name: Check out uses: actions/checkout@v6 diff --git a/.gitignore b/.gitignore index e7bed02c..8f4a5a9c 100644 --- a/.gitignore +++ b/.gitignore @@ -145,3 +145,4 @@ reference/ # Local legacy backups created during framework migrations backup/ +_version.py diff --git a/pyproject.toml b/pyproject.toml index 29c8f0d6..a5755ee1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "bub" -version = "0.3.5" +dynamic = ["version"] description = "A common shape for agents that live alongside people." authors = [ { name = "Chojan Shang", email = "psiace@apache.org" }, @@ -64,9 +64,15 @@ dev = [ ] [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/bub/_version.py" + [tool.hatch.build.targets.sdist] only-include = ["src/bub", "src/skills", "tests"] diff --git a/src/bub/__init__.py b/src/bub/__init__.py index d76eb9da..7f3838de 100644 --- a/src/bub/__init__.py +++ b/src/bub/__init__.py @@ -1,8 +1,19 @@ """Bub framework package.""" +from importlib import import_module +from importlib.metadata import PackageNotFoundError +from importlib.metadata import version as metadata_version + from bub.framework import BubFramework from bub.hookspecs import hookimpl from bub.tools import tool __all__ = ["BubFramework", "hookimpl", "tool"] -__version__ = "0.3.5" + +try: + __version__ = import_module("bub._version").version +except ModuleNotFoundError: + try: + __version__ = metadata_version("bub") + except PackageNotFoundError: + __version__ = "0.0.0" diff --git a/uv.lock b/uv.lock index bb9d81e5..76188f97 100644 --- a/uv.lock +++ b/uv.lock @@ -204,7 +204,6 @@ wheels = [ [[package]] name = "bub" -version = "0.3.5" source = { editable = "." } dependencies = [ { name = "aiohttp" },