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: Publish all OpenHands packages (uv) | |
| on: | |
| # Run manually | |
| workflow_dispatch: | |
| # Run automatically when a release is published | |
| release: | |
| types: [published] | |
| jobs: | |
| publish: | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| outputs: | |
| version: ${{ steps.extract_version.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Extract version from release tag | |
| id: extract_version | |
| run: | | |
| # Get version from release tag (e.g., v1.2.3 -> 1.2.3) | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| VERSION="${{ github.event.release.tag_name }}" | |
| VERSION="${VERSION#v}" # Remove 'v' prefix if present | |
| else | |
| # For manual dispatch, extract from pyproject.toml | |
| VERSION=$(grep -m1 '^version = ' openhands-sdk/pyproject.toml | cut -d'"' -f2) | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "📦 Version: $VERSION" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: latest | |
| - name: Build and publish all packages | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN_OPENHANDS }} | |
| run: | | |
| set -euo pipefail | |
| if [ -z "${UV_PUBLISH_TOKEN:-}" ]; then | |
| echo "❌ Missing secret PYPI_TOKEN_OPENHANDS" | |
| exit 1 | |
| fi | |
| PACKAGES=( | |
| openhands-sdk | |
| openhands-tools | |
| openhands-workspace | |
| openhands-agent-server | |
| ) | |
| echo "🚀 Building and publishing all packages..." | |
| for PKG in "${PACKAGES[@]}"; do | |
| echo "===== $PKG =====" | |
| uv build --package "$PKG" | |
| done | |
| # Use --check-url to skip files that already exist on PyPI | |
| # This allows re-running the workflow after partial failures | |
| uv publish --token "$UV_PUBLISH_TOKEN" --check-url https://pypi.org/simple/ | |
| echo "✅ All packages built and published successfully!" | |
| create-version-bump-prs: | |
| needs: publish | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| if: github.event_name == 'release' | |
| env: | |
| VERSION: ${{ needs.publish.outputs.version }} | |
| GH_TOKEN: ${{ secrets.ALLHANDS_BOT_GITHUB_PAT }} | |
| steps: | |
| - name: Validate version | |
| run: | | |
| if [ -z "$VERSION" ]; then | |
| echo "❌ Version is empty" | |
| exit 1 | |
| fi | |
| echo "📦 Creating version bump PRs for version: $VERSION" | |
| - name: Wait for packages to be available on PyPI | |
| run: | | |
| set -euo pipefail | |
| PACKAGES=( | |
| openhands-sdk | |
| openhands-tools | |
| openhands-workspace | |
| openhands-agent-server | |
| ) | |
| MAX_ATTEMPTS=60 | |
| SLEEP_SECONDS=20 | |
| echo "⏳ Waiting for packages to be available on PyPI..." | |
| for PKG in "${PACKAGES[@]}"; do | |
| echo "Checking $PKG==$VERSION..." | |
| ATTEMPT=1 | |
| while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do | |
| # Check if the package version is available on PyPI | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ | |
| "https://pypi.org/pypi/$PKG/$VERSION/json") | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "✅ $PKG==$VERSION is available on PyPI" | |
| break | |
| fi | |
| echo " Attempt $ATTEMPT/$MAX_ATTEMPTS: $PKG==$VERSION not yet available (HTTP $HTTP_CODE), waiting ${SLEEP_SECONDS}s..." | |
| sleep $SLEEP_SECONDS | |
| ATTEMPT=$((ATTEMPT + 1)) | |
| done | |
| if [ $ATTEMPT -gt $MAX_ATTEMPTS ]; then | |
| echo "❌ Timeout waiting for $PKG==$VERSION to be available on PyPI" | |
| exit 1 | |
| fi | |
| done | |
| echo "✅ All packages are available on PyPI!" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: latest | |
| - name: Install Poetry | |
| run: | | |
| pipx install poetry | |
| - name: Create PR for OpenHands repo | |
| run: | | |
| set -euo pipefail | |
| REPO="All-Hands-AI/OpenHands" | |
| BRANCH="bump-sdk-$VERSION" | |
| echo "🔄 Creating PR for $REPO..." | |
| # Clone the repo | |
| git clone "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" openhands-repo | |
| cd openhands-repo | |
| # Configure git | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Create branch | |
| git checkout -b "$BRANCH" | |
| # Get the git hash from the release branch in software-agent-sdk | |
| SDK_COMMIT_HASH=$(git ls-remote https://github.com/OpenHands/software-agent-sdk.git "refs/tags/v$VERSION" | cut -c1-7) | |
| if [ -z "$SDK_COMMIT_HASH" ]; then | |
| echo "⚠️ Could not find commit hash for tag v$VERSION, using full version" | |
| SDK_COMMIT_HASH="$VERSION" | |
| fi | |
| echo "📦 SDK commit hash: $SDK_COMMIT_HASH" | |
| # 1. Update versions in pyproject.toml using poetry | |
| echo "📝 Updating pyproject.toml..." | |
| poetry add "openhands-sdk==$VERSION" "openhands-tools==$VERSION" "openhands-agent-server==$VERSION" | |
| # 2. Generate poetry.lock in root | |
| echo "🔒 Running poetry lock in root..." | |
| poetry lock | |
| # 3. Generate poetry.lock in enterprise directory | |
| echo "🔒 Running poetry lock in enterprise/..." | |
| cd enterprise | |
| poetry lock | |
| cd .. | |
| # 4. Update the hash in sandbox_spec_service.py | |
| echo "🔧 Updating AGENT_SERVER_IMAGE hash..." | |
| SANDBOX_SPEC_FILE="openhands/app_server/sandbox/sandbox_spec_service.py" | |
| if [ -f "$SANDBOX_SPEC_FILE" ]; then | |
| # Update the AGENT_SERVER_IMAGE line with the new hash | |
| sed -i "s|AGENT_SERVER_IMAGE = 'ghcr.io/openhands/agent-server:[^']*'|AGENT_SERVER_IMAGE = 'ghcr.io/openhands/agent-server:${SDK_COMMIT_HASH}-python'|" "$SANDBOX_SPEC_FILE" | |
| echo "✅ Updated AGENT_SERVER_IMAGE to: ghcr.io/openhands/agent-server:${SDK_COMMIT_HASH}-python" | |
| else | |
| echo "❌ sandbox_spec_service.py not found at expected path" | |
| exit 1 | |
| fi | |
| # Check if there are changes | |
| if git diff --quiet; then | |
| echo "⚠️ No changes detected in $REPO - versions may already be up to date" | |
| exit 0 | |
| fi | |
| # Commit and push | |
| git add . | |
| git commit -m "Bump openhands-sdk, openhands-tools, openhands-agent-server to $VERSION" \ | |
| -m "Automated version bump after PyPI release." \ | |
| -m "" \ | |
| -m "Changes:" \ | |
| -m "- Updated SDK packages to v$VERSION in pyproject.toml" \ | |
| -m "- Regenerated poetry.lock" \ | |
| -m "- Regenerated enterprise/poetry.lock" \ | |
| -m "- Updated AGENT_SERVER_IMAGE hash to ${SDK_COMMIT_HASH}" \ | |
| -m "" \ | |
| -m "Co-authored-by: openhands <openhands@all-hands.dev>" | |
| git push -u origin "$BRANCH" | |
| # Create PR | |
| gh pr create \ | |
| --repo "$REPO" \ | |
| --title "Bump SDK packages to v$VERSION" \ | |
| --body "## Automated Version Bump | |
| This PR updates the following packages to version **$VERSION**: | |
| - \`openhands-sdk\` | |
| - \`openhands-tools\` | |
| - \`openhands-agent-server\` | |
| ### Changes | |
| - Updated SDK packages in \`pyproject.toml\` | |
| - Regenerated \`poetry.lock\` | |
| - Regenerated \`enterprise/poetry.lock\` | |
| - Updated \`AGENT_SERVER_IMAGE\` hash to \`${SDK_COMMIT_HASH}\` in \`sandbox_spec_service.py\` | |
| **Triggered by:** Release of [software-agent-sdk v$VERSION](https://github.com/OpenHands/software-agent-sdk/releases/tag/v$VERSION) | |
| --- | |
| _This PR was automatically created by the pypi-release workflow._" \ | |
| --base main \ | |
| --head "$BRANCH" | |
| echo "✅ PR created for $REPO" | |
| - name: Create PR for OpenHands-CLI repo | |
| run: | | |
| set -euo pipefail | |
| REPO="All-Hands-AI/openhands-cli" | |
| BRANCH="bump-sdk-$VERSION" | |
| echo "🔄 Creating PR for $REPO..." | |
| # Clone the repo | |
| git clone "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" openhands-cli-repo | |
| cd openhands-cli-repo | |
| # Configure git | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Create branch | |
| git checkout -b "$BRANCH" | |
| # Update versions using uv | |
| uv add "openhands-sdk==$VERSION" "openhands-tools==$VERSION" | |
| # Check if there are changes | |
| if git diff --quiet; then | |
| echo "⚠️ No changes detected in $REPO - versions may already be up to date" | |
| exit 0 | |
| fi | |
| # Commit and push | |
| git add pyproject.toml uv.lock | |
| git commit -m "Bump openhands-sdk, openhands-tools to $VERSION" \ | |
| -m "Automated version bump after PyPI release." \ | |
| -m "Co-authored-by: openhands <openhands@all-hands.dev>" | |
| git push -u origin "$BRANCH" | |
| # Create PR | |
| gh pr create \ | |
| --repo "$REPO" \ | |
| --title "Bump SDK packages to v$VERSION" \ | |
| --body "## Automated Version Bump | |
| This PR updates the following packages to version **$VERSION**: | |
| - \`openhands-sdk\` | |
| - \`openhands-tools\` | |
| **Triggered by:** Release of [software-agent-sdk v$VERSION](https://github.com/OpenHands/software-agent-sdk/releases/tag/v$VERSION) | |
| --- | |
| _This PR was automatically created by the pypi-release workflow._" \ | |
| --base main \ | |
| --head "$BRANCH" | |
| echo "✅ PR created for $REPO" | |
| - name: Summary | |
| run: | | |
| echo "## ✅ Version Bump PRs Created" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "PRs have been created to bump SDK packages to version **$VERSION**:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- [OpenHands](https://github.com/All-Hands-AI/OpenHands/pulls?q=is%3Apr+bump-sdk-$VERSION)" >> $GITHUB_STEP_SUMMARY | |
| echo "- [OpenHands-CLI](https://github.com/All-Hands-AI/openhands-cli/pulls?q=is%3Apr+bump-sdk-$VERSION)" >> $GITHUB_STEP_SUMMARY | |
| - name: Notify Slack | |
| uses: slackapi/slack-github-action@v2.1.1 | |
| with: | |
| method: chat.postMessage | |
| token: ${{ secrets.SLACK_BOT_TOKEN }} | |
| payload: | | |
| channel: C08E1SYKEM9 | |
| text: "🚀 *SDK v${{ env.VERSION }} published to PyPI!*\n\nVersion bump PRs created:\n• <https://github.com/All-Hands-AI/OpenHands/pulls?q=is%3Apr+bump-sdk-${{ env.VERSION }}|OpenHands>\n• <https://github.com/All-Hands-AI/openhands-cli/pulls?q=is%3Apr+bump-sdk-${{ env.VERSION }}|OpenHands-CLI>\n\n<https://github.com/OpenHands/software-agent-sdk/releases/tag/v${{ env.VERSION }}|View Release>" |