Update config.yml

This commit is contained in:
Ishaan Jaff 2023-08-01 15:44:09 -07:00 committed by GitHub
parent 9d6cfbf602
commit bccf9950c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,8 +6,6 @@ jobs:
working_directory: ~/project working_directory: ~/project
steps: steps:
- checkout
# Install dependencies from requirements.txt # Install dependencies from requirements.txt
- run: - run:
name: Install Dependencies name: Install Dependencies
@ -34,36 +32,33 @@ jobs:
PYPI_API_TOKEN: $PYPI_API_TOKEN # Use the environment variable in the job PYPI_API_TOKEN: $PYPI_API_TOKEN # Use the environment variable in the job
steps: steps:
- checkout # Check if setup.py is modified and publish to PyPI
# Publish to PyPI using the environment variable
- run: - run:
name: Publish to PyPI name: Check setup.py modification
command: | command: |
echo "Creating a PyPI token file..." if [ -n "$(git diff --name-only $CIRCLE_SHA1^..$CIRCLE_SHA1 | grep 'setup.py')" ]; then
echo -e "[pypi]\nusername = __token__\npassword = $PYPI_API_TOKEN" > ~/.pypirc echo "Creating a PyPI token file..."
python setup.py sdist echo -e "[pypi]\nusername = __token__\npassword = $PYPI_API_TOKEN" > ~/.pypirc
python -m pip install --upgrade twine python setup.py sdist
twine upload dist/* python -m pip install --upgrade twine
twine upload dist/*
else
echo "No changes to setup.py. Skipping PyPI publish."
circleci step halt
fi
workflows: workflows:
version: 2 version: 2
build_and_test: build_and_test:
jobs: jobs:
- local_testing - local_testing:
filters:
branches:
ignore:
- main
- publish_to_pypi: - publish_to_pypi:
filters: filters:
branches: branches:
only: only:
- main - main
steps:
# Check if setup.py is modified and publish to PyPI
- run:
name: Check setup.py modification
command: |
if [ -n "$(git diff --name-only $CIRCLE_SHA1^..$CIRCLE_SHA1 | grep 'setup.py')" ]; then
echo "Publishing to PyPI..."
else
echo "No changes to setup.py. Skipping PyPI publish."
circleci step halt
fi