From 842b047a58988f1069a6ed3cf920f3a821369106 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Wed, 10 Sep 2025 10:48:48 -0400 Subject: [PATCH 1/3] add info on mode, restructure pypi doc --- .../overview/python/publishing-to-pypi.mdx | 227 ++++++++++-------- .../overview/typescript/publishing-to-npm.mdx | 12 +- .../sdks/snippets/github-publishing-mode.mdx | 7 + 3 files changed, 137 insertions(+), 109 deletions(-) create mode 100644 fern/products/sdks/snippets/github-publishing-mode.mdx diff --git a/fern/products/sdks/overview/python/publishing-to-pypi.mdx b/fern/products/sdks/overview/python/publishing-to-pypi.mdx index 3f3b05028..2dcaec63b 100644 --- a/fern/products/sdks/overview/python/publishing-to-pypi.mdx +++ b/fern/products/sdks/overview/python/publishing-to-pypi.mdx @@ -11,15 +11,26 @@ you'll have a versioned package published on PyPI. Versioned package published on PyPI - + + This page assumes that you have: -## Configure `generators.yml` + * An initialized `fern` folder. See [Set up the `fern` + folder](/sdks/overview/quickstart). + * A GitHub repository for your Python SDK. See [Project structure](/sdks/overview/project-structure). + * A Python generator group in `generators.yml`. See [Python + Quickstart](quickstart#add-the-sdk-generator). + + + +## Configure SDK package settings + +You'll need to update your `generators.yml` file to configure the package name, output location, and client naming for PyPi publishing. Your `generators.yml` [should live in your source repository](/sdks/overview/project-structure) (or on your local machine), not the repository that contains your Python SDK code. - 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: + In the `group` for your Python SDK, change the output location in from `local-file-system` (the default) to `pypi` to indicate that Fern should publish your package directly to the PyPi registry: ```yaml title="Python" {6-7} groups: @@ -35,7 +46,7 @@ you'll have a versioned package published on PyPI. - Your package name must be unique in the PyPI repository, otherwise publishing your SDK to PyPI will fail. Update your package name if you haven't done so already: + Your package name must be unique in the PyPI repository, otherwise publishing your SDK to PyPI will fail. ```yaml title="Python" {8} @@ -70,30 +81,9 @@ groups: ``` - - - - Add the path to your GitHub repository to `generators.yml`: - -```yaml title="Python" {11-12} -groups: - python-sdk: - generators: - - name: fernapi/fern-python-sdk - version: - output: - location: pypi - package-name: your-package-name - config: - client_class_name: YourClientName - github: - repository: your-org/company-python -``` - - -## Set up PyPi publishing authentication +## Generate a PyPi token @@ -127,53 +117,34 @@ groups: -## Release your SDK to PyPI - - At this point, you're ready to generate a release for your SDK. - - - -Set up a release workflow via [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) so you can trigger new SDK releases directly from your source repository. +## Configure PyPi publication - - - Open your Fern repository in GitHub. Click on the **Settings** tab in your repository. Then, under the **Security** section, open **Secrets and variables** > **Actions**. - - - Adding GitHub Repository Secret - - - You can also use the url `https://github.com//settings/secrets/actions`. - - - - - 1. Select **New repository secret**. - 1. Name your secret `PYPI_TOKEN`. - 1. Add the corresponding token you generated above. - 1. Click **Add secret**. - - - PYPI_TOKEN secret - - - - + - 1. Select **New repository secret**. - 1. Name your secret `FERN_TOKEN`. - 1. Add your Fern token. If you don't already have one, generate one by - running `fern token`. By default, the `fern_token` is generated for the - organization listed in `fern.config.json`. - 1. Click **Add secret**. +Add the path to your GitHub repository to `generators.yml`: - - +```yaml title="Python" {11-12} +groups: + python-sdk: + generators: + - name: fernapi/fern-python-sdk + version: + output: + location: pypi + package-name: your-package-name + config: + client_class_name: YourClientName + github: + repository: your-org/company-python +``` + + + - Add `token: ${PYPI_TOKEN}` to `generators.yml`. +Add `token: ${PYPI_TOKEN}` to `generators.yml`. - ```yaml {9} title="generators.yml" +```yaml {9} title="generators.yml" groups: python-sdk: generators: @@ -187,11 +158,82 @@ groups: client_class_name: YourClientName github: repository: your-org/company-python - ``` - - +``` + + + + + +```yaml title="generators.yml" {14} +groups: + python-sdk: + generators: + - name: fernapi/fern-python-sdk + version: + output: + location: npm + package-name: name-of-your-package + token: ${PYPI_TOKEN} + config: + namespaceExport: YourClientName + github: + repository: your-org/your-repository + mode: push + branch: your-branch-name # Required for mode: push +``` + + + + + +## Publish your SDK + +Decide how you want to publish your SDK to PyPi. You can use GitHub workflows for automated releases or publish directly via the CLI. + + + + +Set up a release workflow via [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) so you can trigger new SDK releases directly from your source repository. + + + + + +Open your Fern repository in GitHub. Click on the **Settings** tab in your repository. Then, under the **Security** section, open **Secrets and variables** > **Actions**. + + +Adding GitHub Repository Secret + + +You can also use the url `https://github.com//settings/secrets/actions`. + + + + +1. Select **New repository secret**. +1. Name your secret `PYPI_TOKEN`. +1. Add the corresponding token you generated above. +1. Click **Add secret**. + + +PYPI_TOKEN secret + + + + + +1. Select **New repository secret**. +1. Name your secret `FERN_TOKEN`. +1. Add your Fern token. If you don't already have one, generate one by + running `fern token`. By default, the `fern_token` is generated for the + organization listed in `fern.config.json`. +1. Click **Add secret**. + + + + - Set up a CI workflow that you can manually trigger from the GitHub UI. In your repository, navigate to **Actions**. Select **New workflow**, then **Set up workflow yourself**. Add a workflow that's similar to this: +Set up a CI workflow that you can manually trigger from the GitHub UI. In your repository, navigate to **Actions**. Select **New workflow**, then **Set up workflow yourself**. Add a workflow that's similar to this: ```yaml title=".github/workflows/publish.yml" maxLines=0 name: Publish Python SDK @@ -222,19 +264,19 @@ groups: fern generate --group python-sdk --version ${{ inputs.version }} --log-level debug ``` - + - + - Navigate to the **Actions** tab, select the workflow you just created, specify a version number, and click **Run workflow**. - - This regenerates your SDK, tags the new release with the version number you specified, and initiates a Fern-generated publishing workflow in your Python SDK repository that publishes your release to PyPi. + Navigate to the **Actions** tab, select the workflow you just created, specify a version number, and click **Run workflow**. This regenerates your SDK. Running Python publish workflow - Once your workflow completes, log back into PyPi and navigate to **Packages** to see your new release. + + + Once the workflow completes, you can view your new release by logging into PyPi and navigating to **Your projects**. @@ -242,27 +284,6 @@ groups: - - - - Add `token: ${PYPI_TOKEN}` to `generators.yml` to tell Fern to use the `PYPI_TOKEN` environment variable for authentication when publishing to the PyPI registry. - - ```yaml title="Python" {9} - groups: - python-sdk: - generators: - - name: fernapi/fern-python-sdk - version: - output: - location: pypi - package-name: your-package-name - token: ${PYPI_TOKEN} - config: - client_class_name: YourClientName - github: - repository: your-org/company-python - ``` - @@ -274,16 +295,16 @@ groups: - + - Regenerate your SDK and publish it on PyPI: + Regenerate your SDK, specifying the version: ```bash fern generate --group python-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 PyPI and - navigate to **Your projects** to see your new release. + + + Once the workflow completes, you can view your new release by logging into PyPi and navigating to **Your projects**. diff --git a/fern/products/sdks/overview/typescript/publishing-to-npm.mdx b/fern/products/sdks/overview/typescript/publishing-to-npm.mdx index 010be1e37..af2c89c8e 100644 --- a/fern/products/sdks/overview/typescript/publishing-to-npm.mdx +++ b/fern/products/sdks/overview/typescript/publishing-to-npm.mdx @@ -186,11 +186,7 @@ groups: -Optionally set the mode to control how Fern handles SDK publishing: - -- `mode: release` (default): Fern generates code, commits to main, and tags a release automatically -- `mode: pull-request`: Fern generates code and creates a PR for you to review before release -- `mode: push`: Fern generates code and pushes to a branch you specify for you to review before release + ```yaml title="generators.yml" {14} groups: @@ -209,7 +205,6 @@ groups: mode: push branch: your-branch-name # Required for mode: push ``` -You can also configure other settings, like the reviewers or license. Refer to the [full `github` (`generators.yml`) reference](/sdks/reference/generators-yml#github) for more information. @@ -304,6 +299,8 @@ Set up a release workflow via [GitHub Actions](https://docs.github.com/en/action + + Once the workflow completes, you can view your new release by logging into npm and navigating to **Packages**. @@ -332,6 +329,9 @@ fern generate --group ts-sdk --version ``` + +Once the workflow completes, you can view your new release by logging into npm and navigating to **Packages**. + diff --git a/fern/products/sdks/snippets/github-publishing-mode.mdx b/fern/products/sdks/snippets/github-publishing-mode.mdx new file mode 100644 index 000000000..fcc863acb --- /dev/null +++ b/fern/products/sdks/snippets/github-publishing-mode.mdx @@ -0,0 +1,7 @@ +Optionally set the mode to control how Fern handles SDK publishing: + +- `mode: release` (default): Fern generates code, commits to main, and tags a release automatically +- `mode: pull-request`: Fern generates code and creates a PR for you to review before release +- `mode: push`: Fern generates code and pushes to a branch you specify for you to review before release + +You can also configure other settings, like the reviewers or license. Refer to the [full `github` (`generators.yml`) reference](/sdks/reference/generators-yml#github) for more information. \ No newline at end of file From b38819a7198722ecf2e0a2f413f4a5f0b8fd69dd Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Wed, 10 Sep 2025 11:53:52 -0400 Subject: [PATCH 2/3] fix links --- .../sdks/overview/python/publishing-to-pypi.mdx | 13 ++++++------- .../sdks/overview/typescript/publishing-to-npm.mdx | 2 +- fern/products/sdks/snippets/release-sdk.mdx | 4 +--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/fern/products/sdks/overview/python/publishing-to-pypi.mdx b/fern/products/sdks/overview/python/publishing-to-pypi.mdx index 2dcaec63b..6ccb9f1c0 100644 --- a/fern/products/sdks/overview/python/publishing-to-pypi.mdx +++ b/fern/products/sdks/overview/python/publishing-to-pypi.mdx @@ -32,7 +32,7 @@ You'll need to update your `generators.yml` file to configure the package name, In the `group` for your Python SDK, change the output location in from `local-file-system` (the default) to `pypi` to indicate that Fern should publish your package directly to the PyPi registry: - ```yaml title="Python" {6-7} + ```yaml title="generators.yml" {6-7} groups: python-sdk: generators: @@ -49,7 +49,7 @@ You'll need to update your `generators.yml` file to configure the package name, Your package name must be unique in the PyPI repository, otherwise publishing your SDK to PyPI will fail. -```yaml title="Python" {8} +```yaml title="generators.yml" {8} groups: python-sdk: generators: @@ -67,7 +67,7 @@ groups: The `client-class-name` 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 title="Python" {9-10} +```yaml title="generators.yml" {9-10} groups: python-sdk: generators: @@ -124,7 +124,7 @@ groups: Add the path to your GitHub repository to `generators.yml`: -```yaml title="Python" {11-12} +```yaml title="generators.yml" {11-12} groups: python-sdk: generators: @@ -162,14 +162,14 @@ groups: - + ```yaml title="generators.yml" {14} groups: python-sdk: generators: - name: fernapi/fern-python-sdk - version: + version: output: location: npm package-name: name-of-your-package @@ -182,7 +182,6 @@ groups: branch: your-branch-name # Required for mode: push ``` - diff --git a/fern/products/sdks/overview/typescript/publishing-to-npm.mdx b/fern/products/sdks/overview/typescript/publishing-to-npm.mdx index af2c89c8e..99ab3ed02 100644 --- a/fern/products/sdks/overview/typescript/publishing-to-npm.mdx +++ b/fern/products/sdks/overview/typescript/publishing-to-npm.mdx @@ -186,7 +186,7 @@ groups: - + ```yaml title="generators.yml" {14} groups: diff --git a/fern/products/sdks/snippets/release-sdk.mdx b/fern/products/sdks/snippets/release-sdk.mdx index 3f046ad61..db9e693af 100644 --- a/fern/products/sdks/snippets/release-sdk.mdx +++ b/fern/products/sdks/snippets/release-sdk.mdx @@ -2,6 +2,4 @@ The rest of the release process depends on your chosen mode: - **Release mode (default):** If you didn't specify a `mode` or set `mode: release`, no further action is required. Fern automatically tags the new release with your specified version number and initiates the npm publishing workflow in your SDK repository. -- **Pull request or push mode:** If you set `mode: pull-request` or `mode: push`, Fern creates a pull request or pushes to a branch respectively. Review and merge the PR (`pull-request`) or branch (`push`), then [tag a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) to initiate the npm publishing workflow in your SDK repository. - -Once the workflow completes, you can view your new release by logging into npm and navigating to **Packages**. \ No newline at end of file +- **Pull request or push mode:** If you set `mode: pull-request` or `mode: push`, Fern creates a pull request or pushes to a branch respectively. Review and merge the PR (`pull-request`) or branch (`push`), then [tag a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) to initiate the npm publishing workflow in your SDK repository. \ No newline at end of file From bef26ac04927adc010ee7eaeadd39e8d1470264f Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Wed, 10 Sep 2025 11:59:45 -0400 Subject: [PATCH 3/3] add mode to example generators file --- examples/sdks/generators.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/sdks/generators.yml b/examples/sdks/generators.yml index cbe6301d4..cc82a861e 100644 --- a/examples/sdks/generators.yml +++ b/examples/sdks/generators.yml @@ -22,6 +22,8 @@ groups: namespaceExport: YourClientName github: repository: your-company/ts-sdk + mode: push + branch: your-branch-name # This group configures a Python SDK for PyPi publishing python-sdk: generators: @@ -35,4 +37,5 @@ groups: client_class_name: MyClientNameDevin github: repository: devalog/company-python-test + mode: pull-request # generator groups for other SDKs go here