Skip to content

Bumping python package version #14

Bumping python package version

Bumping python package version #14

name: Generate and publish Python client package for COCT SR API
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip
pip3 install twine
- name: Generate Python client package
run: |
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.6.0 generate -i /local/city-sr-api.json \
-g python \
-o /local/dist/python \
--additional-properties=packageName="coct_sr_api_client" \
--additional-properties=packageVersion=0.3.0
- name: Check if package version exists on PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
package_version=$(python3 dist/python/setup.py --version)
curl -sSL https://pypi.org/pypi/coct_sr_api_client/json | grep -q "\"$package_version\"" && exit 1 || exit 0
continue-on-error: true
id: check_package_version
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
if [ ${{ steps.check_package_version.outcome }} == "success" ]; then
sudo chown -R $USER:$USER dist/python
cd dist/python
python3 setup.py sdist bdist_wheel
twine upload dist/*
else
echo "Package version already exists on PyPI, skipping upload"
fi