Update setup.py version to 0.0.94 #21
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: Upload Python Package | |
on: | |
push: | |
branches: | |
- master # assuming you want to trigger on pushes to the master branch | |
jobs: | |
check_version_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build requests | |
pip install setuptools | |
- name: Check if version has changed | |
id: check_version | |
run: | | |
# Extract version number from setup.py | |
CURRENT_VERSION=$(python setup.py --version) | |
echo "Current Version: $CURRENT_VERSION" | |
# Get the latest version from PyPI | |
LATEST_VERSION=$(python -c "import requests; response = requests.get('https://pypi.org/pypi/azubiheftApi/json'); data = response.json(); print(data['info']['version'])") | |
echo "Latest Version on PyPI: $LATEST_VERSION" | |
# Compare the two versions | |
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | |
echo "Version has changed! Proceeding with publishing..." | |
echo "VERSION_CHANGED=true" >> $GITHUB_ENV | |
else | |
echo "Version has not changed. Skipping publishing." | |
echo "VERSION_CHANGED=false" >> $GITHUB_ENV | |
fi | |
- name: Build package | |
if: env.VERSION_CHANGED == 'true' | |
run: python -m build | |
- name: Publish package | |
if: env.VERSION_CHANGED == 'true' | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |