diff --git a/.github/workflows/manual-publish.yml b/.github/workflows/manual-publish.yml index d75cb03191..06ef51bfd4 100644 --- a/.github/workflows/manual-publish.yml +++ b/.github/workflows/manual-publish.yml @@ -2,6 +2,14 @@ name: Publish Package on: workflow_dispatch: inputs: + package_registry: + description: 'Publish to' + required: true + default: 'npm' + type: choice + options: + - npm + - jsr workspace_path: description: 'The workspace to publish' required: true @@ -39,8 +47,8 @@ jobs: id-token: write contents: read steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 16.x registry-url: 'https://registry.npmjs.org' @@ -81,8 +89,17 @@ jobs: yarn config set npmScopes.launchdarkly.npmRegistryServer "https://registry.npmjs.org" yarn config set npmScopes.launchdarkly.npmAlwaysAuth true yarn config set npmScopes.launchdarkly.npmAuthToken $NODE_AUTH_TOKEN - - id: publish - name: Publish Package + - id: publish-jsr + name: Publish Package to jsr + if: ${{ inputs.package_registry == 'jsr' }} + uses: ./actions/publish-jsr + with: + workspace_name: ${{ env.WORKSPACE_NAME }} + workspace_path: ${{ inputs.workspace_path }} + dry_run: ${{ inputs.dry_run }} + - id: publish-npm + name: Publish Package to npm + if: ${{ inputs.package_registry == 'npm' }} uses: ./actions/publish with: workspace_name: ${{ env.WORKSPACE_NAME }} diff --git a/actions/full-release/action.yml b/actions/full-release/action.yml index 17ff7e8f85..6a2d31a709 100644 --- a/actions/full-release/action.yml +++ b/actions/full-release/action.yml @@ -31,6 +31,11 @@ runs: yarn config set npmScopes.launchdarkly.npmRegistryServer "https://registry.npmjs.org" yarn config set npmScopes.launchdarkly.npmAlwaysAuth true yarn config set npmScopes.launchdarkly.npmAuthToken $NODE_AUTH_TOKEN + - uses: ./actions/publish-jsr + with: + workspace_name: ${{ env.WORKSPACE_NAME }} + workspace_path: ${{ inputs.workspace_path }} + dry_run: false - uses: ./actions/publish with: workspace_name: ${{ env.WORKSPACE_NAME }} diff --git a/actions/publish-jsr/action.yml b/actions/publish-jsr/action.yml new file mode 100644 index 0000000000..3765f482fc --- /dev/null +++ b/actions/publish-jsr/action.yml @@ -0,0 +1,25 @@ +name: Publish to jsr +description: Publish a package to jsr from the workspace. +inputs: + workspace_name: + description: 'The workspace to publish' + required: true + workspace_path: + description: 'Path to the workspace (for jsr publish)' + required: true + dry_run: + description: 'Is this a dry run. If so no package will be published.' + required: true + +runs: + using: composite + steps: + - name: Publish jsr + shell: bash + run: | + echo "Publishing jsr: $WORKSPACE" + ./scripts/publish-jsr.sh + env: + WORKSPACE: ${{ inputs.workspace_name }} + WORKSPACE_PATH: ${{ inputs.workspace_path }} + LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }} diff --git a/release-please-config.json b/release-please-config.json index 7a9814de31..6fbcdfb94b 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -5,7 +5,15 @@ "packages/shared/sdk-server": {}, "packages/shared/sdk-server-edge": {}, "packages/shared/akamai-edgeworker-sdk": {}, - "packages/sdk/cloudflare": {}, + "packages/sdk/cloudflare": { + "extra-files": [ + { + "type": "json", + "path": "jsr.json", + "jsonpath": "$.version" + } + ] + }, "packages/sdk/react-native": {}, "packages/sdk/server-node": {}, "packages/sdk/vercel": { diff --git a/scripts/publish-jsr.sh b/scripts/publish-jsr.sh new file mode 100755 index 0000000000..33fbd934cc --- /dev/null +++ b/scripts/publish-jsr.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +if [ -f "./$WORKSPACE_PATH/jsr.json" ]; then + yarn workspace $WORKSPACE pack + cd $WORKSPACE_PATH + + if $LD_RELEASE_IS_DRYRUN ; then + echo "Doing a dry run of jsr publishing." + npx jsr publish --dry-run || { echo "jsr publish failed" >&2; exit 1; } + elif [ -f "./$WORKSPACE_PATH/jsr.json" ]; then + echo "Publishing to jsr." + npx jsr publish || { echo "jsr publish failed" >&2; exit 1; } + fi +fi