Skip to content

Commit ba67334

Browse files
authored
Merge pull request #214 from IABTechLab/xuy-UID2-6105-deployment-pipeline
xuy-UID2-6105-deployment-pipeline
2 parents fe0abba + 71119bd commit ba67334

File tree

14 files changed

+11051
-23914
lines changed

14 files changed

+11051
-23914
lines changed

.github/actions/cdn_deployment_aws/action.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: CDN Deployment for AWS
22
description: Deploys to AWS CDN and optionally invalidates the path in CloudFront
33
inputs:
4-
environment:
5-
description: Environment to deploy to
6-
default: 'integ'
74
artifact:
85
description: Name of the artifact
96
required: true
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Release SDK Package to NPM and CDN (v2)
2+
run-name: ${{ inputs.release_type == 'Snapshot' && 'Publish Pre-release' || format('Release {0}', inputs.release_type)}} SDK Package to NPM and CDN by @${{ github.actor }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
release_type:
8+
type: choice
9+
description: The type of release
10+
options:
11+
- Major
12+
- Minor
13+
- Patch
14+
- Snapshot
15+
required: true
16+
with_tag:
17+
description: By default, running npm publish will tag your package with the latest dist-tag. To use another dist-tag, please add tag here
18+
required: false
19+
publish_to_npm:
20+
type: boolean
21+
description: Publish package to NPM (In general, always release to both)
22+
required: false
23+
default: true
24+
publish_to_cdn:
25+
type: boolean
26+
description: Publish package to CDN (In general, always release to both)
27+
required: false
28+
default: true
29+
30+
jobs:
31+
incrementVersionNumber:
32+
uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-increase-version-number.yaml@v2
33+
with:
34+
release_type: ${{ inputs.release_type }}
35+
secrets: inherit
36+
37+
build:
38+
runs-on: ubuntu-latest
39+
needs: [incrementVersionNumber]
40+
strategy:
41+
matrix:
42+
node-version: [20.x]
43+
target: [development, production]
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
48+
- name: Use Node.js ${{ matrix.node-version }}
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: ${{ matrix.node-version }}
52+
- name: Get Package Version
53+
id: version
54+
run: |
55+
echo "package_version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
56+
- name: Install dependencies
57+
run: npm install
58+
- name: Build script
59+
run: npm run build -- --mode=${{ matrix.target }}
60+
- uses: actions/upload-artifact@v4
61+
if: inputs.publish_to_cdn
62+
with:
63+
name: uid2SDK-${{ matrix.target }}-${{ steps.version.outputs.package_version }}
64+
path: ./dist/uid2-sdk-${{ steps.version.outputs.package_version }}.js
65+
- uses: actions/upload-artifact@v4
66+
if: inputs.publish_to_cdn
67+
with:
68+
name: euidSDK-${{ matrix.target }}-${{ steps.version.outputs.package_version }}
69+
path: ./dist/euid-sdk-${{ steps.version.outputs.package_version }}.js
70+
outputs:
71+
sdkVersion: ${{ steps.version.outputs.package_version }}
72+
73+
createNpmJsRelease:
74+
needs: [incrementVersionNumber, build]
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Build Changelog
78+
id: github_release_changelog
79+
uses: mikepenz/release-changelog-builder-action@v4
80+
with:
81+
toTag: v${{ needs.incrementVersionNumber.outputs.new_version }}
82+
configurationJson: |
83+
{
84+
"pr_template": " - #{{TITLE}} - ( PR: ##{{NUMBER}} )"
85+
}
86+
- name: Create Release Notes
87+
uses: softprops/action-gh-release@v2
88+
with:
89+
name: v${{ needs.incrementVersionNumber.outputs.new_version }}
90+
body: ${{ steps.github_release_changelog.outputs.changelog }}
91+
draft: true
92+
93+
publish-package:
94+
if: inputs.publish_to_npm
95+
needs: [build, incrementVersionNumber]
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@v4
99+
with:
100+
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
101+
- uses: actions/setup-node@v4
102+
with:
103+
node-version: '20.x'
104+
registry-url: 'https://registry.npmjs.org'
105+
scope: uid2
106+
- run: npm ci
107+
- name: Build package
108+
run: npm run build-package
109+
- name: Publish Latest package
110+
if: ${{!github.event.inputs.with_tag}}
111+
run: |
112+
npm publish ./dist/uid2-npm --access public
113+
npm publish ./dist/euid-npm --access public
114+
env:
115+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
116+
- name: Publish Latest package with tag
117+
if: ${{github.event.inputs.with_tag}}
118+
run: |
119+
npm publish ./dist/uid2-npm --tag ${{github.event.inputs.with_tag}} --access public
120+
npm publish ./dist/euid-npm --tag ${{github.event.inputs.with_tag}} --access public
121+
env:
122+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
123+
124+
# Test Environment - UID2 only first
125+
cdn-deployment-test:
126+
if: inputs.publish_to_cdn
127+
needs: [build, incrementVersionNumber]
128+
runs-on: ubuntu-latest
129+
permissions:
130+
id-token: write
131+
environment: test
132+
steps:
133+
- uses: actions/checkout@v4
134+
with:
135+
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
136+
- uses: ./.github/actions/cdn_deployment_aws
137+
with:
138+
artifact: uid2SDK-development-${{ needs.build.outputs.sdkVersion}}
139+
invalidate_paths: '/uid2-sdk-${{ needs.build.outputs.sdkVersion}}.js'
140+
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}
141+
aws_bucket_name: ${{ secrets.S3_BUCKET }}
142+
aws_distribution_id: ${{ secrets.AWS_DISTRIBUTION_ID }}
143+
144+
approval-to-deploy:
145+
name: Approval To Deploy
146+
needs: [cdn-deployment-test]
147+
runs-on: ubuntu-latest
148+
environment: production
149+
steps:
150+
- name: Approval to deploy
151+
shell: bash
152+
run: echo "Approved"
153+
154+
# Consolidated CDN Deployment with Matrix
155+
cdn-deployment:
156+
if: inputs.publish_to_cdn
157+
needs: [build, incrementVersionNumber, approval-to-deploy]
158+
runs-on: ubuntu-latest
159+
permissions:
160+
id-token: write
161+
strategy:
162+
matrix:
163+
include:
164+
# UID2 Environments
165+
- product: uid2
166+
github_env: uid2-integ
167+
build_type: development
168+
- product: uid2
169+
github_env: uid2-prod
170+
build_type: production
171+
# EUID Environments
172+
- product: euid
173+
github_env: euid-integ
174+
build_type: development
175+
- product: euid
176+
github_env: euid-prod
177+
build_type: production
178+
environment: ${{ matrix.github_env }}
179+
steps:
180+
- uses: actions/checkout@v4
181+
with:
182+
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
183+
- uses: ./.github/actions/cdn_deployment_aws
184+
with:
185+
artifact: ${{ matrix.product }}SDK-${{ matrix.build_type }}-${{ needs.build.outputs.sdkVersion}}
186+
invalidate_paths: '/${{ matrix.product }}-sdk-${{ needs.build.outputs.sdkVersion}}.js'
187+
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}
188+
aws_bucket_name: ${{ secrets.S3_BUCKET }}
189+
aws_distribution_id: ${{ secrets.AWS_DISTRIBUTION_ID }}

.github/workflows/secureSignal-cd.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ jobs:
7474
- name: Deploy UID2 Secure Signals to CDN
7575
uses: ./.github/actions/cdn_deployment_aws
7676
with:
77-
environment: ${{ matrix.environment }}
7877
artifact: ${{ (matrix.environment == 'integ' && 'development') || matrix.environment }}Uid2SecureSignalScript
7978
invalidate_paths: '/uid2SecureSignal.js'
8079
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
@@ -83,7 +82,6 @@ jobs:
8382
- name: Deploy EUID Secure Signals to CDN
8483
uses: ./.github/actions/cdn_deployment_aws
8584
with:
86-
environment: ${{ matrix.environment }}
8785
artifact: ${{ (matrix.environment == 'integ' && 'development') || matrix.environment }}EuidSecureSignalScript
8886
invalidate_paths: '/euidSecureSignal.js'
8987
aws_account_id: ${{ vars.EUID_AWS_ACCOUNT_ID }}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Release UID2/EUID Secure Signal Package to CDN (Five Environments)
2+
run-name: ${{ github.action_ref == 'refs/head/main' && 'Release' || 'Publish Pre-release' }} UID2/EUID Secure Signal Package to CDN (Five Environments) by @${{ github.actor }}
3+
4+
on:
5+
workflow_dispatch:
6+
7+
env:
8+
WORKING_DIR: ./
9+
10+
jobs:
11+
verify:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
uid2_modified: ${{ steps.verify_uid2.outputs.any_modified }}
15+
euid_modified: ${{ steps.verify_euid.outputs.any_modified }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Check for change to src/secureSignalUid2.ts
19+
id: verify_uid2
20+
uses: tj-actions/changed-files@v41
21+
with:
22+
files: src/secureSignalUid2.ts
23+
- name: Check for change to src/secureSignalEuid.ts
24+
id: verify_euid
25+
uses: tj-actions/changed-files@v41
26+
with:
27+
files: src/secureSignalEuid.ts
28+
29+
build:
30+
needs: [verify]
31+
runs-on: ubuntu-latest
32+
strategy:
33+
matrix:
34+
node-version: [20.x]
35+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
36+
target: [development, production]
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Use Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
cache: 'npm'
45+
cache-dependency-path: ${{ env.WORKING_DIR }}/package-lock.json
46+
- name: Install dependencies
47+
run: npm install
48+
- name: Build
49+
run: npm run build:esp -- --mode=${{ matrix.target }}
50+
- name: Upload UID2 Secure Signals Files
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: ${{ matrix.target }}Uid2SecureSignalScript
54+
path: ./dist/uid2SecureSignal.js
55+
- name: Upload EUID Secure Signals Files
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: ${{ matrix.target }}EuidSecureSignalScript
59+
path: ./dist/euidSecureSignal.js
60+
61+
# Test Environment - UID2 only (first deployment)
62+
deployment-test:
63+
needs: [build]
64+
runs-on: ubuntu-latest
65+
permissions:
66+
id-token: write
67+
environment: test
68+
steps:
69+
- uses: actions/checkout@v4
70+
- name: Deploy UID2 Secure Signals to Test CDN
71+
uses: ./.github/actions/cdn_deployment_aws
72+
with:
73+
artifact: developmentUid2SecureSignalScript
74+
invalidate_paths: '/uid2SecureSignal.js'
75+
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}
76+
aws_bucket_name: ${{ secrets.S3_BUCKET }}
77+
aws_distribution_id: ${{ secrets.AWS_DISTRIBUTION_ID }}
78+
79+
approval-to-deploy:
80+
name: Approval To Deploy to All Environments
81+
needs: [deployment-test]
82+
runs-on: ubuntu-latest
83+
environment: production
84+
steps:
85+
- name: Approval to deploy
86+
shell: bash
87+
run: echo "Approved for deployment to all environments"
88+
89+
# Matrix Deployment for All Environments
90+
deployment-matrix:
91+
needs: [build, approval-to-deploy]
92+
runs-on: ubuntu-latest
93+
permissions:
94+
id-token: write
95+
strategy:
96+
matrix:
97+
include:
98+
# UID2 Environments
99+
- product: uid2
100+
github_env: uid2-integ
101+
build_type: development
102+
file_name: uid2SecureSignal.js
103+
- product: uid2
104+
github_env: uid2-prod
105+
build_type: production
106+
file_name: uid2SecureSignal.js
107+
# EUID Environments
108+
- product: euid
109+
github_env: euid-integ
110+
build_type: development
111+
file_name: euidSecureSignal.js
112+
- product: euid
113+
github_env: euid-prod
114+
build_type: production
115+
file_name: euidSecureSignal.js
116+
environment: ${{ matrix.github_env }}
117+
steps:
118+
- uses: actions/checkout@v4
119+
- name: Deploy ${{ matrix.product == 'uid2' && 'UID2' || 'EUID' }} Secure Signals to ${{ matrix.build_type == 'development' && 'Integration' || 'Production' }} CDN
120+
uses: ./.github/actions/cdn_deployment_aws
121+
with:
122+
artifact: ${{ matrix.build_type }}${{ matrix.product == 'uid2' && 'Uid2' || 'Euid' }}SecureSignalScript
123+
invalidate_paths: '/${{ matrix.file_name }}'
124+
aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }}
125+
aws_bucket_name: ${{ secrets.S3_BUCKET }}
126+
aws_distribution_id: ${{ secrets.AWS_DISTRIBUTION_ID }}

0 commit comments

Comments
 (0)