Skip to content

Commit a0d09f1

Browse files
committed
ci: Add PyPI publish workflow + build script for Python SDK
- .github/workflows/pypi-publish.yml: GitHub Actions workflow to publish to PyPI - Publishes on release (automatic) - Manual dispatch for test/prod - Test package installation verification - python/build_verify.sh: Local build script Requires secrets (not yet configured): - PYPI_TOKEN: PyPI API token (pypi.org) - PYPI_TEST_TOKEN: Test PyPI token (test.pypi.org)
1 parent ee77379 commit a0d09f1

2 files changed

Lines changed: 134 additions & 0 deletions

File tree

‎.github/workflows/pypi-publish.yml‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Publish Python SDK to PyPI
2+
3+
on:
4+
release:
5+
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
environment:
9+
description: 'Environment'
10+
required: true
11+
default: 'test'
12+
type: choice
13+
options:
14+
- test
15+
- prod
16+
17+
jobs:
18+
publish-testpypi:
19+
if: github.event.inputs.environment == 'test' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'test')
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: testpypi
23+
url: https://test.pypi.org/projects/a3m-router
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.11'
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install build twine
36+
37+
- name: Build package
38+
run: |
39+
cd python
40+
python -m build
41+
42+
- name: Publish to Test PyPI
43+
env:
44+
TWINE_USERNAME: __token__
45+
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
46+
run: |
47+
cd python
48+
python -m twine upload --repository testpypi dist/*
49+
50+
publish-pypi:
51+
if: github.event.inputs.environment == 'prod' || github.event_name == 'release'
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: pypi
55+
url: https://pypi.org/projects/a3m-router
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: '3.11'
64+
65+
- name: Install dependencies
66+
run: |
67+
python -m pip install build twine
68+
69+
- name: Build package
70+
run: |
71+
cd python
72+
python -m build
73+
74+
- name: Publish to PyPI
75+
env:
76+
TWINE_USERNAME: __token__
77+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
78+
run: |
79+
cd python
80+
python -m twine upload dist/*
81+
82+
test-package:
83+
runs-on: ubuntu-latest
84+
needs: publish-testpypi
85+
86+
steps:
87+
- uses: actions/checkout@v4
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@v5
91+
with:
92+
python-version: '3.11'
93+
94+
- name: Install from Test PyPI
95+
env:
96+
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
97+
run: |
98+
pip install --index-url https://test.pypi.org/simple/ a3m-router
99+
100+
- name: Test import
101+
run: |
102+
python -c "from a3m import A3MRouter, __version__; print(f'A3M Router SDK v{__version__} installed successfully!')"

‎python/build_verify.sh‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Build and verify Python SDK
3+
set -e
4+
5+
echo "=== Building A3M Router Python SDK v2.2.0 ==="
6+
cd "$(dirname "$0")"
7+
8+
echo "1. Installing build dependencies..."
9+
pip install build twine 2>/dev/null || pip3 install build twine
10+
11+
echo "2. Cleaning old builds..."
12+
rm -rf dist/ build/ *.egg-info
13+
14+
echo "3. Building package..."
15+
python -m build
16+
17+
echo "4. Checking package..."
18+
python -m twine check dist/*
19+
20+
echo "5. Listing built files..."
21+
ls -lh dist/
22+
23+
echo ""
24+
echo "=== Build complete! ==="
25+
echo "To publish to Test PyPI:"
26+
echo " cd python && python -m twine upload --repository testpypi dist/*"
27+
echo ""
28+
echo "To publish to PyPI:"
29+
echo " cd python && python -m twine upload dist/*"
30+
echo ""
31+
echo "To install locally:"
32+
echo " pip install dist/a3m_router-*.whl"

0 commit comments

Comments
 (0)