Skip to content

Commit 6660417

Browse files
committed
Prepare npm trusted publishing
1 parent 8029c2a commit 6660417

6 files changed

Lines changed: 70 additions & 17 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish JS SDK
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "**"
9+
- ".github/workflows/publish-npm.yml"
10+
workflow_dispatch: {}
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
id-token: write
18+
steps:
19+
- name: Check out repo
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Node
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: "24"
26+
registry-url: "https://registry.npmjs.org"
27+
28+
- name: Upgrade npm for trusted publishing
29+
run: npm install -g npm@11.5.1
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Decide whether to publish
35+
id: should_publish
36+
run: |
37+
current=$(node -p "require('./package.json').version")
38+
published=$(npm view diffio version 2>/dev/null || true)
39+
echo "current=$current"
40+
echo "published=$published"
41+
if [ "$current" = "$published" ]; then
42+
echo "publish=false" >> "$GITHUB_OUTPUT"
43+
else
44+
echo "publish=true" >> "$GITHUB_OUTPUT"
45+
fi
46+
47+
- name: Build
48+
if: ${{ steps.should_publish.outputs.publish == 'true' }}
49+
run: npm run build
50+
51+
- name: Publish to npm
52+
if: ${{ steps.should_publish.outputs.publish == 'true' }}
53+
run: npm publish --access public

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The Diffio JS SDK helps you call the Diffio API from Node. This version covers p
55
## Install
66

77
```bash
8-
npm install diffio-js
8+
npm install diffio
99
```
1010

1111
For local development:
@@ -35,7 +35,7 @@ export DIFFIO_API_BASE_URL="http://127.0.0.1:5001/diffioai/us-central1"
3535
Use request options to override headers, timeouts, retries, or the API key per request.
3636

3737
```ts
38-
import { DiffioClient } from "diffio-js";
38+
import { DiffioClient } from "diffio";
3939

4040
const client = new DiffioClient({ apiKey: "diffio_live_..." });
4141
const projects = await client.listProjects({
@@ -53,7 +53,7 @@ const projects = await client.listProjects({
5353
`createProject` uploads the file and returns the project metadata.
5454

5555
```ts
56-
import { DiffioClient } from "diffio-js";
56+
import { DiffioClient } from "diffio";
5757

5858
const client = new DiffioClient({ apiKey: "diffio_live_..." });
5959
const filePath = "sample.wav";
@@ -74,7 +74,7 @@ console.log(generation.generationId);
7474
## Audio isolation helper
7575

7676
```ts
77-
import { DiffioClient } from "diffio-js";
77+
import { DiffioClient } from "diffio";
7878

7979
const client = new DiffioClient({ apiKey: "diffio_live_..." });
8080
const result = await client.audioIsolation.isolate({
@@ -92,7 +92,7 @@ This helper runs the full flow and returns the downloaded bytes plus a metadata
9292

9393
```ts
9494
import fs from "node:fs";
95-
import { DiffioClient } from "diffio-js";
95+
import { DiffioClient } from "diffio";
9696

9797
const client = new DiffioClient({ apiKey: "diffio_live_..." });
9898
const [audioBytes, info] = await client.restoreAudio({
@@ -114,7 +114,7 @@ console.log(info.apiProjectId, info.generationId);
114114
## Generation progress
115115

116116
```ts
117-
import { DiffioClient } from "diffio-js";
117+
import { DiffioClient } from "diffio";
118118

119119
const client = new DiffioClient({ apiKey: "diffio_live_..." });
120120
const progress = await client.generations.getProgress({
@@ -128,7 +128,7 @@ console.log(progress.status);
128128
## Generation download
129129

130130
```ts
131-
import { DiffioClient } from "diffio-js";
131+
import { DiffioClient } from "diffio";
132132

133133
const client = new DiffioClient({ apiKey: "diffio_live_..." });
134134
const download = await client.generations.getDownload({
@@ -143,7 +143,7 @@ console.log(download.downloadUrl);
143143
## List projects
144144

145145
```ts
146-
import { DiffioClient } from "diffio-js";
146+
import { DiffioClient } from "diffio";
147147

148148
const client = new DiffioClient({ apiKey: "diffio_live_..." });
149149
const projects = await client.projects.list();
@@ -156,7 +156,7 @@ for (const project of projects.projects) {
156156
## List project generations
157157

158158
```ts
159-
import { DiffioClient } from "diffio-js";
159+
import { DiffioClient } from "diffio";
160160

161161
const client = new DiffioClient({ apiKey: "diffio_live_..." });
162162
const generations = await client.projects.listGenerations({ apiProjectId: "proj_123" });
@@ -169,7 +169,7 @@ for (const generation of generations.generations) {
169169
## Webhooks portal access
170170

171171
```ts
172-
import { DiffioClient } from "diffio-js";
172+
import { DiffioClient } from "diffio";
173173

174174
const client = new DiffioClient({ apiKey: "diffio_live_..." });
175175
const portal = await client.webhooks.getPortalAccess({ mode: "test" });
@@ -179,7 +179,7 @@ console.log(portal.portalUrl);
179179
## Send a test webhook event
180180

181181
```ts
182-
import { DiffioClient } from "diffio-js";
182+
import { DiffioClient } from "diffio";
183183

184184
const client = new DiffioClient({ apiKey: "diffio_live_..." });
185185
const event = await client.webhooks.sendTestEvent({

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "diffio-js",
2+
"name": "diffio",
33
"version": "0.1.0",
44
"description": "Diffio API client for Node.js",
55
"license": "MIT",

src/BaseClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ export function normalizeClientOptions<T extends BaseClientOptions>(options: T):
3333
const headers = mergeHeaders(
3434
{
3535
"X-Diffio-SDK-Language": "JavaScript",
36-
"X-Diffio-SDK-Name": "diffio-js",
36+
"X-Diffio-SDK-Name": "diffio",
3737
"X-Diffio-SDK-Version": DIFFIO_SDK_VERSION,
38-
"User-Agent": `diffio-js/${DIFFIO_SDK_VERSION}`
38+
"User-Agent": `diffio/${DIFFIO_SDK_VERSION}`
3939
},
4040
options?.headers
4141
);

tests/wire/client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("DiffioClient wire", () => {
2424
Authorization: "Bearer test",
2525
"Content-Type": "application/json",
2626
"X-Diffio-SDK-Language": "JavaScript",
27-
"X-Diffio-SDK-Name": "diffio-js",
27+
"X-Diffio-SDK-Name": "diffio",
2828
"X-Diffio-SDK-Version": DIFFIO_SDK_VERSION
2929
})
3030
.jsonBody({

0 commit comments

Comments
 (0)