55 version :
66 description : The version to tag the release with, e.g., 1.2.0
77 required : true
8+ aws_region :
9+ description : ' Deploy lambda layer to aws regions'
10+ required : true
11+ default : ' us-east-1, us-east-2, us-west-1, us-west-2, ap-south-1, ap-northeast-3, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-northeast-1, ca-central-1, eu-central-1, eu-west-1, eu-west-2, eu-west-3, eu-north-1, sa-east-1, af-south-1, ap-east-1, ap-south-2, ap-southeast-3, ap-southeast-4, eu-central-2, eu-south-1, eu-south-2, il-central-1, me-central-1, me-south-1, ap-southeast-5, ap-southeast-7, mx-central-1, ca-west-1, cn-north-1, cn-northwest-1'
812
913env :
1014 AWS_DEFAULT_REGION : us-east-1
1418 RELEASE_PRIVATE_REPOSITORY : 020628701572.dkr.ecr.us-west-2.amazonaws.com/adot-autoinstrumentation-node
1519 RELEASE_PRIVATE_REGISTRY : 020628701572.dkr.ecr.us-west-2.amazonaws.com
1620 PACKAGE_NAME : aws-distro-opentelemetry-node-autoinstrumentation
17- ARTIFACT_NAME : aws-aws-distro-opentelemetry-node-autoinstrumentation-${{ github.event.inputs.version }}.tgz
21+ ARTIFACT_NAME : aws-aws-distro-opentelemetry-node-autoinstrumentation-${{ github.event.inputs.version }}.tgz
22+ # Legacy list of commercial regions to deploy to. New regions should NOT be added here, and instead should be added to the `aws_region` default input to the workflow.
23+ LEGACY_COMMERCIAL_REGIONS : us-east-1, us-east-2, us-west-1, us-west-2, ap-south-1, ap-northeast-3, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-northeast-1, ca-central-1, eu-central-1, eu-west-1, eu-west-2, eu-west-3, eu-north-1, sa-east-1
24+ LAYER_NAME : AWSOpenTelemetryDistroJs
1825
1926permissions :
2027 id-token : write
2128 contents : write
2229
2330jobs :
24- build :
31+ build-sdk :
2532 environment : Release
2633 runs-on : ubuntu-latest
2734 steps :
5663 package_name : aws-distro-opentelemetry-node-autoinstrumentation
5764 os : ubuntu-latest
5865
66+ - name : Upload SDK Tarball
67+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
68+ with :
69+ name : ${{ env.ARTIFACT_NAME }}
70+ path : aws-distro-opentelemetry-node-autoinstrumentation/${{ env.ARTIFACT_NAME }}
71+
5972 # TODO: Add some sort of smoke/integration testing before we go
6073 # release the artifacts. adot java for reference:
6174 # https://github.com/aws-observability/aws-otel-java-instrumentation/tree/93870a550ac30988fbdd5d3bf1e8f9f1b37916f5/smoke-tests
75+
76+ build-layer :
77+ needs : build-sdk
78+ runs-on : ubuntu-latest
79+ outputs :
80+ aws_regions_json : ${{ steps.set-matrix.outputs.aws_regions_json }}
81+ steps :
82+ - name : Set up regions matrix
83+ id : set-matrix
84+ env :
85+ AWS_REGIONS : ${{ github.event.inputs.aws_region }}
86+ run : |
87+ IFS=',' read -ra REGIONS <<< "$AWS_REGIONS"
88+ MATRIX="["
89+ for region in "${REGIONS[@]}"; do
90+ trimmed_region=$(echo "$region" | xargs)
91+ MATRIX+="\"$trimmed_region\","
92+ done
93+ MATRIX="${MATRIX%,}]"
94+ echo ${MATRIX}
95+ echo "aws_regions_json=${MATRIX}" >> $GITHUB_OUTPUT
96+ - name : Checkout Repo @ SHA - ${{ github.sha }}
97+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
98+ - name : Setup Node
99+ uses : actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
100+ with :
101+ node-version : 22
102+ - name : NPM Clean Install
103+ # https://docs.npmjs.com/cli/v10/commands/npm-ci
104+ run : npm ci
105+ - name : Compile all NPM projects
106+ run : npm run compile
107+ - name : Build Lambda Layer
108+ run : npm run build-lambda
109+ - name : upload layer
110+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
111+ with :
112+ name : layer.zip
113+ path : lambda-layer/packages/layer/build/layer.zip
114+
115+ publish-sdk :
116+ needs : [build-sdk, build-layer]
117+ runs-on : ubuntu-latest
118+ steps :
119+ - name : Checkout Repo @ SHA - ${{ github.sha }}
120+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
62121
63122 - name : Configure AWS credentials for private ECR
64123 uses : aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # v5.0.0
82141 with :
83142 registry : public.ecr.aws
84143
85-
86144 # Publish to public ECR
87145 - name : Build and push public ECR image
88146 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
@@ -105,37 +163,244 @@ jobs:
105163 tags : |
106164 ${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ github.event.inputs.version }}
107165
108- - name : Get SHA256 checksum of release artifact
109- id : get_sha256
166+ # Publish '@aws/aws-distro-opentelemetry-node-autoinstrumentation' to npm
167+ - name : Publish autoinstrumentation to npm
168+ working-directory : aws-distro-opentelemetry-node-autoinstrumentation
169+ env :
170+ NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
171+ NPM_CONFIG_PROVENANCE : true
172+ run : npm publish
173+
174+ publish-layer-prod :
175+ runs-on : ubuntu-latest
176+ needs : [build-layer, publish-sdk]
177+ strategy :
178+ matrix :
179+ aws_region : ${{ fromJson(needs.build-layer.outputs.aws_regions_json) }}
180+ steps :
181+ - name : role arn
182+ env :
183+ LEGACY_COMMERCIAL_REGIONS : ${{ env.LEGACY_COMMERCIAL_REGIONS }}
110184 run : |
111- shasum -a 256 aws-distro-opentelemetry-node-autoinstrumentation/${{ env.ARTIFACT_NAME }} | sed "s|aws-distro-opentelemetry-node-autoinstrumentation/||" > ${{ env.ARTIFACT_NAME }}.sha256
112-
185+ LEGACY_COMMERCIAL_REGIONS_ARRAY=(${LEGACY_COMMERCIAL_REGIONS//,/ })
186+ FOUND=false
187+ for REGION in "${LEGACY_COMMERCIAL_REGIONS_ARRAY[@]}"; do
188+ if [[ "$REGION" == "${{ matrix.aws_region }}" ]]; then
189+ FOUND=true
190+ break
191+ fi
192+ done
193+ if [ "$FOUND" = true ]; then
194+ echo "Found ${{ matrix.aws_region }} in LEGACY_COMMERCIAL_REGIONS"
195+ SECRET_KEY="LAMBDA_LAYER_RELEASE"
196+ else
197+ echo "Not found ${{ matrix.aws_region }} in LEGACY_COMMERCIAL_REGIONS"
198+ SECRET_KEY="${{ matrix.aws_region }}_LAMBDA_LAYER_RELEASE"
199+ fi
200+ SECRET_KEY=${SECRET_KEY//-/_}
201+ echo "SECRET_KEY=${SECRET_KEY}" >> $GITHUB_ENV
202+ - uses : aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # v5.0.0
203+ with :
204+ role-to-assume : ${{ secrets[env.SECRET_KEY] }}
205+ role-duration-seconds : 1200
206+ aws-region : ${{ matrix.aws_region }}
207+ - name : Get s3 bucket name for release
208+ run : |
209+ echo BUCKET_NAME=nodejs-lambda-layer-${{ github.run_id }}-${{ matrix.aws_region }} | tee --append $GITHUB_ENV
210+ - name : download layer.zip
211+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
212+ with :
213+ name : layer.zip
214+ - name : publish
215+ run : |
216+ aws s3 mb s3://${{ env.BUCKET_NAME }}
217+ aws s3 cp layer.zip s3://${{ env.BUCKET_NAME }}
218+ layerARN=$(
219+ aws lambda publish-layer-version \
220+ --layer-name ${{ env.LAYER_NAME }} \
221+ --content S3Bucket=${{ env.BUCKET_NAME }},S3Key=layer.zip \
222+ --compatible-runtimes nodejs18.x nodejs20.x nodejs22.x \
223+ --compatible-architectures "arm64" "x86_64" \
224+ --license-info "Apache-2.0" \
225+ --description "AWS Distro of OpenTelemetry Lambda Layer for NodeJs Runtime" \
226+ --query 'LayerVersionArn' \
227+ --output text
228+ )
229+ echo $layerARN
230+ echo "LAYER_ARN=${layerARN}" >> $GITHUB_ENV
231+ mkdir ${{ env.LAYER_NAME }}
232+ echo $layerARN > ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
233+ cat ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
234+ - name : public layer
235+ run : |
236+ layerVersion=$(
237+ aws lambda list-layer-versions \
238+ --layer-name ${{ env.LAYER_NAME }} \
239+ --query 'max_by(LayerVersions, &Version).Version'
240+ )
241+ aws lambda add-layer-version-permission \
242+ --layer-name ${{ env.LAYER_NAME }} \
243+ --version-number $layerVersion \
244+ --principal "*" \
245+ --statement-id publish \
246+ --action lambda:GetLayerVersion
247+ - name : upload layer arn artifact
248+ if : ${{ success() }}
249+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
250+ with :
251+ name : ${{ env.LAYER_NAME }}-${{ matrix.aws_region }}
252+ path : ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
253+ - name : clean s3
254+ if : always()
255+ run : |
256+ aws s3 rb --force s3://${{ env.BUCKET_NAME }}
257+
258+ generate-lambda-release-note :
259+ runs-on : ubuntu-latest
260+ needs : publish-layer-prod
261+ outputs :
262+ layer-note : ${{ steps.layer-note.outputs.layer-note }}
263+ steps :
264+ - name : Checkout Repo @ SHA - ${{ github.sha }}
265+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
266+ - uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
267+ - name : download layerARNs
268+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
269+ with :
270+ pattern : ${{ env.LAYER_NAME }}-*
271+ path : ${{ env.LAYER_NAME }}
272+ merge-multiple : true
273+ - name : show layerARNs
274+ run : |
275+ for file in ${{ env.LAYER_NAME }}/*
276+ do
277+ echo $file
278+ cat $file
279+ done
280+ - name : generate layer-note
281+ id : layer-note
282+ working-directory : ${{ env.LAYER_NAME }}
283+ run : |
284+ echo "| Region | Layer ARN |" >> ../layer-note
285+ echo "| ---- | ---- |" >> ../layer-note
286+ for file in *
287+ do
288+ read arn < $file
289+ echo "| " $file " | " $arn " |" >> ../layer-note
290+ done
291+ cd ..
292+ {
293+ echo "layer-note<<EOF"
294+ cat layer-note
295+ echo "EOF"
296+ } >> $GITHUB_OUTPUT
297+ cat layer-note
298+ - name : generate tf layer
299+ working-directory : ${{ env.LAYER_NAME }}
300+ run : |
301+ echo "locals {" >> ../layer_arns.tf
302+ echo " sdk_layer_arns = {" >> ../layer_arns.tf
303+ for file in *
304+ do
305+ read arn < $file
306+ echo " \""$file"\" = \""$arn"\"" >> ../layer_arns.tf
307+ done
308+ cd ..
309+ echo " }" >> layer_arns.tf
310+ echo "}" >> layer_arns.tf
311+ terraform fmt layer_arns.tf
312+ cat layer_arns.tf
313+ - name : generate layer ARN constants for CDK
314+ working-directory : ${{ env.LAYER_NAME }}
315+ run : |
316+ echo "{" > ../layer_cdk
317+ for file in *; do
318+ read arn < "$file"
319+ echo " \"$file\": \"$arn\"," >> ../layer_cdk
320+ done
321+ echo "}" >> ../layer_cdk
322+ cat ../layer_cdk
323+
324+ publish-github :
325+ needs : generate-lambda-release-note
326+ runs-on : ubuntu-latest
327+ steps :
328+ - name : Checkout Repo @ SHA - ${{ github.sha }}
329+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
330+
331+ - name : Download SDK artifact
332+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
333+ with :
334+ name : ${{ env.ARTIFACT_NAME }}
335+
336+ - name : Download layer.zip artifact
337+ uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
338+ with :
339+ name : layer.zip
340+
113341 # Publish to GitHub releases
114342 - name : Create GH release
115343 id : create_release
116344 env :
117- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
345+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
346+ VERSION : ${{ github.event.inputs.version }}
118347 run : |
119- # Download layer.zip from existing latest tagged SDK release note
120- LATEST_SDK_VERSION=$(gh release list --repo "aws-observability/aws-otel-js-instrumentation" --json tagName,isLatest -q 'map(select(.isLatest==true)) | .[0].tagName')
121- mkdir -p layer_artifact
122- gh release download "$LATEST_SDK_VERSION" --repo "aws-observability/aws-otel-js-instrumentation" --pattern "layer.zip" --dir layer_artifact
123- shasum -a 256 layer_artifact/layer.zip > layer_artifact/layer.zip.sha256
348+ # Generate dependency versions from package.json
349+ DEPS=$(node -e "
350+ const pkg = require('./aws-distro-opentelemetry-node-autoinstrumentation/package.json');
351+ const deps = Object.entries(pkg.dependencies || {})
352+ .map(([name, version]) => \`- \\\`\${name}\\\` - \${version}\`)
353+ .join('\n');
354+ console.log(deps);
355+ ")
356+
357+ # Extract CHANGELOG entries for this version
358+ CHANGELOG_ENTRIES=$(python3 -c "
359+ import re, os
360+ version = os.environ['VERSION']
361+ with open('CHANGELOG.md', 'r') as f:
362+ content = f.read()
363+ version_pattern = rf'## v{re.escape(version)}.*?\n(.*?)(?=\n## |\Z)'
364+ version_match = re.search(version_pattern, content, re.DOTALL)
365+ if version_match:
366+ entries = version_match.group(1).strip()
367+ if entries:
368+ print(entries)
369+ ")
370+
371+ # Create release notes
372+ cat > release_notes.md << EOF
373+ $(if [ -n "$CHANGELOG_ENTRIES" ]; then echo "## What's Changed"; echo "$CHANGELOG_ENTRIES"; echo ""; fi)
374+
375+ ## Upstream Components
376+
377+ $DEPS
378+
379+ ## Release Artifacts
380+
381+ This release publishes to public ECR and NPM.
382+ * See ADOT node auto-instrumentation Docker image v$VERSION in our public ECR repository:
383+ https://gallery.ecr.aws/aws-observability/adot-autoinstrumentation-node
384+ * See version $VERSION in our NPM repository:
385+ https://www.npmjs.com/package/@aws/aws-distro-opentelemetry-node-autoinstrumentation
386+
387+ ## Lambda Layer
388+
389+ This release includes the AWS OpenTelemetry Lambda Layer for JavaScript version $VERSION-$(echo $GITHUB_SHA | cut -c1-7).
390+
391+ Lambda Layer ARNs:
392+ ${{ needs.generate-lambda-release-note.outputs.layer-note }}
393+ EOF
394+
395+ shasum -a 256 ${{ env.ARTIFACT_NAME }} > ${{ env.ARTIFACT_NAME }}.sha256
396+ shasum -a 256 layer.zip > layer.zip.sha256
124397
125398 gh release create --target "$GITHUB_REF_NAME" \
126- --title "Release v${{ github.event.inputs.version }}" \
399+ --title "Release v$VERSION" \
400+ --notes-file release_notes.md \
127401 --draft \
128- "v${{ github.event.inputs.version }} " \
129- aws-distro-opentelemetry-node-autoinstrumentation/ ${{ env.ARTIFACT_NAME }} \
402+ "v$VERSION " \
403+ ${{ env.ARTIFACT_NAME }} \
130404 ${{ env.ARTIFACT_NAME }}.sha256 \
131- layer_artifact/layer.zip \
132- layer_artifact/layer.zip.sha256
133-
134- # Publish '@aws/aws-distro-opentelemetry-node-autoinstrumentation' to npm
135- - name : Publish autoinstrumentation to npm
136- working-directory : aws-distro-opentelemetry-node-autoinstrumentation
137- env :
138- NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
139- NPM_CONFIG_PROVENANCE : true
140- run : npm publish
141-
405+ layer.zip \
406+ layer.zip.sha256
0 commit comments