-
Notifications
You must be signed in to change notification settings - Fork 41
Add Python SDK publish workflow #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Python SDK Publish | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "sdk-python/**" | ||
| - ".github/workflows/python-sdk-publish.yml" | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| publish-python-sdk: | ||
| runs-on: ubuntu-latest | ||
| environment: pypi | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install build dependency | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build | ||
|
|
||
| - name: Build package | ||
| run: make build-python-sdk | ||
|
|
||
| - name: Read package version | ||
| id: package | ||
| working-directory: sdk-python | ||
| run: | | ||
| version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, this is using same version for all the changes on main branch right?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. We use the version declared in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question is whether we need automatic version updates or manual version control in |
||
| echo "version=$version" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Check whether version already exists on PyPI | ||
| id: pypi | ||
| env: | ||
| PACKAGE_NAME: agentcube-sdk | ||
acsoto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| PACKAGE_VERSION: ${{ steps.package.outputs.version }} | ||
| run: | | ||
| status="$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/${PACKAGE_NAME}/${PACKAGE_VERSION}/json")" | ||
| if [ "$status" = "200" ]; then | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| echo "Version ${PACKAGE_VERSION} already exists on PyPI, skipping publish." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default, use ‘latest’ as the release version. Since running this GitHub Action indicates that changes have been made to the python-sdk package in agentCube, it should be updated to the ‘latest’ version number even if the version remains the same.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Therefore, the ‘version=latest’ should be push unconditionally, followed by the ‘version=x.y.z’ where applicable; to ensure that each agentCube version has the corresponding Python SDK version.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PyPI package versions are immutable, so unlike container images we cannot keep updating a mutable
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, I think that for the release security, we should explicitly control the version in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, is the best practice for PyPI to push a Python SDK version each time an agentCube release is published?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. When releasing the agentcube version, manually update the SDK version number |
||
| else | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| echo "Version ${PACKAGE_VERSION} is not published yet." | ||
acsoto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| - name: Publish package to PyPI | ||
| if: steps.pypi.outputs.exists != 'true' | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| packages-dir: sdk-python/dist/ | ||
Uh oh!
There was an error while loading. Please reload this page.