Skip to content

Commit 917c71a

Browse files
committed
xuy-UID2-6234-move-release-pipeline
1 parent 31ed3fe commit 917c71a

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Build SDK Package
2+
run-name: ${{ inputs.release_type == 'Snapshot' && 'Build Pre-release' || format('Build {0}', inputs.release_type)}} SDK Package 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+
17+
jobs:
18+
incrementVersionNumber:
19+
uses: IABTechLab/uid2-shared-actions/.github/workflows/shared-increase-version-number.yaml@v2
20+
with:
21+
release_type: ${{ inputs.release_type }}
22+
secrets: inherit
23+
24+
build:
25+
runs-on: ubuntu-latest
26+
needs: [incrementVersionNumber]
27+
strategy:
28+
matrix:
29+
node-version: [20.x]
30+
target: [development, production]
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
ref: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
35+
- name: Use Node.js ${{ matrix.node-version }}
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ matrix.node-version }}
39+
- name: Get Package Version
40+
id: version
41+
run: |
42+
echo "package_version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT
43+
- name: Install dependencies
44+
run: npm install
45+
- name: Build SDK for CDN
46+
run: npm run build -- --mode=${{ matrix.target }}
47+
- name: Build NPM Package
48+
if: matrix.target == 'production'
49+
run: npm run build-package
50+
51+
# Upload SDK artifacts for CDN
52+
- name: Upload UID2 SDK artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: uid2SDK-${{ matrix.target }}-${{ steps.version.outputs.package_version }}
56+
path: ./dist/uid2-sdk-${{ steps.version.outputs.package_version }}.js
57+
retention-days: 30
58+
59+
- name: Upload EUID SDK artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: euidSDK-${{ matrix.target }}-${{ steps.version.outputs.package_version }}
63+
path: ./dist/euid-sdk-${{ steps.version.outputs.package_version }}.js
64+
retention-days: 30
65+
66+
# Upload NPM package artifacts
67+
- name: Upload UID2 NPM package
68+
if: matrix.target == 'production'
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: uid2-npm-package-${{ steps.version.outputs.package_version }}
72+
path: ./dist/uid2-npm/
73+
retention-days: 30
74+
75+
- name: Upload EUID NPM package
76+
if: matrix.target == 'production'
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: euid-npm-package-${{ steps.version.outputs.package_version }}
80+
path: ./dist/euid-npm/
81+
retention-days: 30
82+
83+
outputs:
84+
sdkVersion: ${{ steps.version.outputs.package_version }}
85+
git_tag: ${{ needs.incrementVersionNumber.outputs.git_tag_or_hash }}
86+
new_version: ${{ needs.incrementVersionNumber.outputs.new_version }}
87+
88+
createNpmJsRelease:
89+
needs: [incrementVersionNumber, build]
90+
runs-on: ubuntu-latest
91+
steps:
92+
- name: Build Changelog
93+
id: github_release_changelog
94+
uses: mikepenz/release-changelog-builder-action@v4
95+
with:
96+
toTag: v${{ needs.incrementVersionNumber.outputs.new_version }}
97+
configurationJson: |
98+
{
99+
"pr_template": " - #{{TITLE}} - ( PR: ##{{NUMBER}} )"
100+
}
101+
- name: Create Release Notes
102+
uses: softprops/action-gh-release@v2
103+
with:
104+
name: v${{ needs.incrementVersionNumber.outputs.new_version }}
105+
body: ${{ steps.github_release_changelog.outputs.changelog }}
106+
draft: true
107+
108+
build-summary:
109+
needs: [build, incrementVersionNumber]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Build Summary
113+
run: |
114+
echo "## Build Complete! 🎉" >> $GITHUB_STEP_SUMMARY
115+
echo "" >> $GITHUB_STEP_SUMMARY
116+
echo "**Version:** ${{ needs.build.outputs.sdkVersion }}" >> $GITHUB_STEP_SUMMARY
117+
echo "**Git Tag:** ${{ needs.build.outputs.git_tag }}" >> $GITHUB_STEP_SUMMARY
118+
echo "" >> $GITHUB_STEP_SUMMARY
119+
echo "### Artifacts Built:" >> $GITHUB_STEP_SUMMARY
120+
echo "- ✅ uid2SDK-development-${{ needs.build.outputs.sdkVersion }}" >> $GITHUB_STEP_SUMMARY
121+
echo "- ✅ uid2SDK-production-${{ needs.build.outputs.sdkVersion }}" >> $GITHUB_STEP_SUMMARY
122+
echo "- ✅ euidSDK-development-${{ needs.build.outputs.sdkVersion }}" >> $GITHUB_STEP_SUMMARY
123+
echo "- ✅ euidSDK-production-${{ needs.build.outputs.sdkVersion }}" >> $GITHUB_STEP_SUMMARY
124+
echo "- ✅ uid2-npm-package-${{ needs.build.outputs.sdkVersion }}" >> $GITHUB_STEP_SUMMARY
125+
echo "- ✅ euid-npm-package-${{ needs.build.outputs.sdkVersion }}" >> $GITHUB_STEP_SUMMARY
126+
echo "" >> $GITHUB_STEP_SUMMARY
127+
echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY
128+
echo "Run the **Publish SDK Package** workflow in the private repo to deploy these artifacts." >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)