-
Notifications
You must be signed in to change notification settings - Fork 13
47 lines (42 loc) · 1.47 KB
/
deploy_pypi.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
name: Deploy to PyPI
# Deploy to PyPI if the __version__ variable in himalaya/__init__.py
# is larger than the latest version on PyPI.
on:
push:
branches:
- main
paths:
# trigger workflow only on commits that change __init__.py
- 'himalaya/__init__.py'
jobs:
deploy-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Get versions
# Compare the latest version on PyPI, and the current version
run: |
python -m pip install --upgrade -q pip
pip index versions himalaya
LATEST=$(pip index versions himalaya | grep 'himalaya' |awk '{print $2}' | tr -d '(' | tr -d ')')
CURRENT=$(cat himalaya/__init__.py | grep "__version__" | awk '{print $3}' | tr -d "'" | tr -d '"')
EQUAL=$([ "$CURRENT" = "$LATEST" ] && echo 1 || echo 0)
echo "LATEST=$LATEST" >> $GITHUB_ENV
echo "CURRENT=$CURRENT" >> $GITHUB_ENV
echo "EQUAL=$EQUAL" >> $GITHUB_ENV
- name: Print versions
run: |
echo ${{ env.LATEST }}
echo ${{ env.CURRENT }}
echo ${{ env.EQUAL }}
- name: Build and publish
if: ${{ env.EQUAL == 0 }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine
python setup.py sdist bdist_wheel
python -m twine upload dist/*