77jobs :
88 release :
99 runs-on : ubuntu-latest
10+ permissions :
11+ contents : write
12+ id-token : write
1013 steps :
1114 - uses : actions/checkout@v4
1215 with :
1316 token : ${{ secrets.GITHUB_TOKEN }}
1417 ref : main
18+ fetch-depth : 0
1519 - name : Set up Python
16- uses : actions/setup-python@v4
20+ uses : actions/setup-python@v5
1721 with :
1822 python-version : ' 3.10'
1923 - name : Extract version
20- run : echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
24+ run : |
25+ VERSION="${{ github.event.release.tag_name }}"
26+ VERSION="${VERSION#v}" # 移除 v 前缀
27+ echo "VERSION=${VERSION}" >> $GITHUB_ENV
28+ echo "Extracted version: ${VERSION}"
2129 - name : Update pyproject.toml
22- run : sed -i "s/version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
30+ run : |
31+ sed -i 's/version = "[^"]*"/version = "'${VERSION}'"/' pyproject.toml
32+ echo "Updated pyproject.toml version to ${VERSION}"
2333 - name : Update __version__ in __init__.py
2434 run : |
2535 if grep -q "__version__" agentrun/__init__.py; then
26- sed -i " s/__version__ = \".*\ "/__version__ = \" ${VERSION}\"/" agentrun/__init__.py
36+ sed -i ' s/__version__ = "[^"]* "/__version__ = "' ${VERSION}'"/' agentrun/__init__.py
2737 else
28- sed -i '1a __version__ = \" ${VERSION}\ "' agentrun/__init__.py
38+ sed -i '1a __version__ = "' ${VERSION}' "' agentrun/__init__.py
2939 fi
40+ echo "Updated __init__.py version to ${VERSION}"
3041 - name : Commit changes
3142 run : |
3243 git config --local user.email "action@github.com"
3344 git config --local user.name "GitHub Action"
3445 git add pyproject.toml agentrun/__init__.py
35- git commit -m "Update version to ${VERSION}" || echo "No changes to commit"
36- git push
46+ if git diff --staged --quiet; then
47+ echo "No version changes to commit"
48+ else
49+ git commit -m "Update version to ${VERSION}"
50+ git push
51+ fi
3752 - name : Build package
3853 run : |
3954 python -m pip install --upgrade pip
40- pip install build
55+ pip install build twine
4156 python -m build
57+ echo "Package built successfully"
58+ - name : Verify package
59+ run : |
60+ python -m twine check dist/*
61+ echo "Package verification completed"
4262 - name : Publish to PyPI
4363 uses : pypa/gh-action-pypi-publish@release/v1
4464 with :
45- password : ${{ secrets.PYPI_API_TOKEN }}
65+ password : ${{ secrets.PYPI_API_TOKEN }}
66+ verify-metadata : false
0 commit comments