|
| 1 | +# JSR Publishing Setup |
| 2 | + |
| 3 | +This document explains how JSR (JavaScript Registry) publishing is configured in this monorepo. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Supabase JavaScript packages are published to npm, and select packages with explicit return types are also published to JSR. JSR publishing happens automatically after npm publishing in both stable and canary releases. |
| 8 | + |
| 9 | +Currently, only packages with complete TypeScript typing (explicit return types) are published to JSR to maintain high quality standards and optimal type-checking performance. |
| 10 | + |
| 11 | +## Current Status |
| 12 | + |
| 13 | +**JSR publishing is configured for packages with explicit return types** |
| 14 | + |
| 15 | +The following packages are currently published to JSR: |
| 16 | + |
| 17 | +- @supabase/functions-js (has explicit return types) |
| 18 | +- @supabase/supabase-js (has explicit return types) |
| 19 | + |
| 20 | +## Authentication |
| 21 | + |
| 22 | +JSR publishing uses **OpenID Connect (OIDC)** authentication from GitHub Actions, which is the recommended approach by JSR. This means: |
| 23 | + |
| 24 | +- No secrets to manage or rotate |
| 25 | +- Automatic authentication via GitHub |
| 26 | +- Short-lived tokens for enhanced security |
| 27 | +- Works automatically when `id-token: write` permission is set |
| 28 | + |
| 29 | +The workflow already has the required permissions configured: |
| 30 | + |
| 31 | +```yaml |
| 32 | +permissions: |
| 33 | + contents: read |
| 34 | + id-token: write # Required for JSR OIDC authentication |
| 35 | +``` |
| 36 | +
|
| 37 | +**No additional setup is required** - JSR publishing works automatically in GitHub Actions. |
| 38 | +
|
| 39 | +## How It Works |
| 40 | +
|
| 41 | +1. **Version Synchronization**: The `jsr.json` files use placeholder versions (e.g., `"0.0.0"` or `"0.0.0-automated"`). The publish script updates these to match the package.json version before publishing, then restores the original placeholder to keep the working directory clean. |
| 42 | + |
| 43 | +2. **OIDC Authentication**: When running in GitHub Actions with `id-token: write` permission, JSR automatically authenticates using GitHub's OIDC tokens. No manual token management is required. |
| 44 | + |
| 45 | +3. **Type Checking**: Only packages with explicit return types are published to JSR. This ensures optimal performance and aligns with JSR's quality standards. |
| 46 | + |
| 47 | +Published packages (with explicit return types): |
| 48 | + |
| 49 | +- `functions-js` - Has explicit return types |
| 50 | +- `supabase-js` - Has explicit return types (aggregates other packages) |
| 51 | + |
| 52 | +4. **Failure Handling**: JSR publishing failures don't fail the entire release - npm releases will still succeed. |
| 53 | + |
| 54 | +## Files Involved |
| 55 | + |
| 56 | +- `scripts/publish-to-jsr.ts` - Main JSR publishing script |
| 57 | +- `scripts/release-stable.ts` - Calls JSR publish after stable npm release |
| 58 | +- `scripts/release-canary.ts` - Calls JSR publish after canary npm release |
| 59 | +- `packages/core/*/jsr.json` - JSR configuration for each package |
| 60 | +- `.github/workflows/publish.yml` - GitHub Actions workflow with OIDC permissions |
0 commit comments