Skip to content

Commit b5ea928

Browse files
authored
ci(release): set up jsr releasing (#1874)
1 parent da38938 commit b5ea928

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

docs/JSR_PUBLISHING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

package-lock.json

Lines changed: 1 addition & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"jiti": "2.4.2",
5555
"jsonc-eslint-parser": "^2.1.0",
5656
"jsonwebtoken": "^9.0.0",
57+
"jsr": "^0.13.5",
5758
"nx": "21.6.2",
5859
"prettier": "^3.6.2",
5960
"ts-jest": "^29.4.2",

scripts/release-canary.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,15 @@ import { execSync } from 'child_process'
7878
console.log('⚠️ Continuing with release despite gotrue-js publish failure')
7979
}
8080

81+
// Publish all packages to JSR
82+
console.log('\n📦 Publishing packages to JSR (canary)...')
83+
try {
84+
execSync('npx tsx scripts/publish-to-jsr.ts --tag=canary', { stdio: 'inherit' })
85+
} catch (error) {
86+
console.error('❌ Failed to publish to JSR:', error)
87+
// Don't fail the entire release if JSR publishing fails
88+
console.log('⚠️ Continuing with release despite JSR publish failure')
89+
}
90+
8191
process.exit(Object.values(publishResult).every((result) => result.code === 0) ? 0 : 1)
8292
})()

scripts/release-stable.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ function safeExec(cmd: string, opts = {}) {
142142
console.log('⚠️ Continuing with release despite gotrue-js publish failure')
143143
}
144144

145+
// Publish all packages to JSR
146+
console.log('\n📦 Publishing packages to JSR...')
147+
try {
148+
safeExec('npx tsx scripts/publish-to-jsr.ts --tag=latest')
149+
} catch (error) {
150+
console.error('❌ Failed to publish to JSR:', error)
151+
// Don't fail the entire release if JSR publishing fails
152+
console.log('⚠️ Continuing with release despite JSR publish failure')
153+
}
154+
145155
// ---- CREATE RELEASE BRANCH + PR ----
146156
process.env.GITHUB_TOKEN = process.env.RELEASE_GITHUB_TOKEN
147157

0 commit comments

Comments
 (0)