Merge pull request #7 from hummingbot/feat/add_canldes_feed_route #17
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 to PyPI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
types: [ closed ] | |
jobs: | |
publish: | |
# Only run on merged PRs to main or direct pushes to main | |
if: github.event_name == 'push' || (github.event.pull_request.merged == true && github.base_ref == 'main') | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/hummingbot-client | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
contents: write # IMPORTANT: mandatory for creating releases | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch full history for proper versioning | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build twine | |
- name: Extract version from pyproject.toml | |
id: get_version | |
run: | | |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "Version to be published: $VERSION" | |
- name: Check if version exists on PyPI | |
id: check_version | |
run: | | |
VERSION="${{ steps.get_version.outputs.version }}" | |
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/hummingbot-client/$VERSION/json/") | |
if [ "$HTTP_STATUS" = "200" ]; then | |
echo "exists=true" >> $GITHUB_OUTPUT | |
echo "Version $VERSION already exists on PyPI" | |
else | |
echo "exists=false" >> $GITHUB_OUTPUT | |
echo "Version $VERSION does not exist on PyPI, proceeding with publication" | |
fi | |
- name: Build package | |
if: steps.check_version.outputs.exists == 'false' | |
run: | | |
python -m build | |
- name: Verify package contents | |
if: steps.check_version.outputs.exists == 'false' | |
run: | | |
echo "Contents of dist directory:" | |
ls -la dist/ | |
echo "" | |
echo "Checking package contents:" | |
python -m twine check dist/* | |
- name: Publish to PyPI | |
if: steps.check_version.outputs.exists == 'false' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
print-hash: true | |
verbose: true | |
- name: Create GitHub Release | |
if: steps.check_version.outputs.exists == 'false' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.get_version.outputs.version }} | |
release_name: Release v${{ steps.get_version.outputs.version }} | |
body: | | |
🚀 **Hummingbot Client v${{ steps.get_version.outputs.version }}** | |
This release has been automatically published to PyPI. | |
**Installation:** | |
```bash | |
pip install hummingbot-client==${{ steps.get_version.outputs.version }} | |
``` | |
**What's Changed:** | |
- See commit history for detailed changes | |
**Full Changelog:** https://github.com/hummingbot/hummingbot-client/compare/v${{ steps.get_version.outputs.version }}...v${{ steps.get_version.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Summary | |
if: steps.check_version.outputs.exists == 'false' | |
run: | | |
echo "✅ Successfully published hummingbot-client v${{ steps.get_version.outputs.version }} to PyPI!" | |
echo "📦 Package URL: https://pypi.org/project/hummingbot-client/${{ steps.get_version.outputs.version }}/" | |
echo "🎉 GitHub Release: https://github.com/hummingbot/hummingbot-client/releases/tag/v${{ steps.get_version.outputs.version }}" | |
- name: Skip publication | |
if: steps.check_version.outputs.exists == 'true' | |
run: | | |
echo "⏭️ Skipping publication - version ${{ steps.get_version.outputs.version }} already exists on PyPI" | |
echo "💡 To publish a new version, update the version in pyproject.toml" |