Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish to npm
name: publish to npm and jsr
on:
release:
types: [published]
Expand All @@ -9,6 +9,9 @@ env:
jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # The OIDC ID token is used for authentication with JSR.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -21,16 +24,16 @@ jobs:
- name: Check tag format
run: sh .github/scripts/check-tag-format.sh "${{ github.event.release.prerelease }}"
- name: Install dependencies
run: yarn install
run: yarn
- name: Build meilisearch-js
run: yarn build
- name: Publish with latest tag
if: '!github.event.release.prerelease'
run: npm publish .
run: npm publish && yarn publish:jsr
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish with beta tag
if: 'github.event.release.prerelease'
run: npm publish . --tag beta
run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ typings/
# Output of 'npm pack'
*.tgz

# JSR generated config
jsr.json

# Generated Docs
docs/

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"scripts": {
"playground:javascript": "vite serve playgrounds/javascript --open",
"publish:jsr": "node scripts/make-jsr-json.js && npx jsr publish",
"build:docs": "typedoc",
"build": "vite build && tsc -p tsconfig.build.json && vite --mode production-umd build",
"postbuild": "node scripts/build.js",
Expand Down
23 changes: 23 additions & 0 deletions scripts/make-jsr-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { writeFileSync } from "node:fs";
import pkg from "../package.json" with { type: "json" };

Comment thread
Strift marked this conversation as resolved.
const { name, version, exports, files } = pkg;

writeFileSync(
new URL("../jsr.json", import.meta.url),
JSON.stringify(
{
name: `@meilisearch/${name}`,
version,
exports: Object.fromEntries(
Object.entries(exports).map(([key, val]) => [
key,
val.import.replace("dist/esm", "src").replace(".js", ".ts"),
]),
),
publish: { include: files.filter((v) => v !== "dist") },
},
null,
2,
),
);