99name : Upload Python Package
1010
1111on :
12- release :
13- types : [published]
12+ push :
13+ tags :
14+ - ' v*' # Push events to matching v*, i.e. v1.0, v20.15.10, v0.1.0.dev1
1415
1516permissions :
1617 contents : read
2122
2223 steps :
2324 - uses : actions/checkout@v4
25+ with :
26+ fetch-depth : 0
2427
2528 - name : Set up Python
2629 uses : actions/setup-python@v4
@@ -30,11 +33,36 @@ jobs:
3033 - name : Install uv
3134 uses : astral-sh/setup-uv@v5
3235
36+ - name : Install dependencies
37+ run : |
38+ uv pip install toml
39+
40+ - name : Extract version from tag and update pyproject.toml
41+ run : |
42+ # Get the version from the tag (remove 'v' prefix)
43+ TAG_VERSION=${GITHUB_REF#refs/tags/v}
44+ echo "Tag version: $TAG_VERSION"
45+
46+ # Update pyproject.toml with the version from the tag
47+ python -c "
48+ import toml
49+ data = toml.load('pyproject.toml')
50+ original_version = data['project']['version']
51+ data['project']['version'] = '$TAG_VERSION'
52+ with open('pyproject.toml', 'w') as f:
53+ toml.dump(data, f)
54+ print(f'Version updated in pyproject.toml: {original_version} -> {data[\"project\"][\"version\"]}')
55+ "
56+
57+ # Verify the change
58+ cat pyproject.toml | grep version
59+
3360 - name : Build package
3461 run : uv build --no-sources
3562
36- - name : Publish package
37- uses : pypa/gh-action-pypi-publish@v1.12.4
38- with :
39- user : __token__
40- password : ${{ secrets.PYPI_API_TOKEN }}
63+ # - name: Publish package to PyPI
64+ # uses: pypa/gh-action-pypi-publish@v1.12.4
65+ # with:
66+ # user: __token__
67+ # password: ${{ secrets.PYPI_API_TOKEN }}
68+ # verbose: true
0 commit comments