V0.8.7 (#46) #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- 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 |