diff --git a/fern/products/sdks/overview/typescript/assets/sdk-release-action.png b/fern/products/sdks/overview/typescript/assets/sdk-release-action.png deleted file mode 100644 index da0edb898..000000000 Binary files a/fern/products/sdks/overview/typescript/assets/sdk-release-action.png and /dev/null differ diff --git a/fern/products/sdks/overview/typescript/assets/ts-sdk-release-action.png b/fern/products/sdks/overview/typescript/assets/ts-sdk-release-action.png new file mode 100644 index 000000000..a9ca9f3fb Binary files /dev/null and b/fern/products/sdks/overview/typescript/assets/ts-sdk-release-action.png differ diff --git a/fern/products/sdks/overview/typescript/publishing-to-npm.mdx b/fern/products/sdks/overview/typescript/publishing-to-npm.mdx index c06ccfc13..d99496dec 100644 --- a/fern/products/sdks/overview/typescript/publishing-to-npm.mdx +++ b/fern/products/sdks/overview/typescript/publishing-to-npm.mdx @@ -162,16 +162,17 @@ groups: -## Configure npm authentication +## Configure npm publication + +Choose how you want to authenticate and publish your SDK to npm. You can use GitHub workflows for automated releases or publish directly via the CLI. - + -Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) to automatically publish new SDK versions to npm when you push code changes. +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 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**. @@ -182,7 +183,6 @@ Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) You can also use the url `https://github.com//settings/secrets/actions`. - 1. Select **New repository secret**. @@ -195,43 +195,70 @@ Use [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) + - - - Change your workflow permissions to allow GitHub to run workflows: + 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**. - 1. Click on the **Settings** tab in your repository. - 1. Under the **Code and automation** section, navigate to **Actions** > **General**. - 1. Under **Actions permissions**, select **Allow all actions and reusable workflows**. - 1. **Save** your settings. Now GitHub can run the actions you configure. + + NPM_TOKEN secret + - - - Add `token: ${NPM_TOKEN}` to `generators.yml` to tell Fern to use the `NPM_TOKEN` environment variable (which you just configured in your GitHub repo) for authentication when publishing to the npm registry. - - ```yaml {9} - groups: - ts-sdk: - generators: - - name: fernapi/fern-typescript-sdk - version: - output: - location: npm - package-name: name-of-your-package - token: ${NPM_TOKEN} - config: - namespaceExport: YourClientName - github: - repository: your-org/your-repository + + + In your repo, navigate to **Actions**. Select **New workflow**, then **Set up workflow yourself**. Set up a workflow dispatch that is similar to this: + + ```yaml title=".github/workflows/publish.yml" maxLines=0 + name: Publish TypeScript SDK + + on: + workflow_dispatch: + inputs: + version: + description: "The version of the TypeScript SDK that you would like to release" + required: true + type: string + + jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install Fern CLI + run: npm install -g fern-api + + - name: Release TypeScript SDK + env: + FERN_TOKEN: ${{ secrets.FERN_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + fern generate --group ts-sdk --version ${{ inputs.version }} --log-level debug ``` + + - When you regenerate your release, Fern will automatically create a workflow in your repository called `.github/workflows/ci.yml` that will automatically publish your release to npm. For an example, see Vapi's [npm publishing GitHub Action](https://github.com/VapiAI/server-sdk-typescript/blob/main/.github/workflows/ci.yml) + Navigate to the **Actions** tab, select the workflow you just created, and + click **Run workflow**. + + + Running TS publish workflow + + + Once your workflow completes, log back into npm and + navigate to **Packages** to see your new release. + - + @@ -252,6 +279,8 @@ groups: github: repository: your-org/your-repository ``` + + When you regenerate your release, Fern will automatically create a workflow in your repository called `.github/workflows/ci.yml` that will automatically publish your release to npm. For an example, see Vapi's [npm publishing GitHub Action](https://github.com/VapiAI/server-sdk-typescript/blob/main/.github/workflows/ci.yml) @@ -262,19 +291,17 @@ groups: ``` - - - - + -## Release your SDK to npm - - Regenerate your SDK and publish it on npm: - ```bash fern generate --group ts-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 npm and - navigate to **Packages** to see your new release. \ No newline at end of file + navigate to **Packages** to see your new release. + + + + + diff --git a/fern/products/sdks/sdks.yml b/fern/products/sdks/sdks.yml index c771d7522..54ea5fe71 100644 --- a/fern/products/sdks/sdks.yml +++ b/fern/products/sdks/sdks.yml @@ -33,7 +33,7 @@ navigation: - page: Configuration path: ./overview/typescript/configuration.mdx slug: configuration - - page: Publishing to NPM + - page: Publishing to npm path: ./overview/typescript/publishing-to-npm.mdx slug: publishing - page: Adding custom code