Skip to content

Publish Package

Publish Package #81

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
default: 'packages/shared/common'
type: choice
options:
- packages/shared/common
- packages/shared/sdk-client
- packages/shared/sdk-server
- packages/shared/sdk-server-edge
- packages/shared/akamai-edgeworker-sdk
- packages/sdk/cloudflare
- packages/sdk/react-native
- packages/sdk/server-node
- packages/sdk/vercel
- packages/sdk/akamai-base
- packages/sdk/akamai-edgekv
- packages/store/node-server-sdk-redis
- packages/store/node-server-sdk-dynamodb
- packages/telemetry/node-server-sdk-otel
prerelease:
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
type: boolean
required: true
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true
jobs:
build-publish:
runs-on: ubuntu-latest
# Needed to get tokens during publishing.
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org'
- name: 'Setup Redis'
if: ${{ inputs.workspace_path == 'packages/store/node-server-sdk-redis' }}
run: |
sudo apt-get update
sudo apt-get install redis-server
sudo service redis-server start
- name: 'Setup DynamoDB'
if: ${{ inputs.workspace_path == 'packages/store/node-server-sdk-dynamodb' }}
run: |
sudo docker run -d -p 8000:8000 amazon/dynamodb-local
- name: 'Set WORKSPACE_NAME variable'
run: |
WORKSPACE_NAME=$(./scripts/package-name.sh ${{ inputs.workspace_path }})
echo "WORKSPACE_NAME=$WORKSPACE_NAME" >> $GITHUB_ENV
- id: build-and-test
# Build using the same steps from CI.
name: Build and Test
uses: ./actions/ci
with:
workspace_name: ${{ env.WORKSPACE_NAME }}
workspace_path: ${{ inputs.workspace_path }}
- uses: ./actions/release-secrets
name: 'Get NPM token'
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
- name: Setup .yarnrc.yml
shell: bash
run: |
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-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 }}
workspace_path: ${{ inputs.workspace_path }}
prerelease: ${{ inputs.prerelease }}
dry_run: ${{ inputs.dry_run }}