1- name : Build KeplerGL Python and NPM Packages
1+ name : Build and Publish KeplerGL Python Package
22
3- on : push
3+ on :
4+ push :
5+ workflow_dispatch :
6+ inputs :
7+ prerelease :
8+ description : ' Publish as prerelease (uncheck for official release)'
9+ required : false
10+ type : boolean
11+ default : true
412
513jobs :
614 build_and_publish :
@@ -11,76 +19,81 @@ jobs:
1119 steps :
1220 - uses : actions/checkout@v4
1321
14- # use Volta to manage yarn/node versions
15- - uses : volta-cli/action @v4
22+ - name : Install uv
23+ uses : astral-sh/setup-uv @v4
1624
17- - name : Set up Python 3.9
18- uses : actions/setup-python@v2
25+ - name : Set up Python 3.11
26+ run : uv python install 3.11
27+
28+ - name : Setup Node.js
29+ uses : actions/setup-node@v4
1930 with :
20- python -version : 3.9
31+ node -version : ' 20 '
2132
22- - name : Install dependencies
23- run : |
24- python -m pip install --upgrade pip
25- pip install twine virtualenv
33+ - name : Install Python dependencies
34+ working-directory : bindings/python
35+ run : uv sync --dev
2636
27- - name : Build KeplerGL
37+ - name : Install npm dependencies
38+ working-directory : bindings/python
39+ run : npm ci
40+
41+ - name : Build TypeScript
42+ working-directory : bindings/python
2843 env :
2944 MapboxAccessTokenJupyter : ${{ secrets.mapbox_jupyter_token }}
30- NODE_OPTIONS : --openssl-legacy-provider
31- run : |
32- python -m virtualenv venv
33- source venv/bin/activate
34- pip install jupyter jupyterlab jupyter-packaging
35- cd bindings/kepler.gl-jupyter
36- python setup.py sdist
45+ run : npm run build
46+
47+ - name : Type check
48+ working-directory : bindings/python
49+ run : npm run typecheck
50+
51+ - name : Build Python package
52+ working-directory : bindings/python
53+ run : uv build
3754
3855 - name : Test KeplerGL
56+ working-directory : bindings/python
3957 run : |
40- source venv/bin/activate
41- pip install bindings/kepler.gl-jupyter/dist/*.tar.gz
42- if [ ! -f "venv/share/jupyter/nbextensions/keplergl-jupyter/index.js" ]; then
43- venv/bin/jupyter nbextension install --py --sys-prefix keplergl
44- venv/bin/jupyter nbextension enable --py --sys-prefix keplergl
45- fi
46- venv/bin/jupyter nbconvert --execute bindings/kepler.gl-jupyter/notebooks/DataFrame.ipynb --to python
47- python bindings/kepler.gl-jupyter/notebooks/DataFrame.py
58+ uv pip install dist/*.whl
59+ uv run pytest
4860
4961 - name : Create artifact
5062 uses : actions/upload-artifact@v4
5163 with :
5264 name : keplergl-pypi
53- path : bindings/kepler.gl-jupyter /dist/
65+ path : bindings/python /dist/
5466
55- - name : Check Release Tag
56- id : check-tag
67+ - name : Check version format
68+ if : github.event_name == 'workflow_dispatch'
69+ working-directory : bindings/python
5770 run : |
58- if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+([a|b][0-9])?-jupyter$ ]]; then
59- echo ::set-output name=publish::true
71+ VERSION=$(grep -Po '(?<=^version = ")[^"]+' pyproject.toml)
72+ echo "Package version: $VERSION"
73+
74+ # Check if version contains prerelease indicators (a, b, rc, dev)
75+ if [[ "$VERSION" =~ (a|b|rc|dev)[0-9]+ ]]; then
76+ IS_PRERELEASE_VERSION=true
77+ else
78+ IS_PRERELEASE_VERSION=false
79+ fi
80+
81+ echo "Is prerelease version: $IS_PRERELEASE_VERSION"
82+ echo "Publishing as prerelease: ${{ inputs.prerelease }}"
83+
84+ # Fail if mismatch between version format and publish type
85+ if [[ "${{ inputs.prerelease }}" == "true" && "$IS_PRERELEASE_VERSION" == "false" ]]; then
86+ echo "::error::Publishing as prerelease but version '$VERSION' does not have a prerelease suffix (e.g., 0.4.0a1, 0.4.0b1, 0.4.0rc1)"
87+ exit 1
88+ fi
89+
90+ if [[ "${{ inputs.prerelease }}" == "false" && "$IS_PRERELEASE_VERSION" == "true" ]]; then
91+ echo "::error::Cannot publish official release with prerelease version '$VERSION'. Please update the version in pyproject.toml."
92+ exit 1
6093 fi
6194
62- - name : Setup Node.js
63- uses : actions/setup-node@v3
64- with :
65- node-version : ' 18'
66- registry-url : ' https://registry.npmjs.org'
67-
68- - name : Publish kepler-jupyter to NPM
69- if : steps.check-tag.outputs.publish == 'true'
70- env :
71- NODE_AUTH_TOKEN : ${{secrets.npm_token}}
72- MapboxAccessTokenJupyter : ${{ secrets.mapbox_jupyter_token }}
73- run : |
74- source venv/bin/activate
75- cd bindings/kepler.gl-jupyter/js
76- echo "//registry.npmjs.org/:_authToken=${{ secrets.npm_token }}" > .npmrc
77- npm config set registry https://registry.npmjs.org/
78- npm whoami
79- npm config ls
80- npm publish --verbose --access public
81-
82- - name : Publish KeplerGL to Pypi
83- if : steps.check-tag.outputs.publish == 'true'
95+ - name : Publish to PyPI
96+ if : github.event_name == 'workflow_dispatch'
8497 uses : pypa/gh-action-pypi-publish@release/v1
8598 with :
86- packages-dir : bindings/kepler.gl-jupyter /dist/
99+ packages-dir : bindings/python /dist/
0 commit comments