diff --git a/examples/typescript-sdk/generators.yml b/examples/sdks/generators.yml similarity index 61% rename from examples/typescript-sdk/generators.yml rename to examples/sdks/generators.yml index d66d8397a..cbe6301d4 100644 --- a/examples/typescript-sdk/generators.yml +++ b/examples/sdks/generators.yml @@ -22,4 +22,17 @@ groups: namespaceExport: YourClientName github: repository: your-company/ts-sdk - # generator groups for other SDKs go here \ No newline at end of file + # This group configures a Python SDK for PyPi publishing + python-sdk: + generators: + - name: fernapi/fern-python-sdk + version: 4.28.0 + output: + location: pypi + package-name: devin-new-test-package + token: ${PYPI_TOKEN} + config: + client_class_name: MyClientNameDevin + github: + repository: devalog/company-python-test + # generator groups for other SDKs go here diff --git a/examples/sdks/python-publish.yml b/examples/sdks/python-publish.yml new file mode 100644 index 000000000..00fa3b112 --- /dev/null +++ b/examples/sdks/python-publish.yml @@ -0,0 +1,26 @@ +name: Publish Python SDK + +on: + workflow_dispatch: + inputs: + version: + description: "The version of the Python 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 Python SDK + env: + FERN_TOKEN: ${{ secrets.FERN_TOKEN }} + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + fern generate --group python-sdk --version ${{ inputs.version }} --log-level debug \ No newline at end of file diff --git a/examples/typescript-sdk/typescript-publish.yml b/examples/sdks/typescript-publish.yml similarity index 100% rename from examples/typescript-sdk/typescript-publish.yml rename to examples/sdks/typescript-publish.yml diff --git a/fern/products/sdks/overview/python/assets/github-secret.png b/fern/products/sdks/overview/python/assets/github-secret.png new file mode 100644 index 000000000..30d4b7225 Binary files /dev/null and b/fern/products/sdks/overview/python/assets/github-secret.png differ diff --git a/fern/products/sdks/overview/python/assets/pypi-token-secret.png b/fern/products/sdks/overview/python/assets/pypi-token-secret.png new file mode 100644 index 000000000..46526d5e3 Binary files /dev/null and b/fern/products/sdks/overview/python/assets/pypi-token-secret.png differ diff --git a/fern/products/sdks/overview/python/assets/python-sdk-release-action.png b/fern/products/sdks/overview/python/assets/python-sdk-release-action.png new file mode 100644 index 000000000..e496b6069 Binary files /dev/null and b/fern/products/sdks/overview/python/assets/python-sdk-release-action.png differ diff --git a/fern/products/sdks/overview/python/publishing-to-pypi.mdx b/fern/products/sdks/overview/python/publishing-to-pypi.mdx index 8c4043a4a..3f3b05028 100644 --- a/fern/products/sdks/overview/python/publishing-to-pypi.mdx +++ b/fern/products/sdks/overview/python/publishing-to-pypi.mdx @@ -125,11 +125,55 @@ 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. +## 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. + + + + + 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 + + + + -```yaml title="Python" {9} + 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 `token: ${PYPI_TOKEN}` to `generators.yml`. + + ```yaml {9} title="generators.yml" groups: python-sdk: generators: @@ -143,20 +187,86 @@ groups: client_class_name: YourClientName github: repository: your-org/company-python -``` + ``` + + + 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 + + on: + workflow_dispatch: + inputs: + version: + description: "The version of the Python 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 Python SDK + env: + FERN_TOKEN: ${{ secrets.FERN_TOKEN }} + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + fern generate --group python-sdk --version ${{ inputs.version }} --log-level debug + ``` - + -## Release your SDK to PyPI + - At this point, you're ready to generate a release for your SDK. + 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. + + Running Python publish workflow + + + Once your workflow completes, log back into PyPi and navigate to **Packages** to see your new release. + + + + + + + + + + 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 + ``` + - On your local machine, set the `PYPI_TOKEN` environment variable to the new API token you generated earlier: + Set the `PYPI_TOKEN` environment variable on your local machine: ```bash export PYPI_TOKEN=your-actual-pypi-token @@ -176,4 +286,6 @@ groups: navigate to **Your projects** to see your new release. - \ No newline at end of file + + + \ No newline at end of file