Skip to content

Publish Pre-release SDK Package to NPM and CDN by @lionell-pack-ttd #46

Publish Pre-release SDK Package to NPM and CDN by @lionell-pack-ttd

Publish Pre-release SDK Package to NPM and CDN by @lionell-pack-ttd #46

name: Release SDK Package to NPM and CDN
run-name: ${{ github.action_ref == 'refs/head/main' && 'Release' || 'Publish Pre-release' }} SDK Package to NPM and CDN by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
with_tag:
description: By default, running npm publish will tag your package with the latest dist-tag. To use another dist-tag, please add tag here
required: false
publish_to_npm:
type: boolean
description: Publish package to NPM
required: false
default: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
target: [development, production]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Get Package Version
id: version
run: |
echo "package_version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
- name: Install dependencies
run: npm install
- name: Build script
run: npm run build -- --mode=${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: uid2SDK-${{ matrix.target }}-${{ steps.version.outputs.package_version }}
path: ./dist/uid2-sdk-${{ steps.version.outputs.package_version }}.js
- uses: actions/upload-artifact@v4
with:
name: euidSDK-${{ matrix.target }}-${{ steps.version.outputs.package_version }}
path: ./dist/euid-sdk-${{ steps.version.outputs.package_version }}.js
outputs:
sdkVersion: ${{ steps.version.outputs.package_version }}
publish-package:
if: github.event.inputs.publish_to_npm == 'true'
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
scope: uid2
- run: npm ci
- name: Build package
run: npm run build-package
- name: Publish Latest package
if: ${{!github.event.inputs.with_tag}}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish Latest package with tag
if: ${{github.event.inputs.with_tag}}
run: npm publish --tag ${{github.event.inputs.with_tag}} --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
cdn-deployment-uid2:
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
environment: [integ, production]
environment: ${{ matrix.environment }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/cdn_deployment_aws
with:
environment: ${{ matrix.environment }}
artifact: uid2SDK-${{ (matrix.environment == 'integ' && 'development') || matrix.environment }}-${{ needs.build.outputs.sdkVersion}}
invalidate_paths: '/uid2-sdk-${{ needs.build.outputs.sdkVersion}}.js'
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_bucket_name: ${{ vars.S3_BUCKET }}
aws_distribution_id: ${{ secrets.AWS_DISTRIBUTION_ID }}
cdn-deployment-euid:
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
environment: [integ, production]
environment: ${{ matrix.environment }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/cdn_deployment_aws
with:
environment: ${{ matrix.environment }}
artifact: euidSDK-${{ (matrix.environment == 'integ' && 'development') || matrix.environment }}-${{ needs.build.outputs.sdkVersion}}
invalidate_paths: '/euid-sdk-${{ needs.build.outputs.sdkVersion}}.js'
aws_account_id: ${{ vars.EUID_AWS_ACCOUNT_ID }}
aws_bucket_name: ${{ vars.EUID_S3_BUCKET }}
aws_distribution_id: ${{ secrets.EUID_AWS_DISTRIBUTION_ID }}