Skip to content

Commit 7b98759

Browse files
authored
[OB-75] setup packaging for @launchdarkly/observability sdks (#17)
## Summary Prepare npm SDK repository for publishing using LD npm token. launchdarkly/terraform#18409 ## How did you test this change? CI, will manually trigger action once merged ## Are there any deployment considerations? no ## Does this work require review from our design team? no <!-- ld-jira-link --> --- Related Jira issue: [OB-75: setup packaging for @launchdarkly o11y](https://launchdarkly.atlassian.net/browse/OB-75) <!-- end-ld-jira-link -->
1 parent 2211bd3 commit 7b98759

File tree

5 files changed

+89
-3
lines changed

5 files changed

+89
-3
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Publish to NPM
2+
description: Publish an npm package.
3+
inputs:
4+
prerelease:
5+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
6+
required: false
7+
dry-run:
8+
description: 'Is this a dry run. If so no package will be published.'
9+
required: false
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Publish
15+
shell: bash
16+
run: |
17+
./scripts/publish-npm.sh
18+
env:
19+
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
20+
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry-run }}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Manual Publish Package
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
dry-run:
6+
description: 'Is this a dry run. If so no package will be published.'
7+
type: boolean
8+
required: true
9+
prerelease:
10+
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
11+
type: boolean
12+
required: true
13+
14+
permissions:
15+
id-token: write
16+
contents: write
17+
concurrency: ${{ github.workflow }}-${{ github.ref }}
18+
jobs:
19+
publish-package:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: launchdarkly/common-actions/ssh-key-by-repo@main
23+
with:
24+
repo_keys_map: |
25+
{
26+
"launchdarkly/observability-sdk": ${{ toJSON(secrets.LAUNCHDARKLY_OBSERVABILITY_SDK_DEPLOY_KEY) }},
27+
"launchdarkly/rrweb": ${{ toJSON(secrets.LAUNCHDARKLY_RRWEB_DEPLOY_KEY) }}
28+
}
29+
- uses: launchdarkly/common-actions/init@main
30+
env:
31+
GITHUB_TOKEN: ${{ github.token }}
32+
- run: git submodule update --init --recursive
33+
34+
- name: Setup Node.js environment
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: lts/*
38+
cache: 'yarn'
39+
40+
- name: Install js dependencies
41+
run: yarn
42+
43+
- uses: launchdarkly/gh-actions/actions/[email protected]
44+
name: 'Get NPM token'
45+
with:
46+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
47+
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
48+
49+
- id: publish-npm
50+
name: Publish NPM Packages
51+
uses: ./.github/actions/publish-npm
52+
with:
53+
dry-run: ${{ inputs.dry-run }}
54+
prerelease: ${{ inputs.prerelease }}

.github/workflows/turbo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ jobs:
5858
env:
5959
NPM_TOKEN: ${{ secrets.NPM_TOKEN_HIGHLIGHT_RUN }}
6060

61-
- name: Publish npm packages
61+
- name: Publish highlight npm packages
6262
if: github.ref == 'refs/heads/main'
6363
id: changesets-publish
6464
uses: changesets/action@v1
6565
with:
66-
publish: yarn publish
66+
publish: yarn publish:highlight
6767
env:
6868
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6969
NPM_TOKEN: ${{ secrets.NPM_TOKEN_HIGHLIGHT_RUN }}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"lint": "yarn run turbo lint --filter=!rrweb --filter=!rrvideo --filter=!@rrweb/rrweb-plugin-console-record --filter=!@rrweb/_monorepo --filter=!@rrweb/all --filter=!@rrweb/record --filter=!@rrweb/replay --filter=!@rrweb/types --filter=!@rrweb/packer --filter=!@rrweb/utils --filter=!@rrweb/web-extension --filter=!rrweb-snapshot --filter=!rrweb-player --filter=!rrdom --filter=!rrdom-nodejs --filter=!e2e-react-native",
2424
"prepare": "husky",
2525
"preinstall": "git submodule update --init --recursive || true",
26-
"publish": "yarn workspaces foreach -R --no-private --from '@highlight-run/*' npm publish --access public --tolerate-republish && yarn workspace highlight.run npm publish --access public --tolerate-republish",
26+
"publish": "yarn workspaces foreach -R --no-private --from '@launchdarkly/*' npm publish --access public --tolerate-republish --provenance",
27+
"publish:highlight": "yarn workspaces foreach -R --no-private --from '@highlight-run/*' npm publish --access public --tolerate-republish --provenance && yarn workspace highlight.run npm publish --access public --tolerate-republish --provenance",
2728
"test": "yarn turbo run test --filter=!rrweb --filter=!rrvideo --filter=!@rrweb/rrweb-plugin-console-record --filter=!@rrweb/_monorepo --filter=!@rrweb/all --filter=!@rrweb/record --filter=!@rrweb/replay --filter=!@rrweb/types --filter=!@rrweb/packer --filter=!@rrweb/utils --filter=!@rrweb/web-extension --filter=!rrweb-snapshot --filter=!rrweb-player --filter=!rrdom --filter=!rrdom-nodejs --filter=!nextjs"
2829
},
2930
"devDependencies": {

scripts/publish-npm.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
if $LD_RELEASE_IS_DRYRUN ; then
3+
echo "Doing a dry run of publishing."
4+
else
5+
if $LD_RELEASE_IS_PRERELEASE ; then
6+
echo "Publishing with prerelease tag."
7+
yarn publish --tag prerelease || { echo "npm publish failed" >&2; exit 1; }
8+
else
9+
yarn publish || { echo "npm publish failed" >&2; exit 1; }
10+
fi
11+
fi

0 commit comments

Comments
 (0)