-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (33 loc) · 1.23 KB
/
buildandpublish.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
name: Build and Publish
on:
push:
branches:
- main
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry requests packaging
- name: Check and Publish to PyPI
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
CURRENT_VERSION=$(poetry version -s)
PACKAGE_NAME="ctdfjorder"
PYPI_URL="https://pypi.org/pypi/${PACKAGE_NAME}/json"
EXISTING_VERSION=$(curl -s $PYPI_URL | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
if [ "$(python -c "from packaging.version import parse; print(parse('$CURRENT_VERSION') > parse('$EXISTING_VERSION'))")" == "True" ]; then
poetry config pypi-token.pypi "$PYPI_API_TOKEN"
poetry publish --build
else
echo "Current version ($CURRENT_VERSION) is not greater than existing version ($EXISTING_VERSION). Skipping publish."
fi