|
| 1 | +name: Release bnbagent to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version to release (e.g., 0.1.0)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + release_to_prod: |
| 11 | + description: 'Release to production PyPI (unchecked = test PyPI)' |
| 12 | + required: false |
| 13 | + default: false |
| 14 | + type: boolean |
| 15 | + skip_tests: |
| 16 | + description: 'Skip tests before release' |
| 17 | + required: false |
| 18 | + default: false |
| 19 | + type: boolean |
| 20 | + |
| 21 | +jobs: |
| 22 | + release: |
| 23 | + name: Build and Publish to PyPI |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + contents: write |
| 27 | + id-token: write # Required for trusted publishing to PyPI |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 # Fetch all history for tags |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: '3.12' |
| 39 | + |
| 40 | + - name: Install uv |
| 41 | + uses: astral-sh/setup-uv@v4 |
| 42 | + with: |
| 43 | + version: "latest" |
| 44 | + |
| 45 | + - name: Install dependencies |
| 46 | + run: | |
| 47 | + uv sync --extra dev |
| 48 | +
|
| 49 | + - name: Run tests |
| 50 | + if: ${{ !inputs.skip_tests }} |
| 51 | + run: | |
| 52 | + uv run pytest -v |
| 53 | +
|
| 54 | + - name: Update version in pyproject.toml |
| 55 | + run: | |
| 56 | + # Update version in pyproject.toml |
| 57 | + sed -i 's/^version = ".*"/version = "${{ inputs.version }}"/' pyproject.toml |
| 58 | + echo "Updated version to ${{ inputs.version }}" |
| 59 | + cat pyproject.toml | grep "^version" |
| 60 | +
|
| 61 | + - name: Build package |
| 62 | + run: | |
| 63 | + uv build |
| 64 | +
|
| 65 | + - name: Check package contents |
| 66 | + run: | |
| 67 | + ls -lh dist/ |
| 68 | + echo "Package files:" |
| 69 | + find dist -type f |
| 70 | +
|
| 71 | + - name: Publish to Production PyPI |
| 72 | + if: ${{ inputs.release_to_prod }} |
| 73 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 74 | + with: |
| 75 | + packages-dir: ./dist/ |
| 76 | + print-hash: true |
| 77 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 78 | + # Uses trusted publishing (OIDC) - no token needed |
| 79 | + # Configure OIDC in PyPI account settings: https://pypi.org/manage/account/publishing/ |
| 80 | + |
| 81 | + - name: Publish to Test PyPI |
| 82 | + if: ${{ !inputs.release_to_prod }} |
| 83 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 84 | + with: |
| 85 | + packages-dir: ./dist/ |
| 86 | + print-hash: true |
| 87 | + repository-url: https://test.pypi.org/legacy/ |
| 88 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 89 | + # For Test PyPI, you can use trusted publishing or API token |
| 90 | + # If using API token, set TEST_PYPI_API_TOKEN secret |
| 91 | + |
| 92 | + - name: Commit version update |
| 93 | + if: success() && inputs.release_to_prod |
| 94 | + run: | |
| 95 | + git config user.name "github-actions[bot]" |
| 96 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 97 | + git add pyproject.toml |
| 98 | + git commit -m "chore: bump version to ${{ inputs.version }}" || exit 0 |
| 99 | + git push origin HEAD:${{ github.ref_name }} || echo "No changes to commit or branch protection" |
| 100 | +
|
| 101 | + - name: Create Git tag |
| 102 | + if: success() && inputs.release_to_prod |
| 103 | + run: | |
| 104 | + git config user.name "github-actions[bot]" |
| 105 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 106 | + git tag -a "bnbagent-v${{ inputs.version }}" -m "Release bnbagent v${{ inputs.version }}" |
| 107 | + git push origin "bnbagent-v${{ inputs.version }}" |
| 108 | +
|
| 109 | + - name: Create GitHub Release |
| 110 | + if: success() && inputs.release_to_prod |
| 111 | + uses: softprops/action-gh-release@v1 |
| 112 | + with: |
| 113 | + tag_name: bnbagent-v${{ inputs.version }} |
| 114 | + name: bnbagent v${{ inputs.version }} |
| 115 | + body: | |
| 116 | + ## bnbagent v${{ inputs.version }} |
| 117 | +
|
| 118 | + Python SDK for ERC-8004 on-chain agent registration and management. |
| 119 | +
|
| 120 | + ### Installation |
| 121 | +
|
| 122 | + ```bash |
| 123 | + pip install bnbagent==${{ inputs.version }} |
| 124 | + ``` |
| 125 | +
|
| 126 | + ✅ Published to **Production PyPI** |
| 127 | +
|
| 128 | + ### Changes |
| 129 | +
|
| 130 | + See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details. |
| 131 | + draft: false |
| 132 | + prerelease: false |
0 commit comments