|
1 | 1 | --- |
2 | | -title: Publishing to Go Package Manager |
3 | | -description: How to publish the Fern Go SDK to NPM. |
| 2 | +title: Publishing to Pkgsite |
| 3 | +description: How to publish the Fern Go SDK to Pkgsite. |
4 | 4 | --- |
5 | 5 |
|
6 | | -Learn how to publish your Fern Go SDK to the NPM registry. |
| 6 | +Publish your public-facing Fern GO SDK to the [Pkgsite |
| 7 | +registry](https://pkg.go.dev/). After following the steps on this page, |
| 8 | +you'll have a versioned package published on Pkgsite. |
7 | 9 |
|
8 | | -<Warning>This page is a WIP, please refer to our previous [documentation](https://buildwithfern.com/learn/sdks/guides/publish-a-public-facing-sdk).</Warning> |
| 10 | +<Frame> |
| 11 | + <img src="assets/go-package.png" alt="Versioned package published on Pkgsite" /> |
| 12 | +</Frame> |
9 | 13 |
|
| 14 | +<Info>This guide assumes that you already have an initialized `fern` folder on your local machine. If you don’t, run `fern init`. See [Go Quickstart](quickstart.mdx) for more details.</Info> |
| 15 | + |
| 16 | + |
| 17 | +## Set up your GitHub integration |
| 18 | + |
| 19 | + 1. Create a new GitHub repository called `company-go` (or something similar) for your SDK, if you haven't done so already. Make sure your repository has: |
| 20 | + * **Public** visibility |
| 21 | + * A required license (e.g. [MIT](https://opensource.org/license/mit), [Apache](https://www.apache.org/licenses/LICENSE-2.0)) to the repository. |
| 22 | + 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**. |
| 23 | + |
| 24 | + |
| 25 | +## Configure `generators.yml` |
| 26 | + |
| 27 | +<Steps> |
| 28 | + |
| 29 | + <Step title="Run `fern add <generator>`"> |
| 30 | + |
| 31 | + 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. |
| 32 | + |
| 33 | + Add a new generator to `generators.yml`: |
| 34 | + |
| 35 | + |
| 36 | + ```bash |
| 37 | + fern add fern-go-sdk --group go-sdk |
| 38 | + ``` |
| 39 | + |
| 40 | + Once the command completes, you'll see a new group created in your `generators.yml`: |
| 41 | + |
| 42 | + ```yaml {2-11} |
| 43 | + groups: |
| 44 | + go-sdk: |
| 45 | + generators: |
| 46 | + - name: fernapi/fern-go-sdk |
| 47 | + version: <Markdown src="/snippets/version-number.mdx"/> |
| 48 | + output: |
| 49 | + location: local-file-system |
| 50 | + path: ../sdks/go |
| 51 | + config: |
| 52 | + module: |
| 53 | + path: sdk |
| 54 | + ``` |
| 55 | +
|
| 56 | + </Step> |
| 57 | +
|
| 58 | + <Step title="Configure `output` location"> |
| 59 | + |
| 60 | + Go publishes via Git repositories, so remove the auto-generated |
| 61 | + `output` and `config` properties. Instead, add the path to your |
| 62 | + GitHub repository: |
| 63 | + |
| 64 | + ```yaml {6-7} |
| 65 | + groups: |
| 66 | + go-sdk: |
| 67 | + generators: |
| 68 | + - name: fernapi/fern-go-sdk |
| 69 | + version: <Markdown src="/snippets/version-number.mdx"/> |
| 70 | + github: |
| 71 | + repository: devalog/company-go |
| 72 | +
|
| 73 | + ``` |
| 74 | + </Step> |
| 75 | + |
| 76 | + </Steps> |
| 77 | + |
| 78 | + |
| 79 | +## Release your SDK to Pkgsite |
| 80 | + |
| 81 | + At this point, you're ready to generate a release for your SDK. |
| 82 | + |
| 83 | +<Steps> |
| 84 | + |
| 85 | + <Step title="Generate your release"> |
| 86 | + |
| 87 | + Regenerate your SDK and publish it on PyPI: |
| 88 | + |
| 89 | + ```bash |
| 90 | + fern generate --group go-sdk --version <version> |
| 91 | + ``` |
| 92 | + Local machine output will verify that the release is pushed to your |
| 93 | + repository and tagged with the version you specified. |
| 94 | + |
| 95 | + </Step> |
| 96 | + |
| 97 | + <Step title="Publish on Pkgsite"> |
| 98 | + |
| 99 | + Navigate to `https://pkg.go.dev/github.com/<github-org>/<github-repo-name>/` and send a request to index your package. In a few minutes, your new release should be published to [https://pkg.go.dev/](https://pkg.go.dev/)! |
| 100 | + |
| 101 | + <Tip>After releasing a new version, it may take a few minutes for Pkgsite |
| 102 | + to index and display the update. You can also try checking to see if the Go |
| 103 | + proxy has indexed your module at |
| 104 | + `https://proxy.golang.org/github.com/<github-org>/<github-repo-name>/@v/list`. Pkgsite |
| 105 | + indexing usually happens within 5-15 min of the proxy picking it up. For |
| 106 | + more information, see Go's documentation on [Adding a |
| 107 | + package](https://pkg.go.dev/about#adding-a-package). </Tip> |
| 108 | + |
| 109 | + </Step> |
| 110 | + |
| 111 | +</Steps> |
0 commit comments