From 393d87f3c0563c02fc4ded562a58023bf45cc307 Mon Sep 17 00:00:00 2001 From: jupblb Date: Mon, 1 Jun 2026 15:15:40 +0200 Subject: [PATCH 1/3] Publish TypeScript bindings to npm --- .github/workflows/release.yaml | 41 ++++++++++++++++++++++++++++++- .gitignore | 3 +++ bindings/typescript/package.json | 21 ++++++++++++++-- bindings/typescript/tsconfig.json | 16 ++++++++---- checks.nix | 2 +- 5 files changed, 74 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9c47a93a..a028ea74 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -131,6 +131,45 @@ jobs: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + publish-npm: + needs: publish + runs-on: ubuntu-latest + permissions: + contents: read + # Required for `npm publish --provenance` to mint an OIDC token + # that npm verifies against this workflow's identity. + id-token: write + steps: + - uses: actions/checkout@v6 + with: + ref: v${{ inputs.version }} + - uses: actions/setup-node@v6 + with: + node-version: 22 + registry-url: https://registry.npmjs.org + cache: npm + cache-dependency-path: bindings/typescript/package-lock.json + - name: Install dependencies + run: npm ci + working-directory: bindings/typescript + - name: Build + run: npm run build + working-directory: bindings/typescript + - name: Stage LICENSE into package + run: cp LICENSE bindings/typescript/LICENSE + - name: Publish to npm + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + OUTPUT=$(npm publish --access public --provenance 2>&1) && exit 0 + if echo "$OUTPUT" | grep -qE "(cannot publish over the previously published versions|EPUBLISHCONFLICT|You cannot publish over the previously published versions)"; then + echo "Package version already published, skipping" + else + echo "$OUTPUT" + exit 1 + fi + working-directory: bindings/typescript + build-go-binaries: needs: publish permissions: @@ -192,7 +231,7 @@ jobs: gh release upload "$TAG" "$ASSET.tar.gz" "$ASSET.tar.gz.sha256" --clobber finalize-release: - needs: [release-crate, build-go-binaries, publish-jvm-bindings] + needs: [release-crate, build-go-binaries, publish-jvm-bindings, publish-npm] runs-on: ubuntu-latest permissions: contents: write diff --git a/.gitignore b/.gitignore index 8348665d..d501303f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,7 @@ dist-newstyle/ # Nix output /result +# TypeScript bindings build output +/bindings/typescript/dist/ + vendor/ diff --git a/bindings/typescript/package.json b/bindings/typescript/package.json index 98b3e8ab..e4a49fc9 100644 --- a/bindings/typescript/package.json +++ b/bindings/typescript/package.json @@ -2,11 +2,28 @@ "name": "@scip-code/scip", "version": "0.7.1", "description": "Generated TypeScript definitions for the Semantic Code Intelligence Protocol.", - "repository": "https://github.com/scip-code/scip/bindings/typescript", + "repository": { + "type": "git", + "url": "https://github.com/scip-code/scip", + "directory": "bindings/typescript" + }, "author": "Sourcegraph", "license": "Apache-2.0", + "type": "module", + "main": "./dist/scip_pb.js", + "types": "./dist/scip_pb.d.ts", + "exports": { + ".": { + "types": "./dist/scip_pb.d.ts", + "import": "./dist/scip_pb.js" + } + }, + "files": ["dist"], "sideEffects": false, - "private": false, + "scripts": { + "build": "tsc", + "typecheck": "tsc --noEmit" + }, "dependencies": { "@bufbuild/protobuf": "^2.11.0" }, diff --git a/bindings/typescript/tsconfig.json b/bindings/typescript/tsconfig.json index 38262ef0..ca06db1d 100644 --- a/bindings/typescript/tsconfig.json +++ b/bindings/typescript/tsconfig.json @@ -1,9 +1,15 @@ { "compilerOptions": { - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "bundler", + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "dist", "rootDir": ".", - "strict": true - } + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "strict": true, + "skipLibCheck": true + }, + "include": ["scip_pb.ts"] } diff --git a/checks.nix b/checks.nix index db973b4b..773b8ebb 100644 --- a/checks.nix +++ b/checks.nix @@ -146,7 +146,7 @@ npmDepsHash = "sha256-84LQkN7bJB5q6hGc8TKXC8yD2P+qzBVh34a2L9K2Ji8="; buildPhase = '' runHook preBuild - npx tsc --noEmit + npm run build runHook postBuild ''; installPhase = "touch $out"; From e68f3f5cb9f682995e378e91070b2870d77c5039 Mon Sep 17 00:00:00 2001 From: jupblb Date: Mon, 1 Jun 2026 15:17:53 +0200 Subject: [PATCH 2/3] Use JS-DevTools/npm-publish action --- .github/workflows/release.yaml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a028ea74..e4c672e3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -136,8 +136,6 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - # Required for `npm publish --provenance` to mint an OIDC token - # that npm verifies against this workflow's identity. id-token: write steps: - uses: actions/checkout@v6 @@ -146,7 +144,6 @@ jobs: - uses: actions/setup-node@v6 with: node-version: 22 - registry-url: https://registry.npmjs.org cache: npm cache-dependency-path: bindings/typescript/package-lock.json - name: Install dependencies @@ -157,18 +154,12 @@ jobs: working-directory: bindings/typescript - name: Stage LICENSE into package run: cp LICENSE bindings/typescript/LICENSE - - name: Publish to npm - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - OUTPUT=$(npm publish --access public --provenance 2>&1) && exit 0 - if echo "$OUTPUT" | grep -qE "(cannot publish over the previously published versions|EPUBLISHCONFLICT|You cannot publish over the previously published versions)"; then - echo "Package version already published, skipping" - else - echo "$OUTPUT" - exit 1 - fi - working-directory: bindings/typescript + - uses: JS-DevTools/npm-publish@v4 + with: + token: ${{ secrets.NPM_TOKEN }} + package: bindings/typescript + access: public + provenance: true build-go-binaries: needs: publish From 579c26013c864990a31276d7345c7f6615d0279e Mon Sep 17 00:00:00 2001 From: jupblb Date: Mon, 1 Jun 2026 16:17:29 +0200 Subject: [PATCH 3/3] Symlink LICENSE in bindings/typescript --- .github/workflows/release.yaml | 10 ++++++++-- bindings/typescript/LICENSE | 1 + bindings/typescript/package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 120000 bindings/typescript/LICENSE diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e4c672e3..11c0448b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -152,8 +152,14 @@ jobs: - name: Build run: npm run build working-directory: bindings/typescript - - name: Stage LICENSE into package - run: cp LICENSE bindings/typescript/LICENSE + # bindings/typescript/LICENSE is a symlink to ../../LICENSE in the + # source tree (matching bindings/haskell and bindings/rust), but + # npm-pack drops symlinks. Replace it with a regular file so the + # published tarball carries the license text. + - name: Materialize LICENSE for npm pack + run: | + rm -f bindings/typescript/LICENSE + cp LICENSE bindings/typescript/LICENSE - uses: JS-DevTools/npm-publish@v4 with: token: ${{ secrets.NPM_TOKEN }} diff --git a/bindings/typescript/LICENSE b/bindings/typescript/LICENSE new file mode 120000 index 00000000..30cff740 --- /dev/null +++ b/bindings/typescript/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/bindings/typescript/package.json b/bindings/typescript/package.json index e4a49fc9..8312ba95 100644 --- a/bindings/typescript/package.json +++ b/bindings/typescript/package.json @@ -18,7 +18,7 @@ "import": "./dist/scip_pb.js" } }, - "files": ["dist"], + "files": ["dist", "LICENSE"], "sideEffects": false, "scripts": { "build": "tsc",