|
5 | 5 | version: |
6 | 6 | description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1 |
7 | 7 | 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' |
8 | 12 |
|
9 | 13 | env: |
10 | 14 | AWS_PUBLIC_ECR_REGION: us-east-1 |
|
13 | 17 | PUBLIC_REPOSITORY: public.ecr.aws/aws-observability/adot-autoinstrumentation-java |
14 | 18 | PRIVATE_REPOSITORY: 020628701572.dkr.ecr.us-west-2.amazonaws.com/adot-autoinstrumentation-java |
15 | 19 | PRIVATE_REGISTRY: 020628701572.dkr.ecr.us-west-2.amazonaws.com |
16 | | - ARTIFACT_NAME: aws-opentelemetry-agent.jar |
| 20 | + ARTIFACT_NAME: aws-opentelemetry-agent.jar |
| 21 | + # 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. |
| 22 | + 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 |
| 23 | + LAYER_NAME: AWSOpenTelemetryDistroJava |
17 | 24 |
|
18 | 25 | permissions: |
19 | 26 | id-token: write |
20 | 27 | contents: write |
21 | 28 |
|
22 | 29 | jobs: |
23 | | - build: |
| 30 | + build-sdk: |
24 | 31 | environment: Release |
25 | 32 | runs-on: ubuntu-latest |
26 | 33 | steps: |
|
71 | 78 | with: |
72 | 79 | arguments: build integrationTests -PlocalDocker=true -Prelease.version=${{ github.event.inputs.version }} --stacktrace |
73 | 80 |
|
| 81 | + - name: Upload SDK artifact |
| 82 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2 |
| 83 | + with: |
| 84 | + name: ${{ env.ARTIFACT_NAME }} |
| 85 | + path: otelagent/build/libs/aws-opentelemetry-agent-${{ github.event.inputs.version }}.jar |
| 86 | + |
| 87 | + build-layer: |
| 88 | + needs: build-sdk |
| 89 | + runs-on: ubuntu-latest |
| 90 | + outputs: |
| 91 | + aws_regions_json: ${{ steps.set-matrix.outputs.aws_regions_json }} |
| 92 | + steps: |
| 93 | + - name: Set up regions matrix |
| 94 | + id: set-matrix |
| 95 | + run: | |
| 96 | + IFS=',' read -ra REGIONS <<< "${{ github.event.inputs.aws_region }}" |
| 97 | + MATRIX="[" |
| 98 | + for region in "${REGIONS[@]}"; do |
| 99 | + trimmed_region=$(echo "$region" | xargs) |
| 100 | + MATRIX+="\"$trimmed_region\"," |
| 101 | + done |
| 102 | + MATRIX="${MATRIX%,}]" |
| 103 | + echo ${MATRIX} |
| 104 | + echo "aws_regions_json=${MATRIX}" >> $GITHUB_OUTPUT |
| 105 | +
|
| 106 | + - name: Checkout Repo @ SHA - ${{ github.sha }} |
| 107 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0 |
| 108 | + |
| 109 | + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 |
| 110 | + with: |
| 111 | + java-version-file: .java-version |
| 112 | + distribution: 'temurin' |
| 113 | + |
| 114 | + - name: Build layers |
| 115 | + working-directory: lambda-layer |
| 116 | + run: | |
| 117 | + ./build-layer.sh |
| 118 | +
|
| 119 | + - name: Upload layer |
| 120 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2 |
| 121 | + with: |
| 122 | + name: layer.zip |
| 123 | + path: lambda-layer/build/distributions/aws-opentelemetry-java-layer.zip |
| 124 | + |
| 125 | + publish-sdk: |
| 126 | + runs-on: ubuntu-latest |
| 127 | + needs: [build-sdk, build-layer] |
| 128 | + steps: |
| 129 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0 |
| 130 | + |
| 131 | + - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 |
| 132 | + with: |
| 133 | + java-version-file: .java-version |
| 134 | + distribution: 'temurin' |
| 135 | + - uses: gradle/actions/wrapper-validation@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3 |
| 136 | + |
| 137 | + - name: Publish patched dependencies to maven local |
| 138 | + uses: ./.github/actions/patch-dependencies |
| 139 | + with: |
| 140 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 141 | + gpg_password: ${{ secrets.GPG_PASSPHRASE }} |
| 142 | + |
74 | 143 | - name: Configure AWS Credentials |
| 144 | + uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0 |
| 145 | + with: |
| 146 | + role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} |
| 147 | + aws-region: ${{ env.AWS_PUBLIC_ECR_REGION }} |
| 148 | + |
| 149 | + - name: Log in to AWS ECR |
| 150 | + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 #v3.5.0 |
| 151 | + with: |
| 152 | + registry: public.ecr.aws |
| 153 | + |
| 154 | + # build the artifact again so that its in the output path expected for building the docker image. |
| 155 | + - name: Build release with Gradle |
| 156 | + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa #v2 |
| 157 | + with: |
| 158 | + arguments: build integrationTests -PlocalDocker=true -Prelease.version=${{ github.event.inputs.version }} --stacktrace |
| 159 | + |
| 160 | + - name: Configure AWS Credentials for public ECR |
75 | 161 | uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0 |
76 | 162 | with: |
77 | 163 | role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN_RELEASE }} |
@@ -137,28 +223,223 @@ jobs: |
137 | 223 | GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
138 | 224 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
139 | 225 |
|
| 226 | + publish-layer-prod: |
| 227 | + runs-on: ubuntu-latest |
| 228 | + needs: [build-layer, publish-sdk] |
| 229 | + strategy: |
| 230 | + matrix: |
| 231 | + aws_region: ${{ fromJson(needs.build-layer.outputs.aws_regions_json) }} |
| 232 | + steps: |
| 233 | + - name: role arn |
| 234 | + env: |
| 235 | + LEGACY_COMMERCIAL_REGIONS: ${{ env.LEGACY_COMMERCIAL_REGIONS }} |
| 236 | + run: | |
| 237 | + LEGACY_COMMERCIAL_REGIONS_ARRAY=(${LEGACY_COMMERCIAL_REGIONS//,/ }) |
| 238 | + FOUND=false |
| 239 | + for REGION in "${LEGACY_COMMERCIAL_REGIONS_ARRAY[@]}"; do |
| 240 | + if [[ "$REGION" == "${{ matrix.aws_region }}" ]]; then |
| 241 | + FOUND=true |
| 242 | + break |
| 243 | + fi |
| 244 | + done |
| 245 | + if [ "$FOUND" = true ]; then |
| 246 | + echo "Found ${{ matrix.aws_region }} in LEGACY_COMMERCIAL_REGIONS" |
| 247 | + SECRET_KEY="LAMBDA_LAYER_RELEASE" |
| 248 | + else |
| 249 | + echo "Not found ${{ matrix.aws_region }} in LEGACY_COMMERCIAL_REGIONS" |
| 250 | + SECRET_KEY="${{ matrix.aws_region }}_LAMBDA_LAYER_RELEASE" |
| 251 | + fi |
| 252 | + SECRET_KEY=${SECRET_KEY//-/_} |
| 253 | + echo "SECRET_KEY=${SECRET_KEY}" >> $GITHUB_ENV |
| 254 | +
|
| 255 | + - uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0 |
| 256 | + with: |
| 257 | + role-to-assume: ${{ secrets[env.SECRET_KEY] }} |
| 258 | + role-duration-seconds: 1200 |
| 259 | + aws-region: ${{ matrix.aws_region }} |
140 | 260 |
|
141 | | - - name: Get SHA256 checksum of release artifact |
142 | | - id: get_sha256 |
| 261 | + - name: Get s3 bucket name for release |
143 | 262 | run: | |
144 | | - cp "otelagent/build/libs/aws-opentelemetry-agent-${{ github.event.inputs.version }}.jar" ${{ env.ARTIFACT_NAME }} |
145 | | - shasum -a 256 ${{ env.ARTIFACT_NAME }} > ${{ env.ARTIFACT_NAME }}.sha256 |
| 263 | + echo BUCKET_NAME=java-lambda-layer-${{ github.run_id }}-${{ matrix.aws_region }} | tee --append $GITHUB_ENV |
| 264 | +
|
| 265 | + - name: download layer.zip |
| 266 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5.0.0 |
| 267 | + with: |
| 268 | + name: layer.zip |
| 269 | + |
| 270 | + - name: publish |
| 271 | + run: | |
| 272 | + aws s3 mb s3://${{ env.BUCKET_NAME }} |
| 273 | + aws s3 cp aws-opentelemetry-java-layer.zip s3://${{ env.BUCKET_NAME }} |
| 274 | + layerARN=$( |
| 275 | + aws lambda publish-layer-version \ |
| 276 | + --layer-name ${{ env.LAYER_NAME }} \ |
| 277 | + --content S3Bucket=${{ env.BUCKET_NAME }},S3Key=aws-opentelemetry-java-layer.zip \ |
| 278 | + --compatible-runtimes java11 java17 java21 \ |
| 279 | + --compatible-architectures "arm64" "x86_64" \ |
| 280 | + --license-info "Apache-2.0" \ |
| 281 | + --description "AWS Distro of OpenTelemetry Lambda Layer for Java Runtime" \ |
| 282 | + --query 'LayerVersionArn' \ |
| 283 | + --output text |
| 284 | + ) |
| 285 | + echo $layerARN |
| 286 | + echo "LAYER_ARN=${layerARN}" >> $GITHUB_ENV |
| 287 | + mkdir ${{ env.LAYER_NAME }} |
| 288 | + echo $layerARN > ${{ env.LAYER_NAME }}/${{ matrix.aws_region }} |
| 289 | + cat ${{ env.LAYER_NAME }}/${{ matrix.aws_region }} |
146 | 290 |
|
147 | | - - name: Create release |
| 291 | + - name: public layer |
| 292 | + run: | |
| 293 | + layerVersion=$( |
| 294 | + aws lambda list-layer-versions \ |
| 295 | + --layer-name ${{ env.LAYER_NAME }} \ |
| 296 | + --query 'max_by(LayerVersions, &Version).Version' |
| 297 | + ) |
| 298 | + aws lambda add-layer-version-permission \ |
| 299 | + --layer-name ${{ env.LAYER_NAME }} \ |
| 300 | + --version-number $layerVersion \ |
| 301 | + --principal "*" \ |
| 302 | + --statement-id publish \ |
| 303 | + --action lambda:GetLayerVersion |
| 304 | +
|
| 305 | + - name: upload layer arn artifact |
| 306 | + if: ${{ success() }} |
| 307 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2 |
| 308 | + with: |
| 309 | + name: ${{ env.LAYER_NAME }}-${{ matrix.aws_region }} |
| 310 | + path: ${{ env.LAYER_NAME }}/${{ matrix.aws_region }} |
| 311 | + |
| 312 | + - name: clean s3 |
| 313 | + if: always() |
| 314 | + run: | |
| 315 | + aws s3 rb --force s3://${{ env.BUCKET_NAME }} |
| 316 | +
|
| 317 | + generate-lambda-release-note: |
| 318 | + runs-on: ubuntu-latest |
| 319 | + needs: publish-layer-prod |
| 320 | + outputs: |
| 321 | + layer-note: ${{ steps.layer-note.outputs.layer-note }} |
| 322 | + steps: |
| 323 | + - name: Checkout Repo @ SHA - ${{ github.sha }} |
| 324 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0 |
| 325 | + - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd #v3.1.2 |
| 326 | + - name: download layerARNs |
| 327 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5.0.0 |
| 328 | + with: |
| 329 | + pattern: ${{ env.LAYER_NAME }}-* |
| 330 | + path: ${{ env.LAYER_NAME }} |
| 331 | + merge-multiple: true |
| 332 | + - name: show layerARNs |
| 333 | + run: | |
| 334 | + for file in ${{ env.LAYER_NAME }}/* |
| 335 | + do |
| 336 | + echo $file |
| 337 | + cat $file |
| 338 | + done |
| 339 | + - name: generate layer-note |
| 340 | + id: layer-note |
| 341 | + working-directory: ${{ env.LAYER_NAME }} |
| 342 | + run: | |
| 343 | + echo "| Region | Layer ARN |" >> ../layer-note |
| 344 | + echo "| ---- | ---- |" >> ../layer-note |
| 345 | + for file in * |
| 346 | + do |
| 347 | + read arn < $file |
| 348 | + echo "| " $file " | " $arn " |" >> ../layer-note |
| 349 | + done |
| 350 | + cd .. |
| 351 | + { |
| 352 | + echo "layer-note<<EOF" |
| 353 | + cat layer-note |
| 354 | + echo "EOF" |
| 355 | + } >> $GITHUB_OUTPUT |
| 356 | + cat layer-note |
| 357 | + - name: generate tf layer |
| 358 | + working-directory: ${{ env.LAYER_NAME }} |
| 359 | + run: | |
| 360 | + echo "locals {" >> ../layer_arns.tf |
| 361 | + echo " sdk_layer_arns = {" >> ../layer_arns.tf |
| 362 | + for file in * |
| 363 | + do |
| 364 | + read arn < $file |
| 365 | + echo " \""$file"\" = \""$arn"\"" >> ../layer_arns.tf |
| 366 | + done |
| 367 | + cd .. |
| 368 | + echo " }" >> layer_arns.tf |
| 369 | + echo "}" >> layer_arns.tf |
| 370 | + terraform fmt layer_arns.tf |
| 371 | + cat layer_arns.tf |
| 372 | + - name: generate layer ARN constants for CDK |
| 373 | + working-directory: ${{ env.LAYER_NAME }} |
| 374 | + run: | |
| 375 | + echo "{" > ../layer_cdk |
| 376 | + for file in *; do |
| 377 | + read arn < "$file" |
| 378 | + echo " \"$file\": \"$arn\"," >> ../layer_cdk |
| 379 | + done |
| 380 | + echo "}" >> ../layer_cdk |
| 381 | + cat ../layer_cdk |
| 382 | +
|
| 383 | + publish-github: |
| 384 | + needs: generate-lambda-release-note |
| 385 | + runs-on: ubuntu-latest |
| 386 | + steps: |
| 387 | + - name: Checkout Repo @ SHA - ${{ github.sha }} |
| 388 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0 |
| 389 | + |
| 390 | + - name: Download SDK artifact |
| 391 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5.0.0 |
| 392 | + with: |
| 393 | + name: ${{ env.ARTIFACT_NAME }} |
| 394 | + |
| 395 | + - name: Download layer.zip artifact |
| 396 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5.0.0 |
| 397 | + with: |
| 398 | + name: layer.zip |
| 399 | + |
| 400 | + - name: Rename artifacts |
| 401 | + run: | |
| 402 | + cp "aws-opentelemetry-agent-${{ github.event.inputs.version }}.jar" ${{ env.ARTIFACT_NAME }} |
| 403 | + cp aws-opentelemetry-java-layer.zip layer.zip |
| 404 | +
|
| 405 | + # Publish to GitHub releases |
| 406 | + - name: Create GH release |
| 407 | + id: create_release |
148 | 408 | env: |
149 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token |
| 409 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
150 | 410 | run: | |
151 | | - # Download layer.zip from existing latest tagged SDK release note |
152 | | - LATEST_SDK_VERSION=$(gh release list --repo "aws-observability/aws-otel-java-instrumentation" --json tagName,isLatest -q 'map(select(.isLatest==true)) | .[0].tagName') |
153 | | - mkdir -p layer_artifact |
154 | | - gh release download "$LATEST_SDK_VERSION" --repo "aws-observability/aws-otel-java-instrumentation" --pattern "layer.zip" --dir layer_artifact |
155 | | - shasum -a 256 layer_artifact/layer.zip > layer_artifact/layer.zip.sha256 |
| 411 | + # Extract versions from dependency files |
| 412 | + OTEL_INSTRUMENTATION_VERSION=$(grep "val otelVersion" dependencyManagement/build.gradle.kts | sed 's/.*= "\([^"]*\)".*/\1/') |
| 413 | + OTEL_CONTRIB_VERSION=$(grep "io.opentelemetry.contrib:opentelemetry-aws-xray" dependencyManagement/build.gradle.kts | sed 's/.*:\([^"]*\)".*/\1/') |
| 414 | +
|
| 415 | + # Create release notes |
| 416 | + cat > release_notes.md << EOF |
| 417 | + This release contains updates of the following upstream components: |
| 418 | +
|
| 419 | + OpenTelemetry Java Contrib - $OTEL_CONTRIB_VERSION |
| 420 | + Opentelemetry Instrumentation for Java - $OTEL_INSTRUMENTATION_VERSION |
| 421 | +
|
| 422 | + This release also publishes to public ECR and Maven Central. |
| 423 | + * See ADOT Java auto-instrumentation Docker image v${{ github.event.inputs.version }} in our public ECR repository: |
| 424 | + https://gallery.ecr.aws/aws-observability/adot-autoinstrumentation-java |
| 425 | + * See version ${{ github.event.inputs.version }} in our Maven Central repository: |
| 426 | + https://central.sonatype.com/artifact/software.amazon.opentelemetry/aws-opentelemetry-agent |
| 427 | +
|
| 428 | + This release also includes the AWS OpenTelemetry Lambda Layer for Java version ${{ github.event.inputs.version }}-$(echo $GITHUB_SHA | cut -c1-7). |
| 429 | +
|
| 430 | + Lambda Layer ARNs: |
| 431 | + ${{ needs.generate-lambda-release-note.outputs.layer-note }} |
| 432 | + EOF |
| 433 | +
|
| 434 | + shasum -a 256 ${{ env.ARTIFACT_NAME }} > ${{ env.ARTIFACT_NAME }}.sha256 |
| 435 | + shasum -a 256 layer.zip > layer.zip.sha256 |
156 | 436 |
|
157 | 437 | gh release create --target "$GITHUB_REF_NAME" \ |
158 | 438 | --title "Release v${{ github.event.inputs.version }}" \ |
| 439 | + --notes-file release_notes.md \ |
159 | 440 | --draft \ |
160 | 441 | "v${{ github.event.inputs.version }}" \ |
161 | 442 | ${{ env.ARTIFACT_NAME }} \ |
162 | 443 | ${{ env.ARTIFACT_NAME }}.sha256 \ |
163 | | - layer_artifact/layer.zip \ |
164 | | - layer_artifact/layer.zip.sha256 |
| 444 | + layer.zip \ |
| 445 | + layer.zip.sha256 |
0 commit comments