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:
Language | Package Manager | Support |
---|---|---|
Go | GitHub | ✅ |
Python | PyPI | ✅ |
TypeScript | npm | ✅ |
Java | Maven | ✅ |
PHP | Packagist | ✅ |
C# | NuGet | ✅ |
Ruby | RubyGems | ✅ |
Terraform | Terraform | ✅ |
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 Manager | Credential Creation | Notes |
---|---|---|
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:
Language | Package Manager | Example Package | Naming Conventions |
---|---|---|---|
JS/TS | npm | @npm-org/package-name | Lower case, hyphen separated |
Python | PyPI | package_name | Lower case, underscore separated |
Go | GitHub | github.com/org/repo-name | Lower case, hyphen separated |
Java | Maven | packageName | Camel case |
PHP | Packagist | org/package-name | Lower case, hyphen separated |
C# | NuGet | PackageName | Pascal case |
Terraform | Terraform | terraform-provider-name | Lower case, hyphen separated |
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.
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:
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.
4. Set Up Repository Secrets
For the publishing setup to work correctly, you must add the required tokens as secrets in your GitHub repository:
- Navigate to your GitHub repository's Settings > Secrets & Variables > Actions.
- Click New repository secret.
- 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.