Skip to content

Commit 70173c5

Browse files
authored
Bump version to 2.8.1 (#120)
This pull request updates the versioning approach for the `struct` Python package and refines the GitHub Actions workflow for publishing to PyPI. The most important changes are the adoption of dynamic version retrieval, a version bump, and workflow simplification. **Versioning Improvements** * Updated the `struct_module/__init__.py` to dynamically retrieve the package version using `importlib.metadata`, falling back to `"unknown"` if the package is not installed. This replaces the previous hardcoded version string. * Changed the MCP server initialization in `struct_module/mcp_server.py` to use the dynamically retrieved `__version__` instead of a hardcoded value. **Release Workflow Simplification** * Removed the `update-version` job from `.github/workflows/publish-pypi.yml`, which previously updated the version in `pyproject.toml` on release events. The workflow now relies solely on manual dispatch and no longer automatically bumps the version on release. [[1]](diffhunk://#diff-d4585bdbbb00b46a400628c271f195eb312333d18474299152a0b75fb1a7ec4bL4-L5) [[2]](diffhunk://#diff-d4585bdbbb00b46a400628c271f195eb312333d18474299152a0b75fb1a7ec4bL14-L45) **Version Bump** * Updated the package version in `pyproject.toml` from `1.0.0` to `2.8.1` to reflect the new release.
1 parent 890bbe0 commit 70173c5

File tree

4 files changed

+9
-37
lines changed

4 files changed

+9
-37
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: publish-pypi
22

33
on:
4-
release:
5-
types: [published]
64
workflow_dispatch:
75
inputs:
86
upload:
@@ -11,38 +9,7 @@ on:
119
default: 'true'
1210

1311
jobs:
14-
update-version:
15-
runs-on: ubuntu-latest
16-
permissions:
17-
contents: write
18-
if: github.event_name == 'release'
19-
20-
steps:
21-
- uses: actions/checkout@v5
22-
with:
23-
ref: main
24-
25-
- name: Extract version from tag
26-
id: version
27-
run: |
28-
VERSION=${{ github.event.release.tag_name }}
29-
VERSION=${VERSION#v} # Remove 'v' prefix if present
30-
echo "version=$VERSION" >> $GITHUB_OUTPUT
31-
32-
- name: Update pyproject.toml
33-
run: |
34-
sed -i 's/version = "[^"]*"/version = "${{ steps.version.outputs.version }}"/' pyproject.toml
35-
36-
- name: Commit and push version update
37-
run: |
38-
git config user.name "github-actions[bot]"
39-
git config user.email "github-actions[bot]@users.noreply.github.com"
40-
git add pyproject.toml
41-
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}"
42-
git push origin main
43-
4412
build:
45-
needs: update-version
4613
runs-on: ubuntu-latest
4714

4815
steps:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "struct"
7-
version = "1.0.0"
7+
version = "2.8.1"
88
description = "A structured data processing tool"
99
readme = "README.md"
1010
license = {text = "MIT"}

struct_module/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
# Struct Module
2-
__version__ = '1.0.0'
1+
from importlib.metadata import version, PackageNotFoundError
2+
3+
try:
4+
__version__ = version('struct')
5+
except PackageNotFoundError:
6+
__version__ = "unknown"

struct_module/mcp_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818

1919
from struct_module.commands.generate import GenerateCommand
2020
from struct_module.commands.validate import ValidateCommand
21+
from struct_module import __version__
2122

2223

2324
class StructMCPServer:
2425
"""FastMCP-based MCP Server for struct tool operations."""
2526

2627
def __init__(self):
27-
self.app = FastMCP("struct-mcp-server", version="1.0.0")
28+
self.app = FastMCP("struct-mcp-server", version=__version__)
2829
self.logger = logging.getLogger(__name__)
2930
self._register_tools()
3031

0 commit comments

Comments
 (0)