1+ name : Publish Python distribution to PyPI
2+
3+ on :
4+ push :
5+ tags :
6+ - ' *'
7+
8+ jobs :
9+ build :
10+ name : Build distribution
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - uses : actions/checkout@v4
15+ - name : Set up Python
16+ uses : actions/setup-python@v5
17+ with :
18+ python-version : " 3.x"
19+
20+ - name : Check version consistency
21+ run : |
22+ # Extract version from pyproject.toml
23+ PYPROJECT_VERSION=$(grep 'version = ' pyproject.toml | head -1 | cut -d'"' -f2)
24+
25+ # Extract version from __init__.py
26+ INIT_VERSION=$(grep '__version__ = ' llmsql/__init__.py | head -1 | cut -d'"' -f2)
27+
28+ echo "Version in pyproject.toml: $PYPROJECT_VERSION"
29+ echo "Version in __init__.py: $INIT_VERSION"
30+
31+ # Check if versions match
32+ if [ "$PYPROJECT_VERSION" != "$INIT_VERSION" ]; then
33+ echo "Error: Version mismatch between pyproject.toml ($PYPROJECT_VERSION) and __init__.py ($INIT_VERSION)"
34+ exit 1
35+ fi
36+
37+ echo "Version check passed: $PYPROJECT_VERSION"
38+
39+ - name : Install pypa/build
40+ run : >-
41+ python3 -m
42+ pip install
43+ build
44+ --user
45+ - name : Build a binary wheel and a source tarball
46+ run : python3 -m build
47+ - name : Store the distribution packages
48+ uses : actions/upload-artifact@v4
49+ with :
50+ name : python-package-distributions
51+ path : dist/
52+
53+ publish-to-pypi :
54+ name : >-
55+ Publish Python distribution to PyPI
56+ if : startsWith(github.ref, 'refs/tags/')
57+ needs :
58+ - build
59+ runs-on : ubuntu-latest
60+ environment :
61+ name : pypi
62+ url : https://pypi.org/p/llmsql
63+ permissions :
64+ id-token : write
65+
66+ steps :
67+ - name : Download all the dists
68+ uses : actions/download-artifact@v4
69+ with :
70+ name : python-package-distributions
71+ path : dist/
72+ - name : Publish distribution to PyPI
73+ uses : pypa/gh-action-pypi-publish@release/v1
74+
75+ publish-to-testpypi :
76+ name : Publish Python distribution to TestPyPI
77+ needs :
78+ - build
79+ runs-on : ubuntu-latest
80+
81+ environment :
82+ name : testpypi
83+ url : https://test.pypi.org/p/llmsql
84+
85+ permissions :
86+ id-token : write
87+
88+ steps :
89+ - name : Download all the dists
90+ uses : actions/download-artifact@v4
91+ with :
92+ name : python-package-distributions
93+ path : dist/
94+ - name : Publish distribution to TestPyPI
95+ uses : pypa/gh-action-pypi-publish@release/v1
96+ with :
97+ repository-url : https://test.pypi.org/legacy/
0 commit comments