pypa / gh-action-pypi-publish

The blessed :octocat: GitHub Action, for publishing your :package: distribution files to PyPI: https://github.com/marketplace/actions/pypi-publish
https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
BSD 3-Clause "New" or "Revised" License
920 stars 85 forks source link

[traceback] zipfile.BadZipFile: File is not a zip file #148

Open daisseur opened 1 year ago

daisseur commented 1 year ago

I'm on a python project and i use github action to publish my pypi python package the python project is https://github.com/daisseur/Deltacode_project/ when the package is publishing i got this error:

Traceback (most recent call last):
  File "/usr/local/bin/twine", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/twine/__main__.py", line 33, in main
    error = cli.dispatch(sys.argv[1:])
  File "/usr/local/lib/python3.9/site-packages/twine/cli.py", line 123, in dispatch
    return main(args.args)
  File "/usr/local/lib/python3.9/site-packages/twine/commands/check.py", line 183, in main
    return check(parsed_args.dists, strict=parsed_args.strict)
  File "/usr/local/lib/python3.9/site-packages/twine/commands/check.py", line 129, in check
    warnings, is_ok = _check_file(filename, render_warning_stream)
  File "/usr/local/lib/python3.9/site-packages/twine/commands/check.py", line 73, in _check_file
    package = package_file.PackageFile.from_filename(filename, comment=None)
  File "/usr/local/lib/python3.9/site-packages/twine/package.py", line 96, in from_filename
    meta = DIST_TYPES[dtype](filename)
  File "/usr/local/lib/python3.9/site-packages/twine/wininst.py", line [17](https://github.com/daisseur/Deltacode_project/actions/runs/4769442414/jobs/8479836531#step:7:18), in __init__
    self.extractMetadata()
  File "/usr/local/lib/python3.9/site-packages/pkginfo/distribution.py", line 1[23](https://github.com/daisseur/Deltacode_project/actions/runs/4769442414/jobs/8479836531#step:7:24), in extractMetadata
    data = self.read()
  File "/usr/local/lib/python3.9/site-packages/twine/wininst.py", line 33, in read
    archive = zipfile.ZipFile(fqn)
  File "/usr/local/lib/python3.9/zipfile.py", line 1[26](https://github.com/daisseur/Deltacode_project/actions/runs/4769442414/jobs/8479836531#step:7:27)6, in __init__
    self._RealGetContents()
  File "/usr/local/lib/python3.9/zipfile.py", line 1[33](https://github.com/daisseur/Deltacode_project/actions/runs/4769442414/jobs/8479836531#step:7:34)3, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Checking dist/DeltacodeProject.exe:
webknjaz commented 1 year ago

Remove dist/DeltacodeProject.exe. It can't be published.

daisseur commented 1 year ago

Remove dist/DeltacodeProject.exe. It can't be published.

Okay thank you but how can I remove it from the github action whithout remove the exe from the repo

webknjaz commented 1 year ago

@daisseur firstly, committing binaries to Git repositories is a bad idea. Second, if that's an artifact, it should probably be built within a GHA workflow. Finally, even if you put it into the directory on disk, you can still delete it in GHA via rm -f dist/*.exe or use a different directory for producing/supplying dists. You don't even need a repository checkout for the publishing job — build whatever you're publishing in one job (or many jobs, for that matter), store it as an artifact, get the artifact within the publishing job and make sure you don't add undesired files into that folder.

daisseur commented 1 year ago

@webknjaz okay thank you

webknjaz commented 11 months ago

Action item:

ShukantPal commented 9 months ago

We're trying to publish with .whl files and we're seeing this issue publishing pyktx:

https://github.com/KhronosGroup/KTX-Software/actions/runs/7498674379/job/20414169920

There is also a .tar.gz source distribution in the directory. I wonder how the wheels are supposed to be published?

MarkCallow commented 9 months ago

We're trying to publish with .whl files and we're seeing this issue publishing pyktx:

This was due to curl command used to download the assets in our GitHub Action not enabling redirects resulting in zero-byte .whl files. Sorry for the false alarm.