Closed jamesbraza closed 1 month ago
Doing something like this does not work:
- id: build
uses: hynek/build-and-inspect-python-package@v2
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ steps.build.outputs.dist }}
The gh-action-pypi-publish
fails (CI run):
Traceback (most recent call last):
File "/app/print-pkg-names.py", line 30, in <module>
pkg_name for file_path in packages_dir.iterdir() if
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/pathlib.py", line 1056, in iterdir
for name in os.listdir(self):
^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/baipp/dist'
Warning: Trusted Publishers allows publishing packages to PyPI from automated environments like GitHub Actions without needing to use username/password combinations or API tokens to authenticate with PyPI. Read more: https://docs.pypi.org/trusted-publishers
Warning: It looks like there are no Python distribution packages to publish in the directory '/tmp/baipp/dist/'. Please verify that they are in place should you face this problem.
ERROR InvalidDistribution: Cannot find file (or expand pattern):
'/tmp/baipp/dist/*'
This was what needed to be done btw:
- id: build
uses: hynek/build-and-inspect-python-package@v2
- name: Download built artifact to dist/
uses: actions/download-artifact@v4
with:
name: ${{ steps.build.outputs.artifact-name }}
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
It would be nice to document this if possible
Hmmm, this might be GHA tightening the protection between steps and not allowing actions to access each others /tmp
.
It's a bit extra, but try adding:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
before the publish step.
Ah you figured it out yourself. Another option would've been setting the dist
output:
- id: build
uses: hynek/build-and-inspect-python-package@v2
with:
dist: dist
That might be simpler for your usecase.
Hello @hynek thanks for getting back. I like your suggestion of with: dist: dist
, but is that possible?
From https://github.com/hynek/build-and-inspect-python-package/blob/v2.9.0/action.yml#L9-L25, I don't see dist
being an input argument, unless I am missing something
Yeah sorry, you're right, I misread. I wrote that before 5am my time. ;)
Maybe something like that should be added. Not to make excuses, but I'm confident that the reason for packages-dir: ${{ steps.build.outputs.dist }}
not working is that GHA changed the rules and I pray they don't change it any further.
This will take some testing, but it really should work, I think.
Hi @hynek yes I agree with everything you're saying. Thanks again for making this, we are going to roll this GHA universally for all packages within FutureHouse 🚀
I made a brief docs PR documenting this workflow, feel free to not accept it if you want to do something different
I have a publish GitHub Action that looks like this, using https://github.com/hynek/build-and-inspect-python-package/tree/v2.9.0:
However, this does not work, the
gh-action-pypi-publish
fails due to not finding thedist/
(CI run):Can you add docs on how to pipe the output of
hynek/build-and-inspect-python-package
into a publish step such aspypa/gh-action-pypi-publish
oruv publish
?Alternately, can you add an input to let one specify where to place the built wheel and sdist?