Skip to content

add citation file

add citation file #4

name: Publish Library to PyPI
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Check package version
run: |
PACKAGE_NAME=$(python setup.py --name)
PACKAGE_VERSION=$(python setup.py --version)
RESPONSE=$(curl --silent --fail https://pypi.org/pypi/${PACKAGE_NAME}/json || echo "not found")
if echo "$RESPONSE" | grep -q '"releases"'; then
if echo "$RESPONSE" | jq -e ".releases | has(\"$PACKAGE_VERSION\")" >/dev/null; then
echo "Version ${PACKAGE_VERSION} already exists on PyPI."
echo "already_published=true" >> $GITHUB_ENV
else
echo "Version ${PACKAGE_VERSION} does not exist on PyPI."
echo "already_published=false" >> $GITHUB_ENV
fi
else
echo "Package does not exist on PyPI."
echo "already_published=false" >> $GITHUB_ENV
fi
- name: Publish package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
if: env.already_published == 'false'
run: |
python -m twine upload dist/*
- name: Clean up
run: |
rm -rf build dist *.egg-info