Release v0.0.7 #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release and Publish | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Extract version | |
| run: | | |
| VERSION="${{ github.event.release.tag_name }}" | |
| VERSION="${VERSION#v}" # 移除 v 前缀 | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| echo "Extracted version: ${VERSION}" | |
| - name: Update pyproject.toml | |
| run: | | |
| sed -i 's/version = "[^"]*"/version = "'${VERSION}'"/' pyproject.toml | |
| echo "Updated pyproject.toml version to ${VERSION}" | |
| - name: Update __version__ in __init__.py | |
| run: | | |
| if grep -q "__version__" agentrun/__init__.py; then | |
| sed -i 's/__version__ = "[^"]*"/__version__ = "'${VERSION}'"/' agentrun/__init__.py | |
| else | |
| sed -i '1a __version__ = "'${VERSION}'"' agentrun/__init__.py | |
| fi | |
| echo "Updated __init__.py version to ${VERSION}" | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add pyproject.toml agentrun/__init__.py | |
| if git diff --staged --quiet; then | |
| echo "No version changes to commit" | |
| else | |
| git commit -m "Update version to ${VERSION}" | |
| git push | |
| fi | |
| - name: Build package | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| python -m build | |
| echo "Package built successfully" | |
| - name: Verify package | |
| run: | | |
| python -m twine check dist/* | |
| echo "Package verification completed" | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| verify-metadata: false |