Skip to content

Revert "fix: workflows edgecases error and bump version" #8

Revert "fix: workflows edgecases error and bump version"

Revert "fix: workflows edgecases error and bump version" #8

Workflow file for this run

name: Publish Python Package
on:
push:
branches:
- main
paths:
- 'setup.py'
pull_request:
branches:
- "main"
paths:
- 'setup.py'
jobs:
check-version-changed:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.version-change.outputs.version_changed }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Check if version changed
id: version-change
run: |
VERSION_CHANGE=$(git diff HEAD^ HEAD -- setup.py | grep -e "^+.*version.*=" -e "^-.*version.*=" | wc -l)
if [ "$VERSION_CHANGE" -eq 0 ]; then
echo "Version not changed"
echo "::set-output name=version_changed::false"
else
echo "Version changed"
echo "::set-output name=version_changed::true"
fi
publish:
needs: check-version-changed
if: needs.check-version-changed.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- 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 and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*