1+ name : Publish Python SDK
2+
3+ on :
4+ push :
5+ branches : [main]
6+ paths :
7+ - ' packages/python-sdk/**'
8+
9+ jobs :
10+ publish-pypi :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+
16+ - name : Setup Python
17+ uses : actions/setup-python@v5
18+ with :
19+ python-version : ' 3.12'
20+ cache : ' pip'
21+
22+ - name : Install build dependencies
23+ run : |
24+ python -m pip install --upgrade pip
25+ pip install build twine pytest requests tomli
26+
27+ - name : Run tests
28+ working-directory : packages/python-sdk
29+ run : |
30+ PYTHONPATH=. pytest tests/ -v
31+
32+ - name : Get package version
33+ id : package_version
34+ working-directory : packages/python-sdk
35+ run : echo "version=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])")" >> $GITHUB_OUTPUT
36+
37+ - name : Check if version already exists
38+ id : version_check
39+ run : |
40+ if pip index versions simstudio-sdk | grep -q "${{ steps.package_version.outputs.version }}"; then
41+ echo "exists=true" >> $GITHUB_OUTPUT
42+ else
43+ echo "exists=false" >> $GITHUB_OUTPUT
44+ fi
45+
46+ - name : Build package
47+ if : steps.version_check.outputs.exists == 'false'
48+ working-directory : packages/python-sdk
49+ run : python -m build
50+
51+ - name : Check package
52+ if : steps.version_check.outputs.exists == 'false'
53+ working-directory : packages/python-sdk
54+ run : twine check dist/*
55+
56+ - name : Publish to PyPI
57+ if : steps.version_check.outputs.exists == 'false'
58+ working-directory : packages/python-sdk
59+ env :
60+ TWINE_USERNAME : __token__
61+ TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
62+ run : twine upload dist/*
63+
64+ - name : Log skipped publish
65+ if : steps.version_check.outputs.exists == 'true'
66+ run : echo "Skipped publishing because version ${{ steps.package_version.outputs.version }} already exists on PyPI"
67+
68+ - name : Create GitHub Release
69+ if : steps.version_check.outputs.exists == 'false'
70+ uses : softprops/action-gh-release@v1
71+ env :
72+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73+ with :
74+ tag_name : python-sdk-v${{ steps.package_version.outputs.version }}
75+ name : Python SDK v${{ steps.package_version.outputs.version }}
76+ body : |
77+ ## Python SDK v${{ steps.package_version.outputs.version }}
78+
79+ Published simstudio-sdk==${{ steps.package_version.outputs.version }} to PyPI.
80+
81+ ### Installation
82+ ```bash
83+ pip install simstudio-sdk==${{ steps.package_version.outputs.version }}
84+ ```
85+
86+ ### Documentation
87+ See the [README](https://github.com/simstudio/sim/tree/main/packages/python-sdk) for usage instructions.
88+ draft : false
89+ prerelease : false
0 commit comments