Skip to content

Commit 33da9cf

Browse files
ci: setup automatic releases (#236)
1 parent ddb2815 commit 33da9cf

9 files changed

+188
-1
lines changed

.github/workflows/publish-npm.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# workflow for re-running publishing to NPM in case it fails for some reason
2+
# you can run this workflow by navigating to https://www.github.com/openai/openai-node/actions/workflows/publish-npm.yml
3+
name: Publish NPM
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
publish:
9+
name: publish
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Node
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: '16'
19+
20+
- name: Install dependencies
21+
run: |
22+
yarn install
23+
24+
- name: Publish to NPM
25+
run: |
26+
bash ./bin/publish-npm
27+
env:
28+
NPM_TOKEN: ${{ secrets.OPENAI_NPM_TOKEN }}

.github/workflows/release-doctor.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release Doctor
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release_doctor:
8+
name: release doctor
9+
runs-on: ubuntu-latest
10+
if: github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next'
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Check release environment
16+
run: |
17+
bash ./bin/check-release-environment
18+
env:
19+
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }}
20+
NPM_TOKEN: ${{ secrets.OPENAI_NPM_TOKEN }}

.github/workflows/release.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
release:
9+
name: release
10+
if: github.ref == 'refs/heads/main' && github.repository == 'openai/openai-node'
11+
runs-on: ubuntu-latest
12+
environment: publish
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- uses: stainless-api/trigger-release-please@v1
18+
id: release
19+
with:
20+
repo: ${{ github.event.repository.full_name }}
21+
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
22+
23+
- name: Set up Node
24+
if: ${{ steps.release.outputs.releases_created }}
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: '16'
28+
29+
- name: Install dependencies
30+
if: ${{ steps.release.outputs.releases_created }}
31+
run: |
32+
yarn install
33+
34+
- name: Publish to NPM
35+
if: ${{ steps.release.outputs.releases_created }}
36+
run: |
37+
bash ./bin/publish-npm
38+
env:
39+
NPM_TOKEN: ${{ secrets.OPENAI_NPM_TOKEN }}

.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "4.1.0"
3+
}

bin/check-release-environment

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
errors=()
4+
5+
if [ -z "${STAINLESS_API_KEY}" ]; then
6+
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.")
7+
fi
8+
9+
if [ -z "${NPM_TOKEN}" ]; then
10+
errors+=("The OPENAI_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organisation secrets")
11+
fi
12+
13+
len=${#errors[@]}
14+
15+
if [[ len -gt 0 ]]; then
16+
echo -e "Found the following errors in the release environment:\n"
17+
18+
for error in "${errors[@]}"; do
19+
echo -e "- $error\n"
20+
done
21+
22+
exit 1
23+
fi
24+
25+
echo "The environment is ready to push releases!"

bin/publish-npm

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
6+
7+
yarn build
8+
cd dist
9+
yarn publish --access public

release-please-config.json

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"packages": {
3+
".": {}
4+
},
5+
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
6+
"include-v-in-tag": true,
7+
"include-component-in-tag": false,
8+
"bump-minor-pre-major": true,
9+
"bump-patch-for-minor-pre-major": true,
10+
"pull-request-header": "Automated Release PR",
11+
"changelog-sections": [
12+
{
13+
"type": "feat",
14+
"section": "Features"
15+
},
16+
{
17+
"type": "fix",
18+
"section": "Bug Fixes"
19+
},
20+
{
21+
"type": "perf",
22+
"section": "Performance Improvements"
23+
},
24+
{
25+
"type": "revert",
26+
"section": "Reverts"
27+
},
28+
{
29+
"type": "chore",
30+
"section": "Chores"
31+
},
32+
{
33+
"type": "docs",
34+
"section": "Documentation"
35+
},
36+
{
37+
"type": "style",
38+
"section": "Styles"
39+
},
40+
{
41+
"type": "refactor",
42+
"section": "Refactors"
43+
},
44+
{
45+
"type": "test",
46+
"section": "Tests",
47+
"hidden": true
48+
},
49+
{
50+
"type": "build",
51+
"section": "Build System"
52+
},
53+
{
54+
"type": "ci",
55+
"section": "Continuous Integration",
56+
"hidden": true
57+
}
58+
],
59+
"release-type": "node",
60+
"extra-files": ["src/version.ts"]
61+
}

src/resources/fine-tuning/jobs.ts

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ export namespace FineTuningJob {
185185
}
186186

187187
export interface FineTuningJobEvent {
188+
id: string;
189+
188190
created_at: number;
189191

190192
level: 'info' | 'warn' | 'error';

src/version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = '4.1.0';
1+
export const VERSION = '4.1.0'; // x-release-please-version

0 commit comments

Comments
 (0)