Skip to content

Publish all OpenHands packages (uv) #85

Publish all OpenHands packages (uv)

Publish all OpenHands packages (uv) #85

Workflow file for this run

---
name: Publish all OpenHands packages (uv)
on:
# Run manually
workflow_dispatch:
# Run automatically when a release is published
release:
types: [published]
jobs:
publish:
# Skip PyPI publishing for pre-releases (e.g., release candidates).
# Pre-releases can still be created on GitHub for testing without
# pushing packages to PyPI. Manual workflow_dispatch always runs.
if: >
github.event_name == 'workflow_dispatch' ||
!github.event.release.prerelease
runs-on: ubuntu-24.04
permissions:
actions: write
contents: read
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Extract version from release tag
id: extract_version
env:
GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
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@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
version: latest
python-version: '3.13'
- 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!"
echo ""
echo "📋 Note: Version bump PRs will be created by the 'Create Version Bump PRs' workflow"
echo " which is dispatched after this publish succeeds."
- name: Dispatch version bump workflow
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.extract_version.outputs.version }}
run: |
gh workflow run version-bump-prs.yml \
--repo "${{ github.repository }}" \
-f "version=${VERSION}"
echo "🚀 Dispatched version-bump-prs.yml for v${VERSION}"