-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (45 loc) · 1.89 KB
/
python-client-pkg.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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.2.0
- name: Check if package version exists on PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
package_version=$(python3 setup.py --version)
curl -sSL https://pypi.org/pypi/my_package_name/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