Publish Python SDKs automatically

View as Markdown

You can publish SDKs generated in Postman to PyPI. Automated publishing is supported through GitHub Actions, which can be configured to publish your SDKs to PyPI whenever a new release is created in your GitHub repository. By default, the predefined workflow creates a new release every time an automatic PR is merged.

You can also publish manually from your local machine. To learn more, see Publish Python SDKs manually.

To publish your SDKs automatically, use a PyPI API token stored in GitHub secrets.

Prerequisites

  • A PyPI account with a verified email.
  • Two-factor authentication (2FA) enabled on the account.
  • The distribution name is available on PyPI, or you already own it.

Create a PyPI API token and add it to your GitHub repo

A PyPI API token (PYPI_API_TOKEN) is used for authentication with twine upload.

To create a PyPI API token and add it to your GitHub repo, do the following:

  1. Sign in at pypi.org and select Account settings > API tokens > Add API token.
  2. Create the token:
    • For first publish of a new project, create an account-scoped token (project scope isn’t available until the project exists).
    • After the project exists, create a token scoped to that project only.
  3. Copy the token (starts with pypi-...). It’s shown only once.
  4. In GitHub, select your repository and click Settings > Secrets and variables > Actions > New repository secret. Name it PYPI_API_TOKEN and paste the token.

When using token authentication, the username is __token__.