We've added two new commands to the @apimatic/cli that make it easy to publish SDKs and list your publishing profiles directly from the CLI.
New Commands
1. SDK Publish
Generate and publish an SDK to a package registry (for example npm, PyPI, NuGet) or a source code repository (on GitHub) using a publishing profile configured in the APIMatic App.
apimatic sdk publish
Run without flags for a step-by-step guided experience, or supply all flags for CI/CD automation:
apimatic sdk publish --profile-id=a1b2c3d4e5f6a1b2c3d4e5f6 --language=typescript --version=1.0.0 --publish-type=package --publish-type=sourcecode
Flags
| Flag | Description |
|---|---|
--profile-id, -p | ID of the publishing profile to use. |
--language, -l | SDK language to generate and publish. |
--version, -v | Semantic version of the SDK (e.g. 1.0.0). |
--publish-type | Publishing target(s): package for a package registry, sourcecode for a git repository. Can be specified multiple times. |
--input | Path to the parent directory containing the 'src' directory, which includes API specification. Defaults to ./. |
--destination | Directory where the generated SDK will be saved locally. |
--dry-run | Generate the SDK locally for review without publishing. |
--force | Overwrite existing output without prompting. |
Publish Types
You can target one or both publishing targets in a single command by passing --publish-type multiple times:
# Publish to package registry only
apimatic sdk publish --profile-id=a1b2c3d4e5f6a1b2c3d4e5f6 --language=java --version=2.0.0 --publish-type=package
# Publish to both package registry and source repository
apimatic sdk publish --profile-id=b2c3d4e5f6a1b2c3d4e5f6a1 --language=typescript --version=1.0.0 --publish-type=package --publish-type=sourcecode
The language and publish type(s) specified must be configured in the publishing profile.
Dry Run
Use --dry-run to only generate the SDK locally and inspect the output before publishing:
apimatic sdk publish --dry-run --profile-id=c3d4e5f6a1b2c3d4e5f6a1b2 --language=python --version=1.0.0 --publish-type=package
2. Publishing Profile List
Display all publishing profiles associated with your account, including each profile's name, ID, and enabled languages.
apimatic publishing profile list
Use this command to look up the profile ID required for sdk publish:
# Find your profile ID
apimatic publishing profile list
┌ Publishing Profile List
│
◇ Publishing profiles fetched successfully.
│
● Publishing Profiles (3 profiles)
│
│ Apimatic API
│ ┌──────────────────────────┬────────────────────────────┬─────────────┐
│ │ Name │ ID │ Languages │
│ ├──────────────────────────┼────────────────────────────┼─────────────┤
│ │ New Publishing Profile │ a1b2c3d4e5f6a1b2c3d4e5f6 │ csharp │
│ └──────────────────────────┴────────────────────────────┴─────────────┘
│
│ APIMATIC Calculator
│ ┌────────────────────────────────────────┬────────────────────────────┬──────────────────────────────┐
│ │ Name │ ID │ Languages │
│ ├────────────────────────────────────────┼────────────────────────────┼──────────────────────────────┤
│ │ Test Package Publishing - Calculator │ b2c3d4e5f6a1b2c3d4e5f6a1 │ typescript │
│ ├────────────────────────────────────────┼────────────────────────────┼──────────────────────────────┤
│ │ Another Publishing Profile │ c3d4e5f6a1b2c3d4e5f6a1b2 │ csharp, python, typescript │
│ └────────────────────────────────────────┴────────────────────────────┴──────────────────────────────┘
│
└ Succeeded
Then use the profile ID with sdk publish:
apimatic sdk publish --profile-id=a1b2c3d4e5f6a1b2c3d4e5f6 --language=csharp --version=1.0.0 --publish-type=package
Upgrade Now
Install the latest CLI version from NPM:
npm install -g @apimatic/cli@latest
For full flag references and usage examples, see Publish an SDK and List Publishing Profiles.