Skip to content

Commit c741494

Browse files
committed
Update instructions based on workflow testing. Remove GitHub actions information (for now)
1 parent fcc8566 commit c741494

File tree

1 file changed

+48
-86
lines changed

1 file changed

+48
-86
lines changed

fern/products/sdks/overview/typescript/publishing-to-npm.mdx

Lines changed: 48 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ description: How to publish the Fern Typescript SDK to npm.
55

66
Publish your public-facing Fern Typescript SDK to the [npm registry](https://www.npmjs.com/). Once you've followed the steps on this page to connect your npm account to your SDK, Fern will automatically publish the latest version of your SDK.
77

8-
<Info>This guide assumes that you've already generated a TypeScript SDK by following the instructions in [TypeScript Quickstart](quickstart.mdx).</Info>
8+
<Info>This guide assumes that you already have an initialized `fern` folder on your local machine. If you don’t, run `fern init`. See [TypeScript Quickstart](quickstart.mdx) for more details.</Info>
99

10-
## Configure your GitHub integration
10+
## Set up your GitHub integration
1111

1212
1. Create a new GitHub repository for your SDK, if you haven't done so already.
13-
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**.
14-
1. Add your TypeScript SDK files (`fern` and `sdks` folders) to your repository.
13+
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**.
14+
1. Add your SDK files to your repository.
1515

1616

1717
## Configure `generators.yml`
@@ -20,7 +20,7 @@ Publish your public-facing Fern Typescript SDK to the [npm registry](https://www
2020

2121
<Step title="Run `fern add <generator>`">
2222

23-
Navigate to your `generators.yml`. Your `generators.yml` lives inside of your `fern` folder and contains all the configuration for your Fern generators.
23+
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.
2424

2525
In order to generate the SDK, add the generator to your `generators.yml` using the `fern <add>` command:
2626

@@ -49,7 +49,7 @@ Publish your public-facing Fern Typescript SDK to the [npm registry](https://www
4949

5050
<Step title="Configure `output` location">
5151

52-
Next, change the output location in `generators.yml` to `npm`:
52+
Next, change the output location in `generators.yml` from `local-file-system` (the default) to `npm`:
5353

5454
```yaml title="TypeScript" {6-7}
5555
groups:
@@ -114,7 +114,7 @@ ts-sdk:
114114

115115
<Step title="Navigate to Access Tokens">
116116

117-
Click on your profile picture and select **Access Tokens**.
117+
Click on your profile picture, select **Edit Profile**, and then select **Access Tokens**.
118118

119119
</Step>
120120

@@ -129,12 +129,32 @@ ts-sdk:
129129
<img src="assets/npm-automation-token.png" alt="Creating NPM Automation Token" />
130130
</Frame>
131131

132-
<Warning>When you click **Generate Token**, you’ll be returned to the **Access Token** dashboard. A box on the top of the dashboard will confirm that your token creation was a success and prompt you to copy your token id. Make sure you save this id, as you'll need to add it to your GitHub repository in the later on.</Warning>
132+
<Warning>When you click **Generate Token**, you’ll be returned to the **Access Tokens** dashboard. A box on the top of the dashboard will confirm that you successfully created a new token and prompt you to copy your token id. Make sure you save this id, as you'll need to add it to your GitHub repository in the later on.</Warning>
133133

134134
</Step>
135+
136+
<Step title="Configure npm authentication token">
137+
138+
Add `token: ${NPM_TOKEN}` to `generators.yml` to tell Fern to use the `NPM_TOKEN` environment variable for authentication when publishing to the npm registry.
139+
140+
```yaml title="TypeScript" {9}
141+
groups:
142+
ts-sdk:
143+
generators:
144+
- name: fernapi/fern-typescript-node-sdk
145+
version: 0.9.5
146+
output:
147+
location: npm
148+
package-name: name-of-your-package
149+
token: ${NPM_TOKEN}
150+
github:
151+
repository: your-org/your-repository
152+
```
153+
</Step>
154+
135155
</Steps>
136156

137-
## Add NPM and Fern Tokens to your GitHub Tepository
157+
## Add npm Token to your GitHub Repository
138158

139159
<Info>
140160
Using GitLab? Follow [these steps](/learn/docs/developer-tools/gitlab#add-a-token-to-gitlab).
@@ -144,11 +164,11 @@ Using GitLab? Follow [these steps](/learn/docs/developer-tools/gitlab#add-a-toke
144164

145165
<Step title="Open Repository">
146166

147-
Open your Fern repository in GitHub.
167+
Open your repository in GitHub.
148168

149169
</Step>
150170

151-
<Step title="Navigate to Actions in Settings">
171+
<Step title="Add a Secret for your npm Token">
152172

153173
Click on the **Settings** tab in your repository. Then, under the **Security** section, open **Secrets and variables** > **Actions**.
154174

@@ -158,9 +178,6 @@ Using GitLab? Follow [these steps](/learn/docs/developer-tools/gitlab#add-a-toke
158178

159179
You can also use the url `https://github.com/<your-repo>/settings/secrets/actions`.
160180

161-
</Step>
162-
163-
<Step title="Add secret for your NPM Token">
164181

165182
1. Select **New repository secret**.
166183
1. Name your secret `NPM_TOKEN`.
@@ -169,88 +186,33 @@ Using GitLab? Follow [these steps](/learn/docs/developer-tools/gitlab#add-a-toke
169186

170187
</Step>
171188

172-
<Step title="Generate and Add Secret for your Fern Token">
173-
174-
1. Generate a Fern token by running `fern token` and saving the token id.
175-
1. Select **New repository secret**.
176-
1. Name your secret `FERN_TOKEN`.
177-
1. Add the corresponding token you generated above.
178-
1. Click **Add secret**.
179-
180-
</Step>
181-
182189
</Steps>
183190

184-
## Configure GitHub Actions
191+
## Release your SDK to NPM
192+
193+
At this point, you're ready to generate a release for your SDK.
185194

186195
<Steps>
187-
<Step title="Update Workflow Action Settings">
196+
197+
<Step title="Set npm environment variable">
188198

189-
Change your workflow permissions to allow GitHub to run workflows:
199+
Set the NPM_TOKEN environment variable on your local machine:
190200

191-
1. Click on the **Settings** tab in your repository.
192-
1. Navigate to **Actions**. Under **Actions permissions**, select **Allow all actions and reusable workflows**.
193-
1. **Save** your settings. Now GitHub can run the action you just configured.
201+
```bash
202+
export NPM_TOKEN=your-actual-npm-token
203+
```
194204

195205
</Step>
196-
<Step title="Set up a GitHub Action">
197-
198-
Add a GitHub Action to trigger releases for your SDK. Add a new file called `publish-typescript-sdk.yml` (or something similar) to a new `.github/workflows` directory. Your file should look like this:
199-
200-
201-
```yaml title="TypeScript" maxLines=0
202-
name: Publish TypeScript SDK
203-
204-
on:
205-
workflow_dispatch:
206-
inputs:
207-
version:
208-
description: "The version of the TypeScript SDK that you would like to release"
209-
required: true
210-
type: string
211-
212-
jobs:
213-
release:
214-
runs-on: ubuntu-latest
215-
steps:
216-
- name: Checkout repo
217-
uses: actions/checkout@v4
218-
219-
- name: Install Fern CLI
220-
run: npm install -g fern-api
221-
222-
- name: Release TypeScript SDK
223-
env:
224-
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
225-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
226-
run: |
227-
fern generate --group ts-sdk --version ${{ inputs.version }} --log-level debug
228-
```
229206

230-
The group name in the `run` command (`ts-sdk`) must match the name of your group in `generators.yml`:
231-
232-
```yaml {2}
233-
groups:
234-
ts-sdk:
235-
generators:
236-
- name: fernapi/fern-typescript-node-sdk
237-
version: 1.10.3
238-
output:
239-
location: npm
240-
package-name: name-of-your-package
241-
token: ${NPM_TOKEN}
242-
github:
243-
repository: your-org/your-repository
244-
```
245-
</Step>
246-
</Steps>
207+
<Step title="Generate your release">
247208

248-
## Release your SDK to NPM
209+
Run the following command to regenerate your SDK and publish it on npm:
249210

250-
At this point, you're ready to generate a release for your SDK. You can do this by either:
251-
* Running `fern generate --version <version>` to regenerate your SDK.
252-
* Manually triggering your SDK generation workflow from your GitHub repository by navigating to **Actions** and selecting your workflow. Once you initiate the workflow, you'll be prompted to enter the version number of your release.
211+
```bash
212+
fern generate --version <version>
213+
```
214+
Local machine output will verify that the release is pushed to your repository and tagged with the version you specified. You'll receive an email from npm notifying you that a new version of your package has been successfully published!
253215

254-
<img alt="GitHub Page" src="assets/sdk-release-action.png" />
216+
</Step>
255217

256-
When your workflow executes, you'll receive an email from npm notifying you that your SDK has been successfully published!
218+
</Steps>

0 commit comments

Comments
 (0)