Skip to content

Commit d288aa8

Browse files
authored
feat: dynamic version from VCS and release notes auto-generation (#164)
Signed-off-by: Frost Ming <me@frostming.com>
1 parent b280c0a commit d288aa8

5 files changed

Lines changed: 34 additions & 24 deletions

File tree

.github/workflows/on-release-main.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,25 @@ on:
66

77
jobs:
88

9-
set-version:
10-
runs-on: ubuntu-24.04
9+
release-note:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
1113
steps:
12-
- uses: actions/checkout@v6
13-
14-
- name: Export tag
15-
id: vars
16-
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
17-
if: ${{ github.event_name == 'release' }}
18-
19-
- name: Update project version
20-
run: |
21-
sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
22-
env:
23-
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
24-
if: ${{ github.event_name == 'release' }}
14+
- name: Check out
15+
uses: actions/checkout@v6
16+
with:
17+
fetch-depth: 0
2518

26-
- name: Upload updated pyproject.toml
27-
uses: actions/upload-artifact@v6
19+
- uses: actions/setup-node@v6
2820
with:
29-
name: pyproject-toml
30-
path: pyproject.toml
21+
node-version: lts/*
22+
23+
- run: npx changelogithub
24+
continue-on-error: true
3125

3226
publish:
3327
runs-on: ubuntu-latest
34-
needs: [set-version]
3528
steps:
3629
- name: Check out
3730
uses: actions/checkout@v6

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,4 @@ reference/
145145

146146
# Local legacy backups created during framework migrations
147147
backup/
148+
_version.py

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "bub"
3-
version = "0.3.5"
3+
dynamic = ["version"]
44
description = "A common shape for agents that live alongside people."
55
authors = [
66
{ name = "Chojan Shang", email = "psiace@apache.org" },
@@ -64,9 +64,15 @@ dev = [
6464
]
6565

6666
[build-system]
67-
requires = ["hatchling"]
67+
requires = ["hatchling", "hatch-vcs"]
6868
build-backend = "hatchling.build"
6969

70+
[tool.hatch.version]
71+
source = "vcs"
72+
73+
[tool.hatch.build.hooks.vcs]
74+
version-file = "src/bub/_version.py"
75+
7076
[tool.hatch.build.targets.sdist]
7177
only-include = ["src/bub", "src/skills", "tests"]
7278

src/bub/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
"""Bub framework package."""
22

3+
from importlib import import_module
4+
from importlib.metadata import PackageNotFoundError
5+
from importlib.metadata import version as metadata_version
6+
37
from bub.framework import BubFramework
48
from bub.hookspecs import hookimpl
59
from bub.tools import tool
610

711
__all__ = ["BubFramework", "hookimpl", "tool"]
8-
__version__ = "0.3.5"
12+
13+
try:
14+
__version__ = import_module("bub._version").version
15+
except ModuleNotFoundError:
16+
try:
17+
__version__ = metadata_version("bub")
18+
except PackageNotFoundError:
19+
__version__ = "0.0.0"

uv.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)