diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 000000000..b52ec0a4e --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,28 @@ +# workflow for re-running publishing to NPM in case it fails for some reason +# you can run this workflow by navigating to https://www.github.com/openai/openai-node/actions/workflows/publish-npm.yml +name: Publish NPM +on: + workflow_dispatch: + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install dependencies + run: | + yarn install + + - name: Publish to NPM + run: | + bash ./bin/publish-npm + env: + NPM_TOKEN: ${{ secrets.OPENAI_NPM_TOKEN }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 000000000..a94615c37 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,23 @@ +name: Release Doctor +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + environment: publish + if: github.repository == 'openai/openai-node' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v3 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} + NPM_TOKEN: ${{ secrets.OPENAI_NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..229ad4975 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Release +on: + push: + branches: + - master + +jobs: + release: + name: release + if: github.ref == 'refs/heads/master' && github.repository == 'openai/openai-node' + runs-on: ubuntu-latest + environment: publish + + steps: + - uses: actions/checkout@v3 + + - uses: stainless-api/trigger-release-please@v1 + id: release + with: + repo: ${{ github.event.repository.full_name }} + stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} + + - name: Set up Node + if: ${{ steps.release.outputs.releases_created }} + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install dependencies + if: ${{ steps.release.outputs.releases_created }} + run: | + yarn install + + - name: Publish to NPM + if: ${{ steps.release.outputs.releases_created }} + run: | + bash ./bin/publish-npm + env: + NPM_TOKEN: ${{ secrets.OPENAI_NPM_TOKEN }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 000000000..411256bca --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "4.1.0" +} diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 000000000..759763247 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${STAINLESS_API_KEY}" ]; then + errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organisation secrets on GitHub.") +fi + +if [ -z "${NPM_TOKEN}" ]; then + errors+=("The OPENAI_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organisation secrets") +fi + +len=${#errors[@]} + +if [[ len -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/bin/publish-npm b/bin/publish-npm new file mode 100644 index 000000000..4d6c9f357 --- /dev/null +++ b/bin/publish-npm @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -eux + +npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN + +yarn build +cd dist +yarn publish --access public diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 000000000..04230db37 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,61 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "pull-request-header": "Automated Release PR", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "node", + "extra-files": ["src/version.ts"] +} diff --git a/src/_shims/fetch.d.ts b/src/_shims/fetch.d.ts index 79dcf074c..772a6d987 100644 --- a/src/_shims/fetch.d.ts +++ b/src/_shims/fetch.d.ts @@ -56,4 +56,5 @@ export type { _RequestInfo as RequestInfo, _ResponseType as ResponseType, _BodyInit as BodyInit, + _HeadersInit as HeadersInit, }; diff --git a/src/_shims/fetch.node.d.ts b/src/_shims/fetch.node.d.ts index 4a1bf5051..006f00da4 100644 --- a/src/_shims/fetch.node.d.ts +++ b/src/_shims/fetch.node.d.ts @@ -60,4 +60,5 @@ export type { _RequestInfo as RequestInfo, _ResponseType as ResponseType, _BodyInit as BodyInit, + _HeadersInit as HeadersInit, }; diff --git a/src/index.ts b/src/index.ts index 87553948a..6add24d69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -201,6 +201,8 @@ export namespace OpenAI { export import toFile = Uploads.toFile; export import fileFromPath = Uploads.fileFromPath; + export import RequestOptions = Core.RequestOptions; + export import Page = Pagination.Page; export import PageResponse = Pagination.PageResponse; diff --git a/src/resources/fine-tuning/jobs.ts b/src/resources/fine-tuning/jobs.ts index 7b05b8682..4fa64c85d 100644 --- a/src/resources/fine-tuning/jobs.ts +++ b/src/resources/fine-tuning/jobs.ts @@ -185,6 +185,8 @@ export namespace FineTuningJob { } export interface FineTuningJobEvent { + id: string; + created_at: number; level: 'info' | 'warn' | 'error'; diff --git a/src/version.ts b/src/version.ts index 610604428..be6bae1a8 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.1.0'; +export const VERSION = '4.1.0'; // x-release-please-version