Skip to content

Commit 881a745

Browse files
authored
feat: Support publishing to jsr. (#435)
1 parent 65f01d7 commit 881a745

File tree

5 files changed

+74
-5
lines changed

5 files changed

+74
-5
lines changed

.github/workflows/manual-publish.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ name: Publish Package
22
on:
33
workflow_dispatch:
44
inputs:
5+
package_registry:
6+
description: 'Publish to'
7+
required: true
8+
default: 'npm'
9+
type: choice
10+
options:
11+
- npm
12+
- jsr
513
workspace_path:
614
description: 'The workspace to publish'
715
required: true
@@ -39,8 +47,8 @@ jobs:
3947
id-token: write
4048
contents: read
4149
steps:
42-
- uses: actions/checkout@v3
43-
- uses: actions/setup-node@v3
50+
- uses: actions/checkout@v4
51+
- uses: actions/setup-node@v4
4452
with:
4553
node-version: 16.x
4654
registry-url: 'https://registry.npmjs.org'
@@ -81,8 +89,17 @@ jobs:
8189
yarn config set npmScopes.launchdarkly.npmRegistryServer "https://registry.npmjs.org"
8290
yarn config set npmScopes.launchdarkly.npmAlwaysAuth true
8391
yarn config set npmScopes.launchdarkly.npmAuthToken $NODE_AUTH_TOKEN
84-
- id: publish
85-
name: Publish Package
92+
- id: publish-jsr
93+
name: Publish Package to jsr
94+
if: ${{ inputs.package_registry == 'jsr' }}
95+
uses: ./actions/publish-jsr
96+
with:
97+
workspace_name: ${{ env.WORKSPACE_NAME }}
98+
workspace_path: ${{ inputs.workspace_path }}
99+
dry_run: ${{ inputs.dry_run }}
100+
- id: publish-npm
101+
name: Publish Package to npm
102+
if: ${{ inputs.package_registry == 'npm' }}
86103
uses: ./actions/publish
87104
with:
88105
workspace_name: ${{ env.WORKSPACE_NAME }}

actions/full-release/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ runs:
3131
yarn config set npmScopes.launchdarkly.npmRegistryServer "https://registry.npmjs.org"
3232
yarn config set npmScopes.launchdarkly.npmAlwaysAuth true
3333
yarn config set npmScopes.launchdarkly.npmAuthToken $NODE_AUTH_TOKEN
34+
- uses: ./actions/publish-jsr
35+
with:
36+
workspace_name: ${{ env.WORKSPACE_NAME }}
37+
workspace_path: ${{ inputs.workspace_path }}
38+
dry_run: false
3439
- uses: ./actions/publish
3540
with:
3641
workspace_name: ${{ env.WORKSPACE_NAME }}

actions/publish-jsr/action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish to jsr
2+
description: Publish a package to jsr from the workspace.
3+
inputs:
4+
workspace_name:
5+
description: 'The workspace to publish'
6+
required: true
7+
workspace_path:
8+
description: 'Path to the workspace (for jsr publish)'
9+
required: true
10+
dry_run:
11+
description: 'Is this a dry run. If so no package will be published.'
12+
required: true
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Publish jsr
18+
shell: bash
19+
run: |
20+
echo "Publishing jsr: $WORKSPACE"
21+
./scripts/publish-jsr.sh
22+
env:
23+
WORKSPACE: ${{ inputs.workspace_name }}
24+
WORKSPACE_PATH: ${{ inputs.workspace_path }}
25+
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}

release-please-config.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
"packages/shared/sdk-server": {},
66
"packages/shared/sdk-server-edge": {},
77
"packages/shared/akamai-edgeworker-sdk": {},
8-
"packages/sdk/cloudflare": {},
8+
"packages/sdk/cloudflare": {
9+
"extra-files": [
10+
{
11+
"type": "json",
12+
"path": "jsr.json",
13+
"jsonpath": "$.version"
14+
}
15+
]
16+
},
917
"packages/sdk/react-native": {},
1018
"packages/sdk/server-node": {},
1119
"packages/sdk/vercel": {

scripts/publish-jsr.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -f "./$WORKSPACE_PATH/jsr.json" ]; then
4+
yarn workspace $WORKSPACE pack
5+
cd $WORKSPACE_PATH
6+
7+
if $LD_RELEASE_IS_DRYRUN ; then
8+
echo "Doing a dry run of jsr publishing."
9+
npx jsr publish --dry-run || { echo "jsr publish failed" >&2; exit 1; }
10+
elif [ -f "./$WORKSPACE_PATH/jsr.json" ]; then
11+
echo "Publishing to jsr."
12+
npx jsr publish || { echo "jsr publish failed" >&2; exit 1; }
13+
fi
14+
fi

0 commit comments

Comments
 (0)