I'm trying to get some CI/CD experience with GitHub Actions to put on my resume so I tried to automate the publication/release process of my python package to the PyPI website. But so far the build fails because it doesn't detect that I have python 3.9 installed, for some reason.
My GitHub Actions workflow looks like this:
name: Publish Python Package to PYPI
on:
release:
types: [published]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9.0'
- 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: Publish package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PYPALEX_API_TOKEN }}
run: twine upload dist/*
It's supposed to trigger upon release creation and the commands used to build the package are exactly the same as the commands I use to manually build the package: python setup.py sdist bdist_wheel
I've tried to create a release several times but the workflow fails each and every time during the Build package
phase. If it'll help, here's the fail log:
My package has a requirement that python 3.7 or greater be installed, and python 3.9 is installed in the workflow, but it doesn't seem to recognize that.
I've tried googling this problem for several hours before coming here, and as far as I can tell it's either the fault of the runs-on
step or the actions/checkout
and actions/setup-python
steps. I read last night that python 3.9 isn't available for ubuntu-latest
, so I have tried several other options for the runs-on
step already. And I've tried using actions/checkout@v3 | actions/setup-python@v3
and actions/checkout@v2 | actions/setup-python@v2
with no luck, same result. I am really new to this so I don't know if there's a certain way I can google this myself to get the answer, please go easy on me.
I can't tell if this is because of the version of ubuntu I'm using or if it's because of the checkout and setup-python steps. Does anyone who's more experienced in writing these workflows know how to solve this? Please?