-
Notifications
You must be signed in to change notification settings - Fork 3
50 lines (41 loc) · 1.2 KB
/
pythonpublish.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
name: Upload Python Package
on:
push:
branches: [ main ]
pull_request:
types:
- opened
env:
PACKAGE_NAME: crawlab-ai
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install -r requirements.txt
- name: Check version
run: |
version=$(python setup.py --version)
http_status=$(curl -o /dev/null -s -w "%{http_code}\n" https://pypi.org/project/${{ env.PACKAGE_NAME }}/${version}/)
if [[ "$http_status" == "404" ]]; then
echo "is_matched=1" >> $GITHUB_ENV
else
echo "is_matched=0" >> $GITHUB_ENV
fi
- name: Build and publish
if: ${{ env.is_matched == '1' }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
pip install twine
twine upload dist/*