diff --git a/fern/products/sdks/overview/ruby/assets/new-api-key.png b/fern/products/sdks/overview/ruby/assets/new-api-key.png new file mode 100644 index 000000000..65b1eb514 Binary files /dev/null and b/fern/products/sdks/overview/ruby/assets/new-api-key.png differ diff --git a/fern/products/sdks/overview/ruby/publishing-to-rubygems.mdx b/fern/products/sdks/overview/ruby/publishing-to-rubygems.mdx index 99acc1d67..48e83f1ea 100644 --- a/fern/products/sdks/overview/ruby/publishing-to-rubygems.mdx +++ b/fern/products/sdks/overview/ruby/publishing-to-rubygems.mdx @@ -3,6 +3,211 @@ title: Publishing to RubyGems description: How to publish the Fern Ruby SDK to RubyGems. --- -Learn how to publish your Fern Ruby SDK to the RubyGems registry. +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. -This page is a WIP, please refer to our previous [documentation](https://buildwithfern.com/learn/sdks/guides/publish-a-public-facing-sdk). +This guide assumes that you already have an initialized `fern` folder on your local machine. If you don’t, run `fern init`. See [Ruby Quickstart](quickstart.mdx) for more details. + +## Set up your GitHub integration + + 1. Create a new GitHub repository called `company-ruby` (or something similar) for your SDK, if you haven't done so already. + 1. Install the [Fern GitHub App](https://github.com/apps/fern-api): Select **Configure**, then scroll down to **Repository Access**. Select **Only select repositories** and in the dropdown select the repository for your SDK. Click **Save**. + + +## Configure `generators.yml` + + + + + + Navigate to your `generators.yml` on your local machine. Your `generators.yml` lives inside of your `fern` folder and contains all the configuration for your Fern generators. + + Add a new generator to `generators.yml`: + + + ```bash + fern add fern-ruby-sdk --group ruby-sdk + ``` + + Once the command completes, you'll see a new group created in your `generators.yml`: + + ```yaml {3-9} + groups: + ... + ruby-sdk: + generators: + - name: fernapi/fern-ruby-sdk + version: + output: + location: local-file-system + path: ../sdks/ruby + ``` + + + + + + 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: fernapi/fern-ruby-sdk + version: + output: + location: rubygems + + ``` + + + + + 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: fernapi/fern-ruby-sdk + version: + output: + location: rubygems + package-name: your-package-name +``` + + + + + The `clientClassName` 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: fernapi/fern-ruby-sdk + version: + output: + location: rubygems + package-name: your-package-name + config: + clientClassName: YourClientName # must be PascalCase +``` + + + + + + Add the path to your GitHub repository to `generators.yml`: + +```yaml {11-12} +groups: + ruby-sdk: + generators: + - name: fernapi/fern-ruby-sdk + version: + output: + location: rubygems + package-name: your-package-name + config: + clientClassName: YourClientName + github: + repository: your-org/company-ruby +``` + + + + +## Set up RubyGems publishing authentication + + + + + + Log into [RubyGems](https://rubygems.org/) or create a new account. + + + + + + 1. Click on your profile picture + 1. Select **Settings**. + 1. Scroll down and click on **API Keys**. + + + + + + When prompted to [create a new API key](https://rubygems.org/profile/api_keys/new): + 1. Name your key. + 1. Under **Scopes**, select **Push rubygem** + 1. Select `All Gems` under **Gem Scope**. + + If you are overriding an existing gem, you can select the relevant package instead of entering `All Gems`. + + 1. Set an expiration date. + 1. Click **Create API Key**. + + Save your new key – it won’t be displayed after you leave the page. + + + Creating a New API Key + + + + + + + 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. + +```yaml title="ruby" {9} +groups: + ruby-sdk: + generators: + - name: fernapi/fern-ruby-sdk + version: + output: + location: rubygems + package-name: your-package-name + api-key: ${RUBYGEMS_API_KEY} + config: + clientClassName: 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. + + + + + + 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 + ``` + + + + + + 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. + + + \ No newline at end of file