You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* An initialized `fern` folder. See [Set up the `fern`
19
+
folder](/sdks/overview/quickstart).
20
+
* A GitHub repository for your C#/.NET SDK. See [Project structure](/sdks/overview/project-structure).
21
+
* A C#/.NET generator group in `generators.yml`. See [C#/.NET
22
+
Quickstart](quickstart#add-the-sdk-generator).
18
23
19
-
<Steps>
24
+
</Info>
20
25
21
-
<Steptitle="Configure `output` location">
26
+
## Configure SDK package settings
22
27
23
-
Next, change the output location in `generators.yml`from `local-file-system` (the default) to `nuget` to indicate that Fern should publish your package directly to the NuGet registry:
28
+
You'll need to update your `generators.yml` file to configure the package name, output location, and client name for NuGet 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 C#/.NET SDK code.
In the `group` for your C#/.NET SDK, change the output location from `local-file-system` (the default) to `nuget` to indicate that Fern should publish your package directly to the npm registry:
37
34
38
-
Your package name must be unique in the NuGet repository, otherwise publishing your SDK to NuGet will fail. Update your package name if you haven't done so already:
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';`).
60
+
</Step>
61
+
<Steptitle="Configure `client-class-name`">
56
62
63
+
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';`).
57
64
58
-
```yaml {9-10}
65
+
```yaml {9-10} title="generators.yml"
59
66
groups:
60
67
csharp-sdk:
61
68
generators:
@@ -67,14 +74,51 @@ groups:
67
74
config:
68
75
client_class_name: YourClientName # must be PascalCase
69
76
```
70
-
71
-
</Step>
77
+
</Step>
78
+
</Steps>
72
79
73
-
<Step title="Add repository location">
80
+
## Generate a NuGet API key
81
+
82
+
<Steps>
83
+
84
+
<Step title="Log into NuGet">
85
+
86
+
Log into [NuGet](https://nuget.org/) or create a new account.
87
+
88
+
</Step>
89
+
90
+
<Step title="Add New Key">
91
+
92
+
1. Click on your profile picture.
93
+
1. Select **API Keys**, then **Create**.
94
+
1. Name your key.
95
+
1. Select **Push > Push new packages and package versions** as the **Select Scopes** type.
96
+
1. Enter `*` under **Select Packages > Glob Patten**.
97
+
98
+
<Tip title="Replacing an existing NuGet package">
99
+
If you are overriding an existing package, you can select the relevant
100
+
package instead of entering `*`.
101
+
</Tip>
102
+
1. Click **Create**.
103
+
104
+
<Frame>
105
+
<img src="assets/new-api-key.png" alt="Creating a New API Key" />
106
+
</Frame>
74
107
75
-
Add the path to your GitHub repository to `generators.yml`:
108
+
<Warning>Save your new key – it won’t be displayed after you leave the page.</Warning>
76
109
77
-
```yaml {11-12}
110
+
</Step>
111
+
112
+
</Steps>
113
+
114
+
## Configure NuGet publication
115
+
116
+
<Steps>
117
+
<Step title="Add repository location">
118
+
119
+
Add the path to the GitHub repository containing your C#/.NET SDK:
120
+
121
+
```yaml title="generators.yml" {11-12}
78
122
groups:
79
123
csharp-sdk:
80
124
generators:
@@ -87,48 +131,33 @@ groups:
87
131
client_class_name: YourClientName
88
132
github:
89
133
repository: your-org/company-csharp
90
-
```
91
-
92
-
</Step>
93
-
</Steps>
94
-
95
-
## Set up NuGet publishing authentication
96
-
97
-
<Steps>
98
-
99
-
<Step title="Log into NuGet">
100
-
101
-
Log into [NuGet](https://nuget.org/) or create a new account.
102
-
103
-
</Step>
104
-
105
-
<Step title="Add New Key">
134
+
```
135
+
</Step>
136
+
<Step title="Configure NuGet authentication key">
106
137
107
-
1. Click on your profile picture.
108
-
1. Select **API Keys**, then **Create**.
109
-
1. Name your key.
110
-
1. Select **Push > Push new packages and package versions** as the **Select Scopes** type.
111
-
1. Enter `*` under **Select Packages > Glob Patten**.
112
-
113
-
<Tip title="Replacing an existing NuGet package">
114
-
If you are overriding an existing package, you can select the relevant
115
-
package instead of entering `*`.
116
-
</Tip>
117
-
1. Click **Create**.
138
+
Add `api-key: ${NUGET_API_KEY}` to `generators.yml` to tell Fern to use the `NUGET_API_KEY` environment variable for authentication when publishing to the NuGet registry.
118
139
119
-
<Frame>
120
-
<img src="assets/new-api-key.png" alt="Creating a New API Key" />
121
-
</Frame>
122
-
123
-
<Warning>Save your new key – it won’t be displayed after you leave the page.</Warning>
Add `api-key: ${NUGET_API_KEY}` to `generators.yml` to tell Fern to use the `NUGET_API_KEY` environment variable for authentication when publishing to the NuGet registry.
branch: your-branch-name # Required for mode: push
145
176
```
146
-
</Step>
147
177
178
+
</Step>
148
179
</Steps>
149
180
150
-
## Release your SDK to NuGet
181
+
## Publish your SDK
182
+
183
+
Decide how you want to publish your SDK to NuGet. You can use GitHub workflows for automated releases or publish directly via the CLI.
184
+
185
+
<AccordionGroup>
186
+
187
+
<Accordion title="Release via a GitHub workflow">
151
188
152
-
At this point, you're ready to generate a release for your SDK.
189
+
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.
153
190
154
191
<Steps>
192
+
<Step title="Set up authentication">
155
193
156
-
<Step title="Set NuGet environment variable">
194
+
Open your source repository in GitHub. Click on the **Settings** tab. Then, under the **Security** section, open **Secrets and variables** > **Actions**.
157
195
158
-
On your local machine, set the `NUGET_API_KEY` environment variable to the new API key you generated earlier:
196
+
You can also use the url `https://github.com/<your-repo>/settings/secrets/actions`.
197
+
198
+
</Step>
199
+
<Step title="Add secret for your NuGet API key">
200
+
201
+
1. Select **New repository secret**.
202
+
1. Name your secret `NUGET_API_KEY`.
203
+
1. Add the corresponding API key you generated above.
1. Add your Fern token. If you don't already have one, generate one by
216
+
running `fern token`. By default, the `fern_token` is generated for the
217
+
organization listed in `fern.config.json`.
218
+
1. Click **Add secret**.
219
+
220
+
</Step>
221
+
<Step title="Set up a new workflow">
222
+
223
+
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:
You can alternatively configure your workflow to execute `on: [push]`. See Vapi's [npm publishing GitHub Action](https://github.com/VapiAI/server-sdk-typescript/blob/main/.github/workflows/ci.yml) for an example.
255
+
</Note>
256
+
</Step>
163
257
164
-
</Step>
258
+
<Step title="Regenerate and release your SDK">
165
259
166
-
<Step title="Generate your release">
260
+
Navigate to the **Actions** tab, select the workflow you just created, specify a version number, and click **Run workflow**. This regenerates your SDK.
Copy file name to clipboardExpand all lines: fern/products/sdks/overview/typescript/publishing-to-npm.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ You'll need to update your `generators.yml` file to configure the package name,
29
29
<Steps>
30
30
<Steptitle="Configure `output` location">
31
31
32
-
In the `group` for your TypeScript SDK, change the output location in from `local-file-system` (the default) to `npm` to indicate that Fern should publish your package directly to the npm registry:
32
+
In the `group` for your TypeScript SDK, change the output location from `local-file-system` (the default) to `npm` to indicate that Fern should publish your package directly to the npm registry:
33
33
34
34
```yaml {6-7} title="generators.yml"
35
35
groups:
@@ -222,7 +222,7 @@ Set up a release workflow via [GitHub Actions](https://docs.github.com/en/action
222
222
<Steps>
223
223
<Steptitle="Set up authentication">
224
224
225
-
Open your Fern repository in GitHub. Click on the **Settings** tab in your repository. Then, under the **Security** section, open **Secrets and variables** > **Actions**.
225
+
Open your source repository in GitHub. Click on the **Settings** tab. Then, under the **Security** section, open **Secrets and variables** > **Actions**.
0 commit comments