Skip to content

Commit

Permalink
fix: support PromiseLike input to toFile
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and rattrayalex committed Jul 10, 2023
1 parent 56a17b7 commit 1d5f87d
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Doctor
on:
pull_request:
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: 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 }}
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
push:
branches:
- main

jobs:
release:
name: release
if: github.ref == 'refs/heads/main' && github.repository == 'anthropics/anthropic-sdk-typescript'
runs-on: ubuntu-latest

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 }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.5.2"
}
21 changes: 21 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/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

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!"
9 changes: 9 additions & 0 deletions bin/publish-npm
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -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"]
}
7 changes: 4 additions & 3 deletions src/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export type ToFileInput = Uploadable | Exclude<BlobPart, string> | AsyncIterable
* @returns a {@link File} with the given properties
*/
export async function toFile(
value: ToFileInput,
value: ToFileInput | PromiseLike<ToFileInput>,
name?: string | null | undefined,
options: FilePropertyBag | undefined = {},
): Promise<FileLike> {
Expand All @@ -121,8 +121,9 @@ export async function toFile(
return new File(bits, name, options);
}

async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
if (value instanceof Promise) return getBytes(await (value as any));
async function getBytes(value: ToFileInput | PromiseLike<ToFileInput>): Promise<Array<BlobPart>> {
// resolve input promise or promiselike object
value = await value;

let parts: Array<BlobPart> = [];
if (
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.5.2';
export const VERSION = '0.5.2'; // x-release-please-version

0 comments on commit 1d5f87d

Please sign in to comment.