Repository navigation
Initial release: AI AgentTools v0.2.1 - Comprehensive toolkit for AI … #2
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: Publish Python Package | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'pyproject.toml' | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| jobs: | |
| check-version: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' | |
| outputs: | |
| version-changed: ${{ steps.check.outputs.changed }} | |
| new-version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check if version changed | |
| id: check | |
| run: | | |
| # Get current version | |
| CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| # Get previous version | |
| git checkout HEAD~1 -- pyproject.toml 2>/dev/null || true | |
| PREVIOUS_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/' || echo "0.0.0") | |
| # Restore current version | |
| git checkout HEAD -- pyproject.toml | |
| echo "Previous version: $PREVIOUS_VERSION" | |
| echo "Current version: $CURRENT_VERSION" | |
| if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "Version unchanged" | |
| fi | |
| create-release: | |
| needs: check-version | |
| runs-on: ubuntu-latest | |
| if: needs.check-version.outputs.version-changed == 'true' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ needs.check-version.outputs.new-version }} | |
| release_name: v${{ needs.check-version.outputs.new-version }} | |
| body: | | |
| Release version ${{ needs.check-version.outputs.new-version }} | |
| See [CHANGELOG](https://github.com/${{ github.repository }}/blob/main/README.md) for details. | |
| draft: false | |
| prerelease: false | |
| deploy: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' || needs.check-version.outputs.version-changed == 'true' | |
| needs: [check-version, create-release] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Verify version matches tag (for release events) | |
| if: github.event_name == 'release' | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| PKG_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| echo "Tag version: $TAG_VERSION" | |
| echo "Package version: $PKG_VERSION" | |
| if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then | |
| echo "Error: Tag version ($TAG_VERSION) doesn't match package version ($PKG_VERSION)" | |
| exit 1 | |
| fi | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| python -m twine upload dist/* |