Skip to content

Commit 75d83c2

Browse files
Bucknallaclaude
andauthored
Use setuptools-scm for automatic version management (#152)
Replace manual version management with setuptools-scm which derives the version from git tags at build time. This eliminates the need for a workflow to push version updates back to main (which required a PAT). - Add setuptools-scm as build dependency - Make version field dynamic in pyproject.toml - Update publish workflow to use setuptools-scm - Remove update-version.yml workflow Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 23507da commit 75d83c2

File tree

3 files changed

+8
-37
lines changed

3 files changed

+8
-37
lines changed

.github/workflows/python-publish.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,19 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Extract version from tag
17-
run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
18-
- name: Set version from tag
19-
run: sed -i "s/^version = \".*\"/version = \"$TAG_VERSION\"/" pyproject.toml
16+
with:
17+
fetch-depth: 0 # setuptools-scm needs full git history
2018
- name: Set up Python
2119
uses: actions/setup-python@v5
2220
with:
2321
python-version: '3.x'
2422
- name: Install dependencies
2523
run: |
2624
python -m pip install --upgrade pip
27-
pip install build twine
25+
pip install build twine setuptools-scm
2826
- name: Verify version
2927
run: |
30-
PACKAGE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
28+
PACKAGE_VERSION=$(python -m setuptools_scm)
3129
echo "Publishing version: $PACKAGE_VERSION"
3230
- name: Build and publish
3331
env:

.github/workflows/update-version.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["setuptools>=61.0"]
2+
requires = ["setuptools>=61.0", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "note-python"
7-
version = "2.1.4"
7+
dynamic = ["version"]
88
description = "Cross-platform Python Library for the Blues Wireless Notecard"
99
authors = [
1010
{name = "Blues Inc.", email = "support@blues.com"},
@@ -35,5 +35,7 @@ Repository = "https://github.com/blues/note-python"
3535
[tool.setuptools]
3636
packages = ["notecard"]
3737

38+
[tool.setuptools_scm]
39+
3840
[tool.pytest.ini_options]
3941
addopts = "--ignore=test/hitl/"

0 commit comments

Comments
 (0)