Publish Your SDKs

Why publish your SDKs?

Publishing SDKs to package managers:

  • Enhances discoverability of your API.
  • Simplifies integration for developers using your API.
  • Automates SDK version management.

Prerequisites

  • The Speakeasy CLI installed on your machine.
  • SDKs generated for your API.
  • Access tokens or credentials for your target package managers.

Package Manager Support

Speakeasy SDK creation supports publishing SDKs to the following package managers:

LanguagePackage ManagerSupport
GoGitHub
PythonPyPI
TypeScriptnpm
JavaMaven
PHPPackagist
C#NuGet
RubyRubyGems
TerraformTerraform

Create Package Manager Credentials

To enable Speakeasy to manage publishing, you need to create tokens or provide credentials for each package manager you publish to. The tokens will be used to authenticate Speakeasy to publish on your behalf. Follow the links below to learn how to create the tokens for each package manager.

Package ManagerCredential CreationNotes
GitHub (Go)Repo visibility (opens in a new tab)If your repo is private, you need to add the Speakeasy app (opens in a new tab).
PyPI (Python)API tokens (opens in a new tab)
npm (JS/TS)Access tokens (opens in a new tab)Be sure to create an access token of type Automation.
Maven (Java)See our docs on setting this up (opens in a new tab)Publishing Java packages requires verification of domain ownership and signed releases.
Packagist (PHP)See publishing packages (opens in a new tab)To publish a PHP SDK, it must be in a single repo (monorepo not permitted).
NuGet (C#)API key (opens in a new tab)
Hashicorp (TF)GPG Key (opens in a new tab)

Name Your Package

Choose a name that will uniquely identify your package in the package manager ecosystem, so check to see if your preferred name is available first.

The name you give your package should make sense for your API. For example, if your business name is "pet-corp" and you're creating a package for your ecommerce API, you might call it petcorp-ecommerce. Make sure that the name follows the conventions of the package manager, summarized below:

LanguagePackage ManagerExample PackageNaming Conventions
JS/TSnpm@npm-org/package-nameLower case, hyphen separated
PythonPyPIpackage_nameLower case, underscore separated
GoGitHubgithub.com/org/repo-nameLower case, hyphen separated
JavaMavenpackageNameCamel case
PHPPackagistorg/package-nameLower case, hyphen separated
C#NuGetPackageNamePascal case
TerraformTerraformterraform-provider-nameLower case, hyphen separated
Success Icon

TIP

PyPI and Maven both scope packages globally, so you should choose a unique name for your package.

Publish Your package

1. Start Publishing Configuration

Launch the publishing setup process by running the following command in your terminal:


speakeasy configure publishing

You'll be prompted to select existing SDK targets for which you want to configure publishing (if none are available run speakeasy configure targets first). Use the arrow keys to navigate and space to select the targets, then press Enter to confirm your selection.

Screenshot of the terminal after running Speakeasy configure publishing.

2. Provide Publishing Credentials

After selecting the targets, you'll need to input environment variables required for publishing to package managers. For example, for a TypeScript target, you might be asked to provide an NPM Token:

Screenshot of the terminal prompting the user for an NPM token.

3. Verify Configuration Files

Once the configuration process is complete, Speakeasy will generate or update the necessary workflow files in your project directory:

  • .speakeasy/workflow.yaml for the Speakeasy workflow configuration.
  • .github/workflows/sdk_generation.yaml for the GitHub action to generate SDKs.
  • .github/workflows/sdk_publish.yaml for the GitHub action to publish SDKs.

Screenshot of the terminal after succesfully running Speakeasy configure publishing.

4. Set Up Repository Secrets

For the publishing setup to work correctly, you must add the required tokens as secrets in your GitHub repository:

  1. Navigate to your GitHub repository's Settings > Secrets & Variables > Actions.
  2. Click New repository secret.
  3. Add SPEAKEASY_API_KEY (if needed) and any other tokens (e.g., NPM_TOKEN) as secrets. Ensure the names match those specified during Speakeasy configuration.

5. Push Changes and Verify

Commit and push the updated or newly created workflow files to your GitHub repository.

Monitor the GitHub Actions tab in your repository for the execution of the SDK publishing workflow. Ensure the workflows complete successfully, indicating your SDKs are now configured to be automatically published.