-
Notifications
You must be signed in to change notification settings - Fork 7
52 lines (43 loc) · 1.41 KB
/
python-publish.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
name: Publish to PyPI
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build requests
- name: Check if version changed
id: check-version
run: |
set -x
CURRENT_VERSION=$(grep -Eo "version=\"[0-9]+\.[0-9]+\.[0-9]+\"" setup.py | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
echo "current_version=$CURRENT_VERSION" >> $GITHUB_ENV
LATEST_VERSION=$(python -c "import requests; print(requests.get('https://pypi.org/pypi/tastytrade-api/json').json()['info']['version'])")
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "Publishing new version $CURRENT_VERSION"
echo "VERSION_CHANGED=true" >> $GITHUB_ENV
else
echo "Version $CURRENT_VERSION already published"
echo "VERSION_CHANGED=false" >> $GITHUB_ENV
fi
- name: Build distribution
if: env.VERSION_CHANGED == 'true'
run: |
python -m build
- name: Publish to PyPI
if: env.VERSION_CHANGED == 'true'
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}