Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
yml 113 lines 3.35 KB
Raw
1 name: Release Python Packages
2 on:
3 push:
4 tags:
5 - 'py@*'
6 workflow_dispatch:
7 inputs:
8 skip_tests:
9 description: 'Skip running tests'
10 required: false
11 type: boolean
12 default: false
13
14 permissions:
15 contents: read
16
17 jobs:
18 build:
19 name: Build SDK packages
20 outputs:
21 core_only: ${{ steps.release_mode.outputs.core_only }}
22 defaults:
23 run:
24 working-directory: ./python
25 runs-on: ubuntu-latest
26 steps:
27 - name: Checkout Code
28 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
29
30 - name: Setup Node.js, pnpm, Bun
31 uses: ./.github/actions/setup-node-pnpm-bun
32
33 - name: Install release metadata check dependencies
34 working-directory: .
35 run: pnpm install --frozen-lockfile
36
37 - name: Validate Python release metadata
38 working-directory: .
39 run: pnpm test:release-workflow
40
41 - name: Setup Python with UV
42 uses: ./.github/actions/setup-python-uv
43 with:
44 cache-dependency-glob: |
45 uv.lock
46 pyproject.toml
47 mise.lock
48 python/pyproject.toml
49
50 - name: Resolve release package set
51 id: release_mode
52 run: |
53 python - <<'PY' >> "$GITHUB_OUTPUT"
54 import re
55 import tomllib
56
57 with open("pyproject.toml", "rb") as pyproject:
58 version = tomllib.load(pyproject)["project"]["version"]
59
60 # PEP 440 compact form (0.23.1rc1) and the separator form emitted by
61 # python/scripts/bump.py --pre (0.23.1-rc.1) are both prereleases.
62 is_prerelease = re.search(r"(?:a|b|rc|dev)[-_.]?\d", version, re.IGNORECASE) is not None
63 print(f"core_only={'true' if is_prerelease else 'false'}")
64 PY
65
66 # Install only the locked build tools. `--locked` fails if uv.lock is
67 # stale instead of resolving fresh versions from PyPI.
68 - name: Install locked build tools
69 env:
70 UV_PROJECT_ENVIRONMENT: python/.venv
71 run: uv sync --locked --only-group release
72
73 - name: Build Artifacts
74 env:
75 BUILD_ARGS: --no-isolation
76 run: |
77 if [[ "${{ steps.release_mode.outputs.core_only }}" == "true" ]]; then
78 make build-core
79 else
80 make build
81 fi
82
83 - name: Upload distributions
84 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
85 with:
86 name: python-dist
87 path: python/dist/
88 if-no-files-found: error
89
90 # Publishing runs in its own job so the OIDC token is never available to the
91 # build steps. PyPI trusts this workflow and environment through trusted
92 # publishing, so no long-lived PyPI token is needed.
93 publish:
94 name: Publish to PyPI
95 needs: build
96 if: github.event_name == 'push' && needs.build.outputs.core_only == 'true'
97 runs-on: ubuntu-latest
98 environment:
99 name: pypi
100 permissions:
101 id-token: write
102 steps:
103 - name: Download distributions
104 uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
105 with:
106 name: python-dist
107 path: dist/
108
109 - name: Publish Artifacts
110 uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
111 with:
112 packages-dir: dist/
113 skip-existing: true