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 :
28- - name : Checkout Contrib Repo @ SHA - ${{ github.sha }}
35+ - name : Checkout Repo @ SHA - ${{ github.sha }}
2936 uses : actions/checkout@v4
3037
3138 - name : Check main build status
5663 package_name : aws-distro-opentelemetry-node-autoinstrumentation
5764 os : ubuntu-latest
5865
66+ - name : Upload SDK Tarball
67+ uses : actions/upload-artifact@v4
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+ run : |
85+ IFS=',' read -ra REGIONS <<< "${{ github.event.inputs.aws_region }}"
86+ MATRIX="["
87+ for region in "${REGIONS[@]}"; do
88+ trimmed_region=$(echo "$region" | xargs)
89+ MATRIX+="\"$trimmed_region\","
90+ done
91+ MATRIX="${MATRIX%,}]"
92+ echo ${MATRIX}
93+ echo "aws_regions_json=${MATRIX}" >> $GITHUB_OUTPUT
94+ - name : Checkout Repo @ SHA - ${{ github.sha }}
95+ uses : actions/checkout@v4
96+ - name : Setup Node
97+ uses : actions/setup-node@v4
98+ with :
99+ node-version : 22
100+ - name : NPM Clean Install
101+ # https://docs.npmjs.com/cli/v10/commands/npm-ci
102+ run : npm ci
103+ - name : Compile all NPM projects
104+ run : npm run compile
105+ - name : Build Lambda Layer
106+ run : npm run build-lambda
107+ - name : upload layer
108+ uses : actions/upload-artifact@v4
109+ with :
110+ name : layer.zip
111+ path : lambda-layer/packages/layer/build/layer.zip
112+
113+ publish-sdk :
114+ needs : [build-sdk, build-layer]
115+ runs-on : ubuntu-latest
116+ steps :
117+ - name : Checkout Repo @ SHA - ${{ github.sha }}
118+ uses : actions/checkout@v4
62119
63120 - name : Configure AWS credentials for private ECR
64121 uses : aws-actions/configure-aws-credentials@v4
82139 with :
83140 registry : public.ecr.aws
84141
85-
86142 # Publish to public ECR
87143 - name : Build and push public ECR image
88144 uses : docker/build-push-action@v5
@@ -105,37 +161,223 @@ jobs:
105161 tags : |
106162 ${{ env.RELEASE_PRIVATE_REPOSITORY }}:v${{ github.event.inputs.version }}
107163
108- - name : Get SHA256 checksum of release artifact
109- id : get_sha256
164+ # Publish '@aws/aws-distro-opentelemetry-node-autoinstrumentation' to npm
165+ - name : Publish autoinstrumentation to npm
166+ working-directory : aws-distro-opentelemetry-node-autoinstrumentation
167+ env :
168+ NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN}}
169+ NPM_CONFIG_PROVENANCE : true
170+ run : npm publish
171+
172+ publish-layer-prod :
173+ runs-on : ubuntu-latest
174+ needs : [build-layer, publish-sdk]
175+ strategy :
176+ matrix :
177+ aws_region : ${{ fromJson(needs.build-layer.outputs.aws_regions_json) }}
178+ steps :
179+ - name : role arn
180+ env :
181+ LEGACY_COMMERCIAL_REGIONS : ${{ env.LEGACY_COMMERCIAL_REGIONS }}
182+ run : |
183+ LEGACY_COMMERCIAL_REGIONS_ARRAY=(${LEGACY_COMMERCIAL_REGIONS//,/ })
184+ FOUND=false
185+ for REGION in "${LEGACY_COMMERCIAL_REGIONS_ARRAY[@]}"; do
186+ if [[ "$REGION" == "${{ matrix.aws_region }}" ]]; then
187+ FOUND=true
188+ break
189+ fi
190+ done
191+ if [ "$FOUND" = true ]; then
192+ echo "Found ${{ matrix.aws_region }} in LEGACY_COMMERCIAL_REGIONS"
193+ SECRET_KEY="LAMBDA_LAYER_RELEASE"
194+ else
195+ echo "Not found ${{ matrix.aws_region }} in LEGACY_COMMERCIAL_REGIONS"
196+ SECRET_KEY="${{ matrix.aws_region }}_LAMBDA_LAYER_RELEASE"
197+ fi
198+ SECRET_KEY=${SECRET_KEY//-/_}
199+ echo "SECRET_KEY=${SECRET_KEY}" >> $GITHUB_ENV
200+ -
uses :
aws-actions/[email protected] 201+ with :
202+ role-to-assume : ${{ secrets[env.SECRET_KEY] }}
203+ role-duration-seconds : 1200
204+ aws-region : ${{ matrix.aws_region }}
205+ - name : Get s3 bucket name for release
206+ run : |
207+ echo BUCKET_NAME=nodejs-lambda-layer-${{ github.run_id }}-${{ matrix.aws_region }} | tee --append $GITHUB_ENV
208+ - name : download layer.zip
209+ uses : actions/download-artifact@v4
210+ with :
211+ name : layer.zip
212+ - name : publish
213+ run : |
214+ aws s3 mb s3://${{ env.BUCKET_NAME }}
215+ aws s3 cp layer.zip s3://${{ env.BUCKET_NAME }}
216+ layerARN=$(
217+ aws lambda publish-layer-version \
218+ --layer-name ${{ env.LAYER_NAME }} \
219+ --content S3Bucket=${{ env.BUCKET_NAME }},S3Key=layer.zip \
220+ --compatible-runtimes nodejs18.x nodejs20.x nodejs22.x \
221+ --compatible-architectures "arm64" "x86_64" \
222+ --license-info "Apache-2.0" \
223+ --description "AWS Distro of OpenTelemetry Lambda Layer for NodeJs Runtime" \
224+ --query 'LayerVersionArn' \
225+ --output text
226+ )
227+ echo $layerARN
228+ echo "LAYER_ARN=${layerARN}" >> $GITHUB_ENV
229+ mkdir ${{ env.LAYER_NAME }}
230+ echo $layerARN > ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
231+ cat ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
232+ - name : public layer
233+ run : |
234+ layerVersion=$(
235+ aws lambda list-layer-versions \
236+ --layer-name ${{ env.LAYER_NAME }} \
237+ --query 'max_by(LayerVersions, &Version).Version'
238+ )
239+ aws lambda add-layer-version-permission \
240+ --layer-name ${{ env.LAYER_NAME }} \
241+ --version-number $layerVersion \
242+ --principal "*" \
243+ --statement-id publish \
244+ --action lambda:GetLayerVersion
245+ - name : upload layer arn artifact
246+ if : ${{ success() }}
247+ uses : actions/upload-artifact@v4
248+ with :
249+ name : ${{ env.LAYER_NAME }}-${{ matrix.aws_region }}
250+ path : ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
251+ - name : clean s3
252+ if : always()
253+ run : |
254+ aws s3 rb --force s3://${{ env.BUCKET_NAME }}
255+
256+ generate-lambda-release-note :
257+ runs-on : ubuntu-latest
258+ needs : publish-layer-prod
259+ outputs :
260+ layer-note : ${{ steps.layer-note.outputs.layer-note }}
261+ steps :
262+ - name : Checkout Repo @ SHA - ${{ github.sha }}
263+ uses : actions/checkout@v4
264+ - uses : hashicorp/setup-terraform@v2
265+ - name : download layerARNs
266+ uses : actions/download-artifact@v4
267+ with :
268+ pattern : ${{ env.LAYER_NAME }}-*
269+ path : ${{ env.LAYER_NAME }}
270+ merge-multiple : true
271+ - name : show layerARNs
272+ run : |
273+ for file in ${{ env.LAYER_NAME }}/*
274+ do
275+ echo $file
276+ cat $file
277+ done
278+ - name : generate layer-note
279+ id : layer-note
280+ working-directory : ${{ env.LAYER_NAME }}
110281 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-
282+ echo "| Region | Layer ARN |" >> ../layer-note
283+ echo "| ---- | ---- |" >> ../layer-note
284+ for file in *
285+ do
286+ read arn < $file
287+ echo "| " $file " | " $arn " |" >> ../layer-note
288+ done
289+ cd ..
290+ {
291+ echo "layer-note<<EOF"
292+ cat layer-note
293+ echo "EOF"
294+ } >> $GITHUB_OUTPUT
295+ cat layer-note
296+ - name : generate tf layer
297+ working-directory : ${{ env.LAYER_NAME }}
298+ run : |
299+ echo "locals {" >> ../layer_arns.tf
300+ echo " sdk_layer_arns = {" >> ../layer_arns.tf
301+ for file in *
302+ do
303+ read arn < $file
304+ echo " \""$file"\" = \""$arn"\"" >> ../layer_arns.tf
305+ done
306+ cd ..
307+ echo " }" >> layer_arns.tf
308+ echo "}" >> layer_arns.tf
309+ terraform fmt layer_arns.tf
310+ cat layer_arns.tf
311+ - name : generate layer ARN constants for CDK
312+ working-directory : ${{ env.LAYER_NAME }}
313+ run : |
314+ echo "{" > ../layer_cdk
315+ for file in *; do
316+ read arn < "$file"
317+ echo " \"$file\": \"$arn\"," >> ../layer_cdk
318+ done
319+ echo "}" >> ../layer_cdk
320+ cat ../layer_cdk
321+
322+ publish-github :
323+ needs : generate-lambda-release-note
324+ runs-on : ubuntu-latest
325+ steps :
326+ - name : Checkout Repo @ SHA - ${{ github.sha }}
327+ uses : actions/checkout@v4
328+
329+ - name : Download SDK artifact
330+ uses : actions/download-artifact@v4
331+ with :
332+ name : ${{ env.ARTIFACT_NAME }}
333+
334+ - name : Download layer.zip artifact
335+ uses : actions/download-artifact@v4
336+ with :
337+ name : layer.zip
338+
113339 # Publish to GitHub releases
114340 - name : Create GH release
115341 id : create_release
116342 env :
117- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
343+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
118344 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
345+ # Generate dependency versions from package.json
346+ DEPS=$(node -e "
347+ const pkg = require('./aws-distro-opentelemetry-node-autoinstrumentation/package.json');
348+ const deps = Object.entries(pkg.dependencies || {})
349+ .map(([name, version]) => \`- \\\`\${name}\\\` - \${version}\`)
350+ .join('\n');
351+ console.log(deps);
352+ ")
353+
354+ # Create release notes
355+ cat > release_notes.md << EOF
356+ This release contains the following upstream components:
357+
358+ $DEPS
359+
360+ This release also publishes to public ECR and NPM.
361+ * See ADOT node auto-instrumentation Docker image v${{ github.event.inputs.version }} in our public ECR repository:
362+ https://gallery.ecr.aws/aws-observability/adot-autoinstrumentation-node
363+ * See version ${{ github.event.inputs.version }} in our NPM repository:
364+ https://www.npmjs.com/package/@aws/aws-distro-opentelemetry-node-autoinstrumentation
365+
366+ This release also includes the AWS OpenTelemetry Lambda Layer for JavaScript version ${{ github.event.inputs.version }}-$(echo $GITHUB_SHA | cut -c1-7).
367+
368+ Lambda Layer ARNs:
369+ ${{ needs.generate-lambda-release-note.outputs.layer-note }}
370+ EOF
371+
372+ shasum -a 256 ${{ env.ARTIFACT_NAME }} > ${{ env.ARTIFACT_NAME }}.sha256
373+ shasum -a 256 layer.zip > layer.zip.sha256
124374
125375 gh release create --target "$GITHUB_REF_NAME" \
126376 --title "Release v${{ github.event.inputs.version }}" \
377+ --notes-file release_notes.md \
127378 --draft \
128379 "v${{ github.event.inputs.version }}" \
129- aws-distro-opentelemetry-node-autoinstrumentation/ ${{ env.ARTIFACT_NAME }} \
380+ ${{ env.ARTIFACT_NAME }} \
130381 ${{ 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-
382+ layer.zip \
383+ layer.zip.sha256
0 commit comments