Giter Club home page Giter Club logo

pypa / gh-action-pypi-publish Goto Github PK

View Code? Open in Web Editor NEW
842.0 9.0 79.0 297 KB

The blessed :octocat: GitHub Action, for publishing your :package: distribution files to PyPI: https://github.com/marketplace/actions/pypi-publish

Home Page: https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

License: BSD 3-Clause "New" or "Revised" License

Dockerfile 6.02% Shell 31.04% Python 62.94%
github-action python workflow workflow-automation pypi python-packaging twine secrets upload release

gh-action-pypi-publish's Introduction

SWUbanner

๐Ÿงช GitHub Actions CI/CD workflow tests badge pre-commit.ci status badge

PyPI publish GitHub Action

This action allows you to upload your Python distribution packages in the dist/ directory to PyPI. This text suggests a minimalistic usage overview. For more detailed walkthrough check out the PyPA guide.

If you have any feedback regarding specific action versions, please leave comments in the corresponding per-release announcement discussions.

๐ŸŒ‡ master branch sunset โ—

The master branch version has been sunset. Please, change the GitHub Action version you use from master to release/v1 or use an exact tag, or opt-in to use a full Git commit SHA and Dependabot.

Usage

Trusted publishing

Note

Trusted publishing cannot be used from within a reusable workflow at this time. It is recommended to instead create a non-reusable workflow that contains a job calling your reusable workflow, and then do the trusted publishing step from a separate job within that non-reusable workflow. Alternatively, you can still use a username/token inside the reusable workflow.

Note

Trusted publishing is sometimes referred to by its underlying technology -- OpenID Connect, or OIDC for short. If you see references to "OIDC publishing" in the context of PyPI, this is what they're referring to.

This example jumps right into the current best practice. If you want to use API tokens directly or a less secure username and password, check out how to specify username and password.

This action supports PyPI's trusted publishing implementation, which allows authentication to PyPI without a manually configured API token or username/password combination. To perform trusted publishing with this action, your project's publisher must already be configured on PyPI.

To enter the trusted publishing flow, configure this action's job with the id-token: write permission and without an explicit username or password:

# .github/workflows/ci-cd.yml
jobs:
  pypi-publish:
    name: Upload release to PyPI
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/<your-pypi-project-name>
    permissions:
      id-token: write  # IMPORTANT: this permission is mandatory for trusted publishing
    steps:
    # retrieve your distributions here

    - name: Publish package distributions to PyPI
      uses: pypa/gh-action-pypi-publish@release/v1

Note

Pro tip: instead of using branch pointers, like unstable/v1, pin versions of Actions that you use to tagged versions or sha1 commit identifiers. This will make your workflows more secure and better reproducible, saving you from sudden and unpleasant surprises.

Other indices that support trusted publishing can also be used, like TestPyPI:

- name: Publish package distributions to TestPyPI
  uses: pypa/gh-action-pypi-publish@release/v1
  with:
    repository-url: https://test.pypi.org/legacy/

(don't forget to update the environment name to testpypi or similar!)

Note

Pro tip: only set the id-token: write permission in the job that does publishing, not globally. Also, try to separate building from publishing โ€” this makes sure that any scripts maliciously injected into the build or test environment won't be able to elevate privileges while flying under the radar.

A common use case is to upload packages only on a tagged commit, to do so add a filter to the job:

    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

Non-goals

This GitHub Action has nothing to do with building package distributions. Users are responsible for preparing dists for upload by putting them into the dist/ folder prior to running this Action.

Important

Since this GitHub Action is docker-based, it can only be used from within GNU/Linux based jobs in GitHub Actions CI/CD workflows. This is by design and is unlikely to change due to a number of considerations we rely on.

This should not stop one from publishing platform-specific distribution packages, though. It is strongly advised to separate jobs for building the OS-specific wheels from the publish job. This allows one to (1) test exactly the same artifacts that are about to be uploaded to PyPI, (2) prevent parallel unsynchronized jobs from publishing only part of the dists asynchronously (in case when part of the jobs fail and others succeed ending up with an incomplete release on PyPI) and (3) make an atomic upload to PyPI (when part of the dists appear on PyPI, installers like pip will use that version for the dependency resolution but this may cause some environments to use sdists while the wheel for their runtime is not yet available).

To implement this sort of orchestration, please use actions/upload-artifact and actions/download-artifact actions for sharing the built dists across stages and jobs. Then, use the needs setting to order the build, test and publish stages.

Advanced release management

For best results, figure out what kind of workflow fits your project's specific needs.

For example, you could implement a parallel job that pushes every commit to TestPyPI or your own index server, like devpi. For this, you'd need to (1) specify a custom repository-url value and (2) generate a unique version number for each upload so that they'd not create a conflict. The latter is possible if you use setuptools_scm package but you could also invent your own solution based on the distance to the latest tagged commit.

You'll need to create another token for a separate host and then save it as a GitHub repo secret under an environment used in your job. Though, passing a password would disable the secretless trusted publishing so it's better to configure it instead, when publishing to TestPyPI and not something custom.

The action invocation in this case would look like:

- name: Publish package to TestPyPI
  uses: pypa/gh-action-pypi-publish@release/v1
  with:
    password: ${{ secrets.TEST_PYPI_API_TOKEN }}
    repository-url: https://test.pypi.org/legacy/

Customizing target package dists directory

You can change the default target directory of dist/ to any directory of your liking. The action invocation would now look like:

- name: Publish package to PyPI
  uses: pypa/gh-action-pypi-publish@release/v1
  with:
    packages-dir: custom-dir/

Disabling metadata verification

It is recommended that you run twine check just after producing your files, but this also runs twine check before upload. You can also disable the twine check with:

   with:
     verify-metadata: false

Tolerating release package file duplicates

Sometimes, when you publish releases from multiple places, your workflow may hit race conditions. For example, when publishing from multiple CIs or even having workflows with the same steps triggered within GitHub Actions CI/CD for different events concerning the same high-level act.

To facilitate this use-case, you may use skip-existing (disabled by default) setting as follows:

   with:
     skip-existing: true

Note

Pro tip: try to avoid enabling this setting where possible. If you have steps for publishing to both PyPI and TestPyPI, consider only using it for the latter, having the former fail loudly on duplicates.

For Debugging

Sometimes, twine upload can fail and to debug use the verbose setting as follows:

   with:
     verbose: true

Showing hash values of files to be uploaded

You may want to verify whether the files on PyPI were automatically uploaded by CI script. It will show SHA256, MD5, BLAKE2-256 values of files to be uploaded.

  with:
    print-hash: true

Specifying a different username

The default username value is __token__. If you publish to a custom registry that does not provide API tokens, like devpi, you may need to specify a custom username and password pair. This is how it's done.

  with:
    user: guido
    password: ${{ secrets.DEVPI_PASSWORD }}

The secret used in ${{ secrets.DEVPI_PASSWORD }} needs to be created on the environment page under the settings of your project on GitHub. See Creating & using secrets.

In the past, when publishing to PyPI, the most secure way of the access scoping for automatic publishing was to use the API tokens feature of PyPI. One would make it project-scoped and save as an environment-bound secret in their GitHub repository settings, naming it ${{ secrets.PYPI_API_TOKEN }}, for example. See Creating & using secrets. While still secure, trusted publishing is now encouraged over API tokens as a best practice on supported platforms (like GitHub).

License

The Dockerfile and associated scripts and documentation in this project are released under the BSD 3-clause license.

gh-action-pypi-publish's People

Contributors

asherf avatar colindean avatar dependabot[bot] avatar di avatar digitronik avatar dukecat0 avatar grische avatar henryiii avatar hugovk avatar jaap3 avatar jessefarebro avatar matham avatar mfussenegger avatar pllim avatar pquentin avatar pre-commit-ci[bot] avatar samuelhwilliams avatar scop avatar sesdaile-varmour avatar siguremo avatar sub-mod avatar virtuald avatar webknjaz avatar woodruffw avatar xuanzhi33 avatar zhongjiajie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gh-action-pypi-publish's Issues

working-directory ignored

Using this github action (v1.5) along with the 'working-directory' directive (under defaults.run), I get an error, "InvalidDistribution: Cannot find file (or expand pattern): 'dist/*'"

It seems that this plugin is ignoring the provided 'working-directory' as of v1.5

A GitHub Action Workflow demonstrating the issue:

on: [push]
jobs:
  deploy:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    defaults:
      run:
        shell: bash
        working-directory: python-client      # ๐Ÿ‘€ NOTICE: This working directory should apply to all below steps

    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
      - name: Setup Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.6"
      - name: Package ๐Ÿ“ฆ
        run: python setup.py sdist
        
      - name: Publish ๐Ÿ“ฆ to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1.5
        with:
          password: ${{ secrets.NTSJENKINS_PYPI }}
          packages_dir: dist                   # โŒ this fails.
          # packages_dir: python-client/dist   # โœ… this works.

Raw console output for this failed task

2022-01-31T21:42:53.3676862Z ##[group]Run pypa/gh-action-pypi-publish@master
2022-01-31T21:42:53.3677359Z with:
2022-01-31T21:42:53.3678936Z   password: ***

2022-01-31T21:42:53.3679246Z   packages_dir: dist
2022-01-31T21:42:53.3679521Z   user: __token__
2022-01-31T21:42:53.3679751Z   verify_metadata: true
2022-01-31T21:42:53.3680116Z   skip_existing: false
2022-01-31T21:42:53.3680348Z   verbose: false
2022-01-31T21:42:53.3680618Z   print_hash: false
2022-01-31T21:42:53.3681071Z env:
2022-01-31T21:42:53.3681359Z   pythonLocation: /opt/hostedtoolcache/Python/3.6.15/x64
2022-01-31T21:42:53.3681821Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.6.15/x64/lib
2022-01-31T21:42:53.3682131Z ##[endgroup]
2022-01-31T21:42:53.4041919Z ##[command]/usr/bin/docker run --name db2d72e9457747aab47d7b5f146799b3e286c_b34990 --label 7db2d7 --workdir /github/workspace --rm -e pythonLocation -e LD_LIBRARY_PATH -e INPUT_PASSWORD -e INPUT_PACKAGES_DIR -e INPUT_USER -e INPUT_REPOSITORY_URL -e INPUT_VERIFY_METADATA -e INPUT_SKIP_EXISTING -e INPUT_VERBOSE -e INPUT_PRINT_HASH -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/google-cloud-storage/google-cloud-storage":"/github/workspace" 7db2d7:2e9457747aab47d7b5f146799b3e286c  "__token__" "***
" "" "dist" "true" "false" "false" "false"
2022-01-31T21:42:53.9670746Z ##[warning] It looks like there are no Python distribution packages to publish in the directory 'dist/'. Please verify that they are in place should you face this problem.
2022-01-31T21:42:54.7887798Z InvalidDistribution: Cannot find file (or expand pattern): 'dist/*'

Container build failure on master: `gcc` missing

This is completely unrelated to the work I'm doing on PyPI, but I just noticed it on another project: cryptography is failing to build because gcc is missing. My best guess is that the docker container that this action is using changed underneath it.

Raw error:

Building wheels for collected packages: cryptography
2020-12-09T00:33:50.3441972Z   Building wheel for cryptography (PEP 517): started
2020-12-09T00:33:51.4732894Z   Building wheel for cryptography (PEP 517): finished with status 'error'
2020-12-09T00:33:51.4745471Z ๏ฟฝ[91m  ERROR: Command errored out with exit status 1:
2020-12-09T00:33:51.4746375Z    command: /usr/local/bin/python /usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpnbs2lzqp
2020-12-09T00:33:51.4747511Z        cwd: /tmp/pip-install-yxqcx4jn/cryptography_4bbbeefb6f3647b9b31617dd26d2712d
2020-12-09T00:33:51.4748271Z   Complete output (146 lines):
2020-12-09T00:33:51.4748683Z   running bdist_wheel
2020-12-09T00:33:51.4749037Z   running build
2020-12-09T00:33:51.4749392Z   running build_py
2020-12-09T00:33:51.4749741Z   creating build
2020-12-09T00:33:51.4750188Z   creating build/lib.linux-x86_64-3.8
2020-12-09T00:33:51.4750734Z   creating build/lib.linux-x86_64-3.8/cryptography
2020-12-09T00:33:51.4751450Z   copying src/cryptography/utils.py -> build/lib.linux-x86_64-3.8/cryptography
2020-12-09T00:33:51.4752252Z   copying src/cryptography/__init__.py -> build/lib.linux-x86_64-3.8/cryptography
2020-12-09T00:33:51.4755057Z   copying src/cryptography/__about__.py -> build/lib.linux-x86_64-3.8/cryptography
2020-12-09T00:33:51.4757211Z   copying src/cryptography/fernet.py -> build/lib.linux-x86_64-3.8/cryptography
2020-12-09T00:33:51.4758214Z   copying src/cryptography/exceptions.py -> build/lib.linux-x86_64-3.8/cryptography
2020-12-09T00:33:51.4758990Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat
2020-12-09T00:33:51.4759765Z   copying src/cryptography/hazmat/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat
2020-12-09T00:33:51.4760649Z   copying src/cryptography/hazmat/_der.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat
2020-12-09T00:33:51.4761547Z   copying src/cryptography/hazmat/_oid.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat
2020-12-09T00:33:51.4762304Z   creating build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4763088Z   copying src/cryptography/x509/extensions.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4763962Z   copying src/cryptography/x509/name.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4764813Z   copying src/cryptography/x509/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4765746Z   copying src/cryptography/x509/certificate_transparency.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4766696Z   copying src/cryptography/x509/oid.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4767566Z   copying src/cryptography/x509/general_name.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4768421Z   copying src/cryptography/x509/base.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4769263Z   copying src/cryptography/x509/ocsp.py -> build/lib.linux-x86_64-3.8/cryptography/x509
2020-12-09T00:33:51.4770040Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/bindings
2020-12-09T00:33:51.4770912Z   copying src/cryptography/hazmat/bindings/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/bindings
2020-12-09T00:33:51.4771913Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/backends
2020-12-09T00:33:51.4772785Z   copying src/cryptography/hazmat/backends/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends
2020-12-09T00:33:51.4773851Z   copying src/cryptography/hazmat/backends/interfaces.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends
2020-12-09T00:33:51.4774790Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4775735Z   copying src/cryptography/hazmat/primitives/hashes.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4776810Z   copying src/cryptography/hazmat/primitives/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4777910Z   copying src/cryptography/hazmat/primitives/padding.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4779012Z   copying src/cryptography/hazmat/primitives/poly1305.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4780164Z   copying src/cryptography/hazmat/primitives/hmac.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4781260Z   copying src/cryptography/hazmat/primitives/keywrap.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4782389Z   copying src/cryptography/hazmat/primitives/constant_time.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4783489Z   copying src/cryptography/hazmat/primitives/cmac.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives
2020-12-09T00:33:51.4784426Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/bindings/openssl
2020-12-09T00:33:51.4785397Z   copying src/cryptography/hazmat/bindings/openssl/binding.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/bindings/openssl
2020-12-09T00:33:51.4786551Z   copying src/cryptography/hazmat/bindings/openssl/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/bindings/openssl
2020-12-09T00:33:51.4787736Z   copying src/cryptography/hazmat/bindings/openssl/_conditional.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/bindings/openssl
2020-12-09T00:33:51.4788727Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4789684Z   copying src/cryptography/hazmat/backends/openssl/x25519.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4790798Z   copying src/cryptography/hazmat/backends/openssl/ec.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4791958Z   copying src/cryptography/hazmat/backends/openssl/backend.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4793106Z   copying src/cryptography/hazmat/backends/openssl/utils.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4794239Z   copying src/cryptography/hazmat/backends/openssl/x448.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4795492Z   copying src/cryptography/hazmat/backends/openssl/hashes.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4796648Z   copying src/cryptography/hazmat/backends/openssl/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4797776Z   copying src/cryptography/hazmat/backends/openssl/rsa.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4798929Z   copying src/cryptography/hazmat/backends/openssl/decode_asn1.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4800083Z   copying src/cryptography/hazmat/backends/openssl/dsa.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4801228Z   copying src/cryptography/hazmat/backends/openssl/ciphers.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4802397Z   copying src/cryptography/hazmat/backends/openssl/aead.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4803614Z   copying src/cryptography/hazmat/backends/openssl/poly1305.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4804758Z   copying src/cryptography/hazmat/backends/openssl/x509.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4805890Z   copying src/cryptography/hazmat/backends/openssl/ocsp.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4807012Z   copying src/cryptography/hazmat/backends/openssl/dh.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4808141Z   copying src/cryptography/hazmat/backends/openssl/ed448.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4809267Z   copying src/cryptography/hazmat/backends/openssl/hmac.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4810467Z   copying src/cryptography/hazmat/backends/openssl/ed25519.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4811658Z   copying src/cryptography/hazmat/backends/openssl/encode_asn1.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4812814Z   copying src/cryptography/hazmat/backends/openssl/cmac.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/backends/openssl
2020-12-09T00:33:51.4813793Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4814840Z   copying src/cryptography/hazmat/primitives/asymmetric/x25519.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4816077Z   copying src/cryptography/hazmat/primitives/asymmetric/ec.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4817318Z   copying src/cryptography/hazmat/primitives/asymmetric/utils.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4818572Z   copying src/cryptography/hazmat/primitives/asymmetric/x448.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4819796Z   copying src/cryptography/hazmat/primitives/asymmetric/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4821047Z   copying src/cryptography/hazmat/primitives/asymmetric/rsa.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4822287Z   copying src/cryptography/hazmat/primitives/asymmetric/dsa.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4823565Z   copying src/cryptography/hazmat/primitives/asymmetric/padding.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4824830Z   copying src/cryptography/hazmat/primitives/asymmetric/dh.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4826070Z   copying src/cryptography/hazmat/primitives/asymmetric/ed448.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4827327Z   copying src/cryptography/hazmat/primitives/asymmetric/ed25519.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/asymmetric
2020-12-09T00:33:51.4828368Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/twofactor
2020-12-09T00:33:51.4829406Z   copying src/cryptography/hazmat/primitives/twofactor/hotp.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/twofactor
2020-12-09T00:33:51.4830627Z   copying src/cryptography/hazmat/primitives/twofactor/utils.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/twofactor
2020-12-09T00:33:51.4831851Z   copying src/cryptography/hazmat/primitives/twofactor/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/twofactor
2020-12-09T00:33:51.4833120Z   copying src/cryptography/hazmat/primitives/twofactor/totp.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/twofactor
2020-12-09T00:33:51.4834143Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/ciphers
2020-12-09T00:33:51.4835285Z   copying src/cryptography/hazmat/primitives/ciphers/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/ciphers
2020-12-09T00:33:51.4836471Z   copying src/cryptography/hazmat/primitives/ciphers/aead.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/ciphers
2020-12-09T00:33:51.4838107Z   copying src/cryptography/hazmat/primitives/ciphers/base.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/ciphers
2020-12-09T00:33:51.4839307Z   copying src/cryptography/hazmat/primitives/ciphers/modes.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/ciphers
2020-12-09T00:33:51.4840677Z   copying src/cryptography/hazmat/primitives/ciphers/algorithms.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/ciphers
2020-12-09T00:33:51.4841832Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4842810Z   copying src/cryptography/hazmat/primitives/kdf/scrypt.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4843935Z   copying src/cryptography/hazmat/primitives/kdf/x963kdf.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4845154Z   copying src/cryptography/hazmat/primitives/kdf/concatkdf.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4846301Z   copying src/cryptography/hazmat/primitives/kdf/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4847424Z   copying src/cryptography/hazmat/primitives/kdf/kbkdf.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4848559Z   copying src/cryptography/hazmat/primitives/kdf/pbkdf2.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4849683Z   copying src/cryptography/hazmat/primitives/kdf/hkdf.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/kdf
2020-12-09T00:33:51.4850687Z   creating build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/serialization
2020-12-09T00:33:51.4851796Z   copying src/cryptography/hazmat/primitives/serialization/__init__.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/serialization
2020-12-09T00:33:51.4853115Z   copying src/cryptography/hazmat/primitives/serialization/pkcs7.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/serialization
2020-12-09T00:33:51.4854448Z   copying src/cryptography/hazmat/primitives/serialization/base.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/serialization
2020-12-09T00:33:51.4855764Z   copying src/cryptography/hazmat/primitives/serialization/ssh.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/serialization
2020-12-09T00:33:51.4857109Z   copying src/cryptography/hazmat/primitives/serialization/pkcs12.py -> build/lib.linux-x86_64-3.8/cryptography/hazmat/primitives/serialization
2020-12-09T00:33:51.4857951Z   running egg_info
2020-12-09T00:33:51.4858495Z   writing src/cryptography.egg-info/PKG-INFO
2020-12-09T00:33:51.4859305Z   writing dependency_links to src/cryptography.egg-info/dependency_links.txt
2020-12-09T00:33:51.4860214Z   writing requirements to src/cryptography.egg-info/requires.txt
2020-12-09T00:33:51.4861063Z   writing top-level names to src/cryptography.egg-info/top_level.txt
2020-12-09T00:33:51.4861907Z   reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
2020-12-09T00:33:51.4862593Z   reading manifest template 'MANIFEST.in'
2020-12-09T00:33:51.4863281Z   no previously-included directories found matching 'docs/_build'
2020-12-09T00:33:51.4864053Z   warning: no previously-included files found matching 'vectors'
2020-12-09T00:33:51.4864887Z   warning: no previously-included files matching '*' found under directory 'vectors'
2020-12-09T00:33:51.4865856Z   warning: no previously-included files matching '*' found under directory '.github'
2020-12-09T00:33:51.4866701Z   warning: no previously-included files found matching 'release.py'
2020-12-09T00:33:51.4867524Z   warning: no previously-included files found matching '.coveragerc'
2020-12-09T00:33:51.4868326Z   warning: no previously-included files found matching 'codecov.yml'
2020-12-09T00:33:51.4869178Z   warning: no previously-included files found matching '.readthedocs.yml'
2020-12-09T00:33:51.4870098Z   warning: no previously-included files found matching 'dev-requirements.txt'
2020-12-09T00:33:51.4871068Z   warning: no previously-included files found matching 'rtd-requirements.txt'
2020-12-09T00:33:51.4871922Z   warning: no previously-included files found matching 'tox.ini'
2020-12-09T00:33:51.4872748Z   warning: no previously-included files matching '*' found under directory '.zuul.d'
2020-12-09T00:33:51.4873674Z   warning: no previously-included files matching '*' found under directory '.zuul.playbooks'
2020-12-09T00:33:51.4874952Z   writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
2020-12-09T00:33:51.4875717Z   warning: build_py: byte-compiling is disabled, skipping.
2020-12-09T00:33:51.4876200Z   
2020-12-09T00:33:51.4876504Z   running build_ext
2020-12-09T00:33:51.4877055Z   generating cffi module 'build/temp.linux-x86_64-3.8/_padding.c'
2020-12-09T00:33:51.4877662Z   creating build/temp.linux-x86_64-3.8
2020-12-09T00:33:51.4878282Z   generating cffi module 'build/temp.linux-x86_64-3.8/_openssl.c'
2020-12-09T00:33:51.4878857Z   building '_openssl' extension
2020-12-09T00:33:51.4879374Z   creating build/temp.linux-x86_64-3.8/build
2020-12-09T00:33:51.4879998Z   creating build/temp.linux-x86_64-3.8/build/temp.linux-x86_64-3.8
2020-12-09T00:33:51.4881466Z   gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.8 -c build/temp.linux-x86_64-3.8/_openssl.c -o build/temp.linux-x86_64-3.8/build/temp.linux-x86_64-3.8/_openssl.o -Wconversion -Wno-error=sign-conversion
2020-12-09T00:33:51.4882834Z   unable to execute 'gcc': No such file or directory
2020-12-09T00:33:51.4883261Z   
2020-12-09T00:33:51.4883626Z       =============================DEBUG ASSISTANCE=============================
2020-12-09T00:33:51.4884245Z       If you are seeing a compilation error please try the following steps to
2020-12-09T00:33:51.4884910Z       successfully install cryptography:
2020-12-09T00:33:51.4885530Z       1) Upgrade to the latest pip and try again. This will fix errors for most
2020-12-09T00:33:51.4886338Z          users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2020-12-09T00:33:51.4887266Z       2) Read https://cryptography.io/en/latest/installation.html for specific
2020-12-09T00:33:51.4888012Z          instructions for your platform.
2020-12-09T00:33:51.4888598Z       3) Check our frequently asked questions for more information:
2020-12-09T00:33:51.4889311Z          https://cryptography.io/en/latest/faq.html
2020-12-09T00:33:51.4889907Z       =============================DEBUG ASSISTANCE=============================
2020-12-09T00:33:51.4890279Z   
2020-12-09T00:33:51.4890682Z   error: command 'gcc' failed with exit status 1
2020-12-09T00:33:51.4891170Z   ----------------------------------------
2020-12-09T00:33:51.4891688Z ๏ฟฝ[0m๏ฟฝ[91m  ERROR: Failed building wheel for cryptography
2020-12-09T00:33:51.4892289Z ๏ฟฝ[0mFailed to build cryptography
2020-12-09T00:33:51.4893022Z ๏ฟฝ[91mERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
2020-12-09T00:33:51.9156945Z The command '/bin/sh -c pip install --upgrade --no-cache-dir twine' returned a non-zero code: 1
2020-12-09T00:33:51.9157576Z ๏ฟฝ[0m
2020-12-09T00:33:51.9175397Z ##[warning]Docker build failed with exit code 1, back off 6.602 seconds before retry.

Example failing workflow: https://github.com/trailofbits/blight/runs/1520996200

Integrate reporting via GitHub APIs using octomachinery

The idea is to wrap twine invocation with the octomachinery framework which supports GitHub Actions out of the box.
We need to specify an event handler for Actions and after the command execution analyze the result and report this information back to GitHub using:

  • Checks API (with the details of what was happening)
  • Deployment API (with link to PyPI page)

Info about octomachinery:

App examples (with Actions and Checks API):

Run 'twine check' before upload?

twine check can detect problems such as bad README formatting or classifiers. I think it's worth running before the upload step?

action fails when non-dist files are present

It seems like the action tries to upload all files and directories present in the dist/ directory. This is fine as long as the build system did not add other files or directories to the dist/ directory.

In some cases the build system might add other files or directories. Most common is a <package-name>-<version>.dist-info directory. One example can be found here.

Currently one can work around this by cleaning up the pollution manually, but I think it would be better to make the package discovery a bit more robust. Most notably directories should be excluded.

CherryPy in LICENSE.md text

It looks like the LICENSE.md text was copied from another project, specifically the third clause:

  • Neither the name of CherryPy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

Perhaps that should be "PyPA" or "gh-action-pypi-publish" instead?

Help to deploy only some versions

I want to be able to upload my packages to pypi when I create a release. But I don't want to do it on every release, just stable versions. I read your tip:

Pro tip: instead of using branch pointers, like master, pin versions of Actions that you use to tagged versions or sha1 commit identifiers. This will make your workflows more secure and better reproducible, saving you from sudden and unpleasant surprises.

But I couldn't make it work.

I tried with the if you suggested but I couldn't deploy any package (tagged or not) when I added the if. This one:

 if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

Could you help me to implement that. This is my current pypi-publish.yml:

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload to PyPI

on:
  release:
    branches: [ main ]
    types: [published]

jobs:
  deploy:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install build
    - name: Build package
      run: python -m build
    - name: Publish package
      uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN_RUNUP }} 

Add a usage guide to packaging.python.org

I think it should be in a how-to tutorial style.

All info (more or less) is already in the README. It just needs to be turned into a nice and detailed text.
Essentially, this action just runs twine upload meaning that anything that twine can do can be done with an Action.

We need to explain that users can easily set any env vars twine consumes and how to be careful with secrets.

Start here: https://github.com/pypa/packaging.python.org/fork

Tutorial improvements

There's been some confusion with the tutorial so I'm documenting a few things that I'd like to improve (not sure if they belong to the tutorial or to separate guides):

  • Building OS-specific wheels under multiple VMs/OSs, publishing them as build artifacts, then testing exactly those and finally publishing the dists to PyPIs (knowing that they are good)
  • Publishing each commit versions that are in between Git tags (setuptools-scm etc.) is not a widely known technique (I may even be the first one to propose it) and needs a more public explanation

Invalid warning when using wildcards in packages_dir variable

When using a wildcard in the packages_dir folder, the following invalid warning is issued:

##[warning] It looks like there are no Python distribution packages to publish in the directory 'release/*/'. Please verify that they are in place should you face this problem.

Inside those subfolders are whl/tar.gz files and hence the action still successfully continues running.

Here is the GitHub actions file:

        # Publish to TestPyPi on each merge to master
      - name: Publish distribution ๐Ÿ“ฆ to Test PyPI
        if: github.event_name != 'pull_request'
        uses: pypa/[email protected]
        with:
          password: ${{ secrets.test_pypi_token }}
          repository_url: https://test.pypi.org/legacy/
          packages_dir: "release/*/"

Here is the log output:

 Publish distribution ๐Ÿ“ฆ to Test PyPI3s
    RELEASE_VERSION: 20200621
Run pypa/[email protected]
  with:
    password: ***
    repository_url: https://test.pypi.org/legacy/
    packages_dir: release/*/
    user: __token__
    verify_metadata: true
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.7.7/x64
    RELEASE_VERSION: 20200621
/usr/bin/docker run --name c27d31aa85ebc4e6e34873a5573ecfa0e8d524_dfa4f2 --label c27d31 --workdir /github/workspace --rm -e pythonLocation -e RELEASE_VERSION -e INPUT_PASSWORD -e INPUT_REPOSITORY_URL -e INPUT_PACKAGES_DIR -e INPUT_USER -e INPUT_VERIFY_METADATA -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_API_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/fake-bpy-module/fake-bpy-module":"/github/workspace" c27d31:aa85ebc4e6e34873a5573ecfa0e8d524  "__token__" "***" "https://test.pypi.org/legacy/" "release/*/" "true"
##[warning] It looks like there are no Python distribution packages to publish in the directory 'release/*/'. Please verify that they are in place should you face this problem.
Checking release/2.82/fake_bpy_module_2.82-20200621-py3-none-any.whl: PASSED, with warnings
  warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Checking release/2.82/fake-bpy-module-2.82-20200621.tar.gz: PASSED, with warnings
  warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Uploading distributions to https://test.pypi.org/legacy/
Uploading fake_bpy_module_2.82-20200621-py3-none-any.whl

publish fails due to rust compiler not found

Oh yes.

https://github.com/robotpy/robotpy-navx/runs/1856441423?check_suite_focus=true

...
Step 7/12 : RUN pip install --upgrade --no-cache-dir twine
   ---> Running in ce26efd674e3
...
Building wheels for collected packages: cryptography
    Building wheel for cryptography (PEP 517): started
    Building wheel for cryptography (PEP 517): finished with status 'error'
    ERROR: Command errored out with exit status 1:
...
        =============================DEBUG ASSISTANCE=============================
        If you are seeing a compilation error please try the following steps to
        successfully install cryptography:
        1) Upgrade to the latest pip and try again. This will fix errors for most
           users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
        2) Read https://cryptography.io/en/latest/installation.html for specific
           instructions for your platform.
        3) Check our frequently asked questions for more information:
           https://cryptography.io/en/latest/faq.html
        4) Ensure you have a recent Rust toolchain installed:
           https://cryptography.io/en/latest/installation.html#rust
        5) If you are experiencing issues with Rust for *this release only* you may
           set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
        =============================DEBUG ASSISTANCE=============================
...
error: Can not find Rust compiler

Seems like the crptography project messed something up when publishing their wheel? But maybe you need to set that environment variable mentioned?

Create v1 tag for rolling releases

First, thanks for maintaining this neat GitHub Action, and congrats for the v1.1.0 release.

Now that we no longer have the alpha suffix in the version, could you please create a v1 tag which is kept updated to the latest stable version? It would greatly benefit users looking to "subscribe" to bug fixes. Also, all of GitHub's official Actions also provide a v1 tag, and it would make the overall user experience consistent when writing Workflows.

I understand that updating the v1 tag every time adds extra burden on the maintainers. Hopefully, it might be automate this as part of the release process for this Action.

[Help wanted] I can't to upload from github to PyPI via github workflow

This is my package: https://github.com/ben981/scriptifier
I am trying to get it on PyPI using github Actions but when I make a new release, the uploader launches and I get:

Build and publish:
Run python setup.py sdist bdist_wheel
python: can't open file '/home/runner/work/scriptifier/scriptifier/setup.py': [Errno 2] No such file or directory
Error: Process completed with exit code 2.

Am I missing something? Do I need to upload it / create a repository in PyPI before doing this?

[metaissue] Action items for going live

Stage 0

  • Put the repo with code under pypa (done by @pradyunsg)
  • Try convincing GitHub to enable Actions for pypa (and python, but that's not directly related)
    • Actions are enabled for PyPA org now.
    • This will probably not work for now โ€” when I tried asking GH to enroll participants of my workshop they said that the waitlist is huge. But it looks like I can still publish this Action to the Marketplace.
  • โœ”๏ธ Do a security review of the Action (#14)

Stage 1: Once Warehouse supports tokens

  • Publish the Action to the Marketplace
  • Write the docs. (See #2 / pypa/packaging.python.org#647)
  • Merge docs (See #2)
  • Implement Action testing (this one may be challenging ATM. See #3)
    • Smoke testing added via #111
  • Keep improving the Action (#4)
    • This is always in the works
  • Monitor SO and other sources of complaints
    • We watch GitHub issues and Discussions attached to releases now
  • Keep it up with the latest best practices
    • I think it's up to date

Create a new release?

First of all, thank for this action. It is very useful.

I was wondering if you could create a new release. The current release v1.0.0a0 is already a bit outdated. It is 19 commits behind master. It is also lacking the useful feature of being able to define the package_dir/.

FileNotFoundError: [Errno 2] No such file or directory: '/github/workspace/wheelhouse/*'

My github actions script is breaking without any changes to the script.
The print_hash setting appears to be ignored and thus erroring out because there are no hashes.

## first I identify what is available to be uploaded from the wheelhouse directory
Run ls -latR wheelhouse
  ls -latR wheelhouse
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
wheelhouse:
total 12
drwxr-xr-x 2 runner docker 4096 Jan 12 20:09 btc_pip_dist-3.9-ubuntu-latest
drwxr-xr-x 3 runner docker 4096 Jan 12 20:09 .
drwxr-xr-x 3 runner docker 4096 Jan 12 20:09 ..

wheelhouse/btc_pip_dist-3.9-ubuntu-latest:
total 2260
-rw-r--r-- 1 runner docker 2304081 Jan 12 20:09 brainome-1.8.80-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
drwxr-xr-x 2 runner docker    4096 Jan 12 20:09 .
drwxr-xr-x 3 runner docker    4096 Jan 12 20:09 ..

## second I run the verify and upload 
Run pypa/gh-action-pypi-publish@release/v1
  with:
    user: __token__
    password: ***
    repository_url: https://test.pypi.org/legacy/
    packages_dir: wheelhouse/\*/
    verbose: true
    verify_metadata: true
    skip_existing: false
    print_hash: false
/usr/bin/docker run --name a6825092b92cd3441479187c9d283f7e5ebcc_aff43d --label 6a6825 --workdir /github/workspace --rm -e INPUT_USER -e INPUT_PASSWORD -e INPUT_REPOSITORY_URL -e INPUT_PACKAGES_DIR -e INPUT_VERBOSE -e INPUT_VERIFY_METADATA -e INPUT_SKIP_EXISTING -e INPUT_PRINT_HASH -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/mlmeter/mlmeter":"/github/workspace" 6a6825:092b92cd3441479187c9d283f7e5ebcc  "__token__" "***" "https://test.pypi.org/legacy/" "wheelhouse/*/" "true" "false" "true" "false"
Checking wheelhouse/btc_pip_dist-3.9-ubuntu-latest/brainome-1.8.80-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl: PASSED
Traceback (most recent call last):
  File "/app/print-hash.py", line 9, in <module>
    for file_object in packages_dir.iterdir():
  File "/usr/local/lib/python3.9/pathlib.py", line 1160, in iterdir
Showing hash values of files to be uploaded:
    for name in self._accessor.listdir(self):
FileNotFoundError: [Errno 2] No such file or directory: '/github/workspace/wheelhouse/*'

Container action is only supported on Linux

Hello.

I ran into this when I attempted to upload wheels generated in Windows and OSX for a package with C-extension. Do you have plans to re-implement this action in Typescript or Javascript, or is that even possible?

2021-01-15T17:48:26.9532380Z ##[group]Run pypa/gh-action-pypi-publish@master
2021-01-15T17:48:26.9533060Z with:
2021-01-15T17:48:26.9533460Z   packages_dir: wheelhouse/
2021-01-15T17:48:26.9534130Z   repository_url: https://test.pypi.org/legacy/
2021-01-15T17:48:26.9534690Z   verbose: true
2021-01-15T17:48:26.9535230Z   verify_metadata: true
2021-01-15T17:48:26.9535660Z   skip_existing: false
2021-01-15T17:48:26.9536020Z env:
2021-01-15T17:48:26.9536590Z   pythonLocation: /Users/runner/hostedtoolcache/Python/3.8.7/x64
2021-01-15T17:48:26.9537160Z ##[endgroup]
2021-01-15T17:48:26.9586610Z ##[error]Container action is only supported on Linux
2021-01-15T17:48:26.9688420Z Post job cleanup.

Not sure if this would be addressed by #4 or not.

Thank you!

Action fails when `setupotools.setup` values are parsed from text file

I'm playing around with a dummy python package to understand how to properly use this action. This is my workflow file:

name: Upload Python Package

on:
  release:
    types: [published]

jobs:
  deploy:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install build
    - name: Build package
      run: python -m build
    - name: Publish package
      uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN }}

It fails giving

FileNotFoundError: [Errno 2] No such file or directory: '<my_pkg_name>/VERSION.txt'
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting dependencies for sdist...
* Building sdist...
* Building wheel from sdist
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting dependencies for wheel...

ERROR Backend subproccess exited when trying to invoke get_requires_for_build_wheel
Error: Process completed with exit code 1.

whenever I try to do something like this:

import setuptools
import os

# loading version number from path
VERSION_PATH = os.path.join(os.path.dirname(__file__), "<my_pkg_name>", "VERSION.txt")
with open(VERSION_PATH, "r") as version_file:
    version = version_file.read().strip()

setuptools.setup(
    ...
    version=version,
    ...

If I specify the version number by hand it works as expected.
The very same error appears if I try to parse the description from the README.
Am I doing anything wrong ?

Verified creator status for pypa

Hi!

Could the pypa organization request the "verified creator" status for GitHub Marketplace?

I see pypa already has the domain verification for www.pypa.io, but that's different than the verified creator status (seems like the domain verification is one condition for the creator status).

The verified creator status would ease the use of this and all pypa's Actions, as organizations/repositories may choose to allow running only Actions by "verified creators" (or by GitHub or those added to a custom allow list). Also on Marketplace search there is a filter for Actions by verified creators.

Possibility to use the action on non-linux runners

Github Actions only supports docker on linux and since this action is docker-based, it can only run on linux runners, but I see no reason for that. If this action is refactored into a composite action, it would enable everyone to choose whatever runner they need to run.

Getting 403 forbidden from TestPypi

Discussed in #38

i am facing the same issue as mentioned in #38
I rechecked the token too. there is no extra space[The same issue occurs when i try to publsh to PyPi too, however publishing to both was possible locally]

this is my yaml file content:

- name: Publish distribution ๐Ÿ“ฆ to Test PyPI
  uses: pypa/gh-action-pypi-publish@master
  with:
    password: ${{ secrets.PYPI_TEST_TOKEN }}
    repository_url: https://test.pypi.org/legacy/

Any help would be appreciated. Thanks

this is the runner log:

Uploading distributions to https://test.pypi.org/legacy/
Uploading pywsitest-0.3.5-py3-none-any.whl

  0%|          | 0.00/23.2k [00:00<?, ?B/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 23.2k/23.2k [00:00<00:00, 80.0kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 403 Forbidden from https://test.pypi.org/legacy/
Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.
Error: Process completed with exit code 1.

Provide a v1 tag

To avoid having to update all workflow files with minor release, it would be very convenient if there was a v1 tag that contained the latest v1.y.z.

Add major version at release

To make it easier for users to adapt to breaking changes in the action, having major version tags to rely on, instead of master, is a good thing for users and developers.
I recently discovered this awesome action which does exactly this, fully automated on relese if you set you workflow up like this.
Just wanted to share that info and action, to save you the research.

P.S.: Thanks for this action, it works like a charm ๐Ÿ˜„

ModuleNotFoundError: No module named 'typing_extensions'

Cant publish package

/usr/bin/docker run --name cd[98](https://github.com/Shkarlatov/python_test/runs/7284458255?check_suite_focus=true#step:4:99)f5dcfcd33f1cf4178b3c4feb1f275fc10_bfe2c1 --label 4cd98f --workdir /github/workspace --rm -e INPUT_USER -e INPUT_PASSWORD -e INPUT_REPOSITORY_URL -e INPUT_PACKAGES_DIR -e INPUT_VERIFY_METADATA -e INPUT_SKIP_EXISTING -e INPUT_VERBOSE -e INPUT_PRINT_HASH -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_DEBUG -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/python_test/python_test":"/github/workspace" 4cd98f:5dcfcd33f1cf4178b3c4feb1f275fc10  "__token__" "***" "" "dist" "true" "false" "false" "false"
Traceback (most recent call last):
  File "/usr/local/bin/twine", line 5, in <module>
    from twine.__main__ import main
  File "/usr/local/lib/python3.9/site-packages/twine/__main__.py", line 22, in <module>
    from twine import cli
  File "/usr/local/lib/python3.9/site-packages/twine/cli.py", line 21, in <module>
    import rich.logging
  File "/usr/local/lib/python3.9/site-packages/rich/logging.py", line 13, in <module>
    from .traceback import Traceback
  File "/usr/local/lib/python3.9/site-packages/rich/traceback.py", line 26, in <module>
    from .syntax import Syntax
  File "/usr/local/lib/python3.9/site-packages/rich/syntax.py", line 52, in <module>
    from typing_extensions import TypeAlias
ModuleNotFoundError: No module named 'typing_extensions'

My workflow

name: Python CI
jobs:
  build:
     ... build package and upload-artifacts
  publish:
    environment: CI
    needs: build
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
    steps:
      - name: Deploying artifacts
        uses: actions/download-artifact@v3
        with:
          name: dist
          path: dist/

      - name:  Publish a Python distribution to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}

Support using a list of tokens

I have a single github repository which uploads two separate pypi projects. I have separate tokens for each project, because I don't want to have a token that controls my entire pypi account.

So I configure to use both tokens:

  upload_dev_release_to_pypi:
    needs: build_wheels
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v2
        with:
          name: dist
          path: dist
      - uses: pypa/[email protected]
        with:
          user: __token__
          password: |
            ${{ secrets.pypi_token_stim }}
            ${{ secrets.pypi_token_stimcirq }}

Currently, this successfully uploads wheels for one project but not the other. It seems like it should work for both packages. Alternatively, the upload process should fail before uploading any of the wheels, complaining about how using multiple tokens is not permitted.

/app/twine-upload.sh: line 22: INPUT_PACKAGES_DIR: unbound variable

Hello,

I have an issue using this GitHub Action:

/app/twine-upload.sh: line 22: INPUT_PACKAGES_DIR: unbound variable

Looks like the last commit 2ae9caf it's the reason of this issue.

! -d ${INPUT_PACKAGES_DIR%%/}/ ||

Could it be because you are using an underscore instead of a dash like you have defined in the action.yml?

packages-dir:


Also, is it possible to use a specific version of this Action instead of the branch master to avoid this kind of issues?

Digitally sign before publish?

Hi Team,

Is there a way to digitally sign my package before publishing it to pypi? Is there a feature in here that allows for such a security publish?

Upload fails with 403 Invalid API Token: InvalidMacaroon

Hello,
thx for this cool tool, we have been using it already for a while but just not got some problems...

Unfortunately recently we started to observe some auth issue for uploading to test PyPI:
403 Invalid API Token: InvalidMacaroon('invalid macaroon signature')
as you can see in this GH action nightly build but at the same time uploading linked release event works fine...
I have tested locally to change the version to be as nightly YYYYMMDD and upload with twine and after passing my personal credentials it works fine too...

So I really don't know what is wrong as:

  • token shall be fine as we use the same as for release and that actions pass
  • version is also valid as we used it in the past and local upload also works

This is the call we use in both GH actions (the only diff is that one has a conditional trigger)

- name: Publish to Test PyPI
  uses: pypa/[email protected]
  with:
    user: __token__
    password: ${{ secrets.test_pypi_password }}
    repository_url: https://test.pypi.org/legacy/
    verbose: true

--skip-existing

Kind of a dumb question, but I have a build matrix with quite a few platforms and python version, and after adding

    - name: Publish distribution ๐Ÿ“ฆ to Test PyPI
      uses: pypa/gh-action-pypi-publish@master
      with:
        password: ${{ secrets.test_pypi_password }}
        repository_url: https://test.pypi.org/legacy/

all except one will fail due to the file already existing, so how should I account for that?

Unclear reason why upload fails

Please help to understand why upload fails from GitHub Actions.

action file:

job output:

I've done in job output echo -n "${{ secrets.PYPI_TOKEN }}" | sha1sum and compared with locally saved tolen value, the checksum was identica.

with the same token used for test/prod, I was able to upload from local successfully:

Test.pypi.org returning 500

I am not sure if this belongs here, but I am having an issue when using this Github Action.

This is the link to the github run that failed:
https://github.com/jampp/migratron/pull/25/checks?check_run_id=456554120

and the content is:

Uploading distributions to https://test.pypi.org/legacy/
Uploading migratron-1.1.0-py3-none-any.whl

  0%|          | 0.00/30.5k [00:00<?, ?B/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 30.5k/30.5k [00:00<00:00, 135kB/s]
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 1 of 5
Uploading migratron-1.1.0-py3-none-any.whl

  0%|          | 0.00/30.5k [00:00<?, ?B/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 30.5k/30.5k [00:00<00:00, 177kB/s]
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 2 of 5
Uploading migratron-1.1.0-py3-none-any.whl

  0%|          | 0.00/30.5k [00:00<?, ?B/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 30.5k/30.5k [00:00<00:00, 187kB/s]
Received "500: Internal Server Error" Package upload appears to have failed.  Retry 3 of 5
Uploading migratron-1.1.0-py3-none-any.whl

  0%|          | 0.00/30.5k [00:00<?, ?B/s]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 30.5k/30.5k [00:00<00:00, 276kB/s]
  Post actions/checkout@v2

If I run:

TWINE_USERNAME="__token__" \
TWINE_PASSWORD="pypi-foobar" \
TWINE_REPOSITORY_URL="https://test.pypi.org/legacy/" \
twine upload dist/*

with a valid TWINE_PASSWORD that works ok. If I use an invalid password ir returns a 403 and not a 500

add custom package_data to action

I'm trying to publish my bashbox package and can't figure out how to add some extra project data files that are needed to make one of the features work. How do I go about doing this?

How to upload multiple wheels in different path?

In our project, the directory structure after build as following:

project:
     - coordinator
          - dist
               1.whl
               2.whl
               - wheelhouse
                   3.whl
                   4.whl

How can I upload these 4 wheels to PyPI? In my release.yml, I try to use packages_dir, can it works?

- name: Publish to PyPI
   uses: pypa/gh-action-pypi-publish@master
   with:
       user: xxx
       password: xxx
       packages_dir: |
           coordinator/dist/
           coordinator/dist/wheelhouse

Print hash values of uploaded files

The files on PyPI have these hash values:

  • SHA256
  • MD5
  • BLAKE2-256

If print the hash values, people can easily verify whether the file on PyPI was automatically uploaded by CI script.
It is best to print a pretty-print table.

Docker build fails due to gcc being missing

Since yesterday (8th of December) the Action fails as it tries to build cryptography with gcc, which is missing from the python3.8:slim image.

    running build_ext
    generating cffi module 'build/temp.linux-x86_64-3.8/_padding.c'
    creating build/temp.linux-x86_64-3.8
    generating cffi module 'build/temp.linux-x86_64-3.8/_openssl.c'
    building '_openssl' extension
    creating build/temp.linux-x86_64-3.8/build
    creating build/temp.linux-x86_64-3.8/build/temp.linux-x86_64-3.8
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.8 -c build/temp.linux-x86_64-3.8/_openssl.c -o build/temp.linux-x86_64-3.8/build/temp.linux-x86_64-3.8/_openssl.o -Wconversion -Wno-error=sign-conversion
    unable to execute 'gcc': No such file or directory
    
        =============================DEBUG ASSISTANCE=============================
        If you are seeing a compilation error please try the following steps to
        successfully install cryptography:
        1) Upgrade to the latest pip and try again. This will fix errors for most
           users. See: pip.pypa.io/en/stable/installing/#upgrading-pip
        2) Read cryptography.io/en/latest/installation.html for specific
           instructions for your platform.
        3) Check our frequently asked questions for more information:
           cryptography.io/en/latest/faq.html
        =============================DEBUG ASSISTANCE=============================
    
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
    ERROR: Failed building wheel for cryptography
  Failed to build cryptography
  ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
  The command '/bin/sh -c pip install --upgrade --no-cache-dir twine' returned a non-zero code: 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.