Skip to content

Commit 1dbb193

Browse files
committed
add pypi publish in action
1 parent 021d57c commit 1dbb193

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,50 @@ jobs:
5959
name: ${{ matrix.python-version }}
6060
fail_ci_if_error: false
6161

62+
publish:
63+
needs: [tests]
64+
runs-on: ubuntu-latest
65+
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
66+
steps:
67+
- uses: actions/checkout@v4
68+
- name: Set up Python
69+
uses: actions/setup-python@v5
70+
with:
71+
python-version: ${{ env.LATEST_PY_VERSION }}
72+
73+
- name: Install dependencies
74+
run: |
75+
python -m pip install --upgrade pip
76+
python -m pip install wheel twine build
77+
python -m pip install .
78+
79+
- name: Set tag version
80+
id: tag
81+
run: |
82+
echo "version=${GITHUB_REF#refs/*/}"
83+
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
84+
85+
- name: Set module version
86+
id: module
87+
run: |
88+
echo version=$(python -c'import titiler.stacapi; print(titiler.stacapi.__version__)') >> $GITHUB_OUTPUT
89+
90+
- name: Build and publish
91+
if: ${{ steps.tag.outputs.version }} == ${{ steps.module.outputs.version}}
92+
env:
93+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
94+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
95+
run: |
96+
rm -rf dist
97+
python -m build
98+
twine upload dist/*
6299
63100
publish-docker:
64101
needs: [tests]
65102
# runs on push to main, on tag creation, and on release
66103
if: github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
67104
runs-on: ubuntu-latest
68-
105+
69106
steps:
70107
- name: Checkout
71108
uses: actions/checkout@v4
@@ -110,4 +147,4 @@ jobs:
110147
file: dockerfiles/Dockerfile
111148
push: true
112149
tags: |
113-
ghcr.io/developmentseed/titiler-stacapi:${{ steps.tag.outputs.version }}
150+
ghcr.io/developmentseed/titiler-stacapi:${{ steps.tag.outputs.version }}

0 commit comments

Comments
 (0)