在创建tag,并把它推送到GitHub后,GitHub Actions自动构建,然后将python包发布到pypi。
在此之前,我是使用以下代码来实现的
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
但无论怎么构建,它直接显示找不到setup.py,但我的setup.py就在文件夹里面。
ERROR Source /home/runner/work/EasyGitTool/EasyGitTool does not appear to be a Python project: no pyproject.toml or setup.py
将之前我输入的那部分改成如下内容
- 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/*
结果,当我再次触发GitHub Actions,使其运行后,它构建成功了,并把发布python包到Pypi中。
感谢weixin_39855944的文章《github安装python包_使用github action发布python包到Pypi_weixin_39855944的博客-CSDN博客》让我找到了解决的方法