-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (143 loc) · 5.46 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Release SDK Package to NPM and CDN
run-name: ${{ inputs.release_type == 'Snapshot' && 'Publish Pre-release' || format('Release {0}', inputs.release_type)}} SDK Package to NPM and CDN by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
release_type:
type: choice
description: The type of release
options:
- Major
- Minor
- Patch
- Snapshot
required: true
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 (In general, always release to both)
required: false
default: true
publish_to_cdn:
type: boolean
description: Publish package to CDN (In general, always release to both)
required: false
default: true
jobs:
incrementVersionNumber:
uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-increase-version-number.yaml@v2
with:
release_type: ${{ inputs.release_type }}
secrets: inherit
build:
runs-on: ubuntu-latest
needs: [incrementVersionNumber]
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
with:
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
- 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
if: inputs.publish_to_cdn
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
if: inputs.publish_to_cdn
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: inputs.publish_to_npm
needs: [build, incrementVersionNumber]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
- 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 ./dist/uid2-npm --access public
npm publish ./dist/euid-npm --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish Latest package with tag
if: ${{github.event.inputs.with_tag}}
run: |
npm publish ./dist/uid2-npm --tag ${{github.event.inputs.with_tag}} --access public
npm publish ./dist/euid-npm --tag ${{github.event.inputs.with_tag}} --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
cdn-deployment-uid2:
if: inputs.publish_to_cdn
needs: [build, incrementVersionNumber]
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
environment: [integ, production]
environment: ${{ matrix.environment }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
- 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:
if: inputs.publish_to_cdn
needs: [build, incrementVersionNumber]
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
environment: [integ, production]
environment: ${{ matrix.environment }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
- 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 }}