mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-30 14:52:36 +00:00
135 lines
3.7 KiB
YAML
135 lines
3.7 KiB
YAML
name: Publish to PyPI
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_tag:
|
|
description: 'Release tag to publish'
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
name: Build packages
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Determine release tag
|
|
id: release
|
|
run: |
|
|
if [ -n "${{ inputs.release_tag }}" ]; then
|
|
echo "tag=${{ inputs.release_tag }}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ steps.release.outputs.tag || github.ref }}
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v4
|
|
|
|
- name: Build packages
|
|
run: |
|
|
uv build --all-packages
|
|
rm dist/.gitignore
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
publish:
|
|
name: Publish to PyPI
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: pypi
|
|
url: https://pypi.org/p/crewai
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
version: "0.8.4"
|
|
python-version: "3.12"
|
|
enable-cache: false
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist
|
|
|
|
- name: Publish to PyPI
|
|
env:
|
|
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
run: |
|
|
failed=0
|
|
for package in dist/*; do
|
|
if [[ "$package" == *"crewai_devtools"* ]]; then
|
|
echo "Skipping private package: $package"
|
|
continue
|
|
fi
|
|
echo "Publishing $package"
|
|
if ! uv publish "$package"; then
|
|
echo "Failed to publish $package"
|
|
failed=1
|
|
fi
|
|
done
|
|
if [ $failed -eq 1 ]; then
|
|
echo "Some packages failed to publish"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Extract version and release notes
|
|
if: success()
|
|
id: release-info
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
version=$(uv run python -c "import tomllib; print(tomllib.load(open('lib/crewai/pyproject.toml','rb'))['project']['version'])")
|
|
echo "version=$version" >> $GITHUB_OUTPUT
|
|
|
|
tag="${{ inputs.release_tag }}"
|
|
if [ -z "$tag" ]; then
|
|
tag="$version"
|
|
fi
|
|
|
|
# Fetch release body and convert GitHub markdown to Slack mrkdwn
|
|
notes=$(gh release view "$tag" --json body -q '.body' 2>/dev/null || echo "")
|
|
if [ -n "$notes" ]; then
|
|
notes=$(echo "$notes" \
|
|
| sed 's/^### \(.*\)/*\1*/g' \
|
|
| sed 's/^## \(.*\)/*\1*/g' \
|
|
| sed 's/\*\*\([^*]*\)\*\*/*\1*/g' \
|
|
| sed 's/^- /• /g')
|
|
fi
|
|
|
|
{
|
|
echo "notes<<SLACKEOF"
|
|
echo "$notes"
|
|
echo "SLACKEOF"
|
|
} >> $GITHUB_OUTPUT
|
|
|
|
- name: Notify Slack
|
|
if: success()
|
|
uses: slackapi/slack-github-action@v2.1.0
|
|
with:
|
|
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
webhook-type: incoming-webhook
|
|
payload: |
|
|
text: ":rocket: *crewAI v${{ steps.release-info.outputs.version }}* published to <https://pypi.org/project/crewai/${{ steps.release-info.outputs.version }}/|PyPI>\n\n${{ steps.release-info.outputs.notes }}"
|