Merge pull request #34 from ProdByGodfather/33-issue-github-actions-w… #4
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: Publish to PyPI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout the repository | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
# Set up Python environment | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
# Install dependencies for building and publishing | ||
- name: Install build tools | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build twine | ||
# Extract version from setup.py | ||
- name: Extract version from setup.py | ||
id: extract_version | ||
run: | | ||
version=$(python setup.py --version) | ||
echo "VERSION=$version" >> $GITHUB_ENV | ||
# Log the extracted version | ||
- name: Show extracted version | ||
run: echo "Extracted Version: ${{ env.VERSION }}" | ||
# Build the package | ||
- name: Build the package | ||
run: python -m build | ||
# Publish to PyPI | ||
- name: Publish to PyPI | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: twine upload dist/* |