> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. # Publishing to RubyGems > Publish Ruby SDKs to RubyGems with Fern. Complete setup guide for package configuration, API key authentication, and versioned releases. #### Enterprise feature This feature is available only for the [Enterprise plan](https://buildwithfern.com/pricing). To get started, reach out to [support@buildwithfern.com](mailto:support@buildwithfern.com). Publish your public-facing Fern Ruby SDK to the [RubyGems registry](https://rubygems.org/). After following the steps on this page, you'll have a versioned package published on RubyGems. To distribute the SDK internally instead, generate to the local file system (optionally [self-hosted](/learn/sdks/deep-dives/self-hosted)) and build a gem with [`fern generate --package`](/learn/cli-api-reference/cli-reference/sdk-commands#package). This page assumes that you have: * An initialized `fern` folder, a GitHub repository for your Ruby SDK, and a Ruby generator group in `generators.yml`. See [Generating an SDK (Ruby)](/learn/sdks/generators/ruby/quickstart). ## Configure `generators.yml` #### Configure \`output\` location Next, change the output location in `generators.yml` from `local-file-system` (the default) to `pypi` to indicate that Fern should publish your package directly to the PyPI registry: ```yaml {6-7} groups: ruby-sdk: generators: - name: fern-ruby-sdk version: 1.25.0 output: location: rubygems ``` #### Add a unique package name Your package name must be unique in the RubyGems repository, otherwise publishing your SDK to RubyGems will fail. Update your package name if you haven't done so already: ```yaml {8} groups: ruby-sdk: generators: - name: fern-ruby-sdk version: 1.25.0 output: location: rubygems package-name: your-package-name ``` #### Configure \`clientModuleName\` The `clientModuleName` option controls the name of the generated client. This is the name customers use to import your SDK (`import { your-client-name } from 'your-package-name';`). ```yaml {9-10} groups: ruby-sdk: generators: - name: fern-ruby-sdk version: 1.25.0 output: location: rubygems package-name: your-package-name config: clientModuleName: YourClientName # must be PascalCase ``` #### Add repository location Add the path to your GitHub repository to `generators.yml`: ```yaml {11-12} groups: ruby-sdk: generators: - name: fern-ruby-sdk version: 1.25.0 output: location: rubygems package-name: your-package-name config: clientModuleName: YourClientName github: repository: your-org/company-ruby ``` ## Set up RubyGems publishing authentication #### Log into RubyGems Log into [RubyGems](https://rubygems.org/) or create a new account. #### Navigate to Account settings 1. Click on your profile picture 2. Select **Settings**. 3. Scroll down and click on **API Keys**. #### Add New Key When prompted to [create a new API key](https://rubygems.org/profile/api_keys/new): 1. Name your key. 2. Under **Scopes**, select **Push rubygem** 3. Select `All Gems` under **Gem Scope**. #### Replacing an existing gem If you are overriding an existing gem, you can select the relevant package instead of entering `All Gems`. 1. Set an expiration date. 2. Click **Create API Key**. Save your new key – it won’t be displayed after you leave the page. ![Creating a New API Key](/learn/_fern-img/96a4e05d925b8e47bc26b72e876d40841a734e771c72d6e24b2f41a7a1a1088f.webp) #### Configure RubyGems authentication token Add `api-key: ${RUBYGEMS_API_KEY}` to `generators.yml` to tell Fern to use the `RUBYGEMS_API_KEY` environment variable for authentication when publishing to the PyPI registry. **`ruby`** ```yaml title="ruby" {9} groups: ruby-sdk: generators: - name: fern-ruby-sdk version: 1.25.0 output: location: rubygems package-name: your-package-name api-key: ${RUBYGEMS_API_KEY} config: clientModuleName: YourClientName github: repository: your-org/company-ruby ``` ## Release your SDK to RubyGems At this point, you're ready to generate a release for your SDK. #### Set RubyGems environment variable On your local machine, set the `RUBYGEMS_API_KEY` environment variable to the new API key you generated earlier: ```bash export RUBYGEMS_API_KEY=your-actual-rubygems-token ``` #### Generate your release Regenerate your SDK and publish it on RubyGems: ```bash fern generate --group ruby-sdk --version ``` Local machine output will verify that the release is pushed to your repository and tagged with the version you specified. Log back into RubyGems and navigate to **Releases** to see your new release. > Publish Ruby SDKs to RubyGems with Fern. Complete setup guide for package configuration, API key authentication, and versioned releases.