-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (82 loc) · 3.03 KB
/
publish-package-to-npmjs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
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'
- 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:
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_bucket_name: ${{ vars.S3_BUCKET }}
aws_distribution_id: ${{ secrets.AWS_DISTRIBUTION_ID }}