Skip to content

Add Python SDK publish workflow#247

Merged
volcano-sh-bot merged 1 commit intovolcano-sh:mainfrom
acsoto:issue-246-python-sdk-publish
Mar 31, 2026
Merged

Add Python SDK publish workflow#247
volcano-sh-bot merged 1 commit intovolcano-sh:mainfrom
acsoto:issue-246-python-sdk-publish

Conversation

@acsoto
Copy link
Copy Markdown
Member

@acsoto acsoto commented Mar 28, 2026

What type of PR is this?

/kind enhancement

What this PR does / why we need it:

This PR adds an automated publishing workflow for the Python SDK.

The new workflow builds the package from sdk-python, reads the package version from sdk-python/pyproject.toml, checks whether that version already exists on PyPI, and only publishes when the version is not already present.

It also tightens the SDK packaging flow by:

  • excluding Python cache artifacts from the source distribution
  • updating the Python package license metadata to the modern string form
  • reusing the existing make build-python-sdk path so the root LICENSE remains the single source of truth while still being included in built artifacts

Trusted publishing for PyPI has already been configured for this repository, so this workflow does not require a stored PyPI API token. It uses PyPI's trusted publisher flow via GitHub Actions OIDC and pypa/gh-action-pypi-publish.

Screenshot 2026-03-28 at 21 38 52

References:

Which issue(s) this PR fixes:
Fixes #246

Special notes for your reviewer:

The publish job is intentionally limited to push on main and manual dispatch. Existing Python test workflows remain responsible for test coverage; this workflow focuses on build-and-publish behavior.

Does this PR introduce a user-facing change?:

Added automated PyPI publishing for the Python SDK when `sdk-python` changes are merged to `main`.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Python SDK build process in the Makefile to ensure the temporary LICENSE file is removed even if the build fails, excludes Python cache files from the package manifest, and simplifies the license specification in pyproject.toml. Feedback suggests using a shell trap in the Makefile for a more idiomatic and robust cleanup of the temporary license file.

Signed-off-by: Zhou Zihang <z@mcac.cc>
@acsoto acsoto force-pushed the issue-246-python-sdk-publish branch from 7eb0d75 to 6a2be5b Compare March 28, 2026 13:59
@acsoto acsoto marked this pull request as ready for review March 28, 2026 14:00
Copilot AI review requested due to automatic review settings March 28, 2026 14:00
@acsoto
Copy link
Copy Markdown
Member Author

acsoto commented Mar 28, 2026

Pls take a look thanks
@LiZhenCheng9527 @YaoZengzeng

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.35%. Comparing base (845b798) to head (6a2be5b).
⚠️ Report is 129 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #247      +/-   ##
==========================================
+ Coverage   35.60%   43.35%   +7.74%     
==========================================
  Files          29       30       +1     
  Lines        2533     2611      +78     
==========================================
+ Hits          902     1132     +230     
+ Misses       1505     1358     -147     
+ Partials      126      121       -5     
Flag Coverage Δ
unittests 43.35% <ø> (+7.74%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions workflow to automatically publish the sdk-python Python SDK to PyPI using trusted publishing (OIDC), alongside small packaging/build tweaks to ensure correct artifacts are produced.

Changes:

  • Added python-sdk-publish.yml workflow to build, check PyPI for an existing version, and publish only when needed.
  • Tightened Python sdist contents by excluding Python cache artifacts.
  • Updated the build-python-sdk Makefile target to use a temporary copied LICENSE file with reliable cleanup.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
sdk-python/pyproject.toml Updates license metadata format for the SDK package.
sdk-python/MANIFEST.in Excludes __pycache__ and *.py[cod] from the source distribution.
Makefile Makes build-python-sdk copy/remove LICENSE via an EXIT trap for safer cleanup.
.github/workflows/python-sdk-publish.yml New workflow to build the SDK and publish to PyPI via trusted publishing when the version is not already present.

id: package
working-directory: sdk-python
run: |
version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We use the version declared in sdk-python/pyproject.toml, so if that version does not change, later runs on main will skip

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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 sdk-python/pyproject.toml. I think the latter is more under control

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."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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 latest tag for the same package version. Re-publishing the same version is not supported. So if we want to do that we need to do a version auto updater

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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 sdk-python/pyproject.toml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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

@LiZhenCheng9527
Copy link
Copy Markdown
Contributor

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot merged commit 46b07f7 into volcano-sh:main Mar 31, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need an action to automatically package the Python SDK

6 participants