|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -Eeuo pipefail |
| 4 | + |
| 5 | +BUILD_DIR=lib # for .net can either be lib or bin. See: https://docs.aws.amazon.com/lambda/latest/dg/packaging-layers.html |
| 6 | +DIST_DIR=dist |
| 7 | + |
| 8 | +DOTNET_DIST_ARM64=$DIST_DIR/dotnet.arm64.zip |
| 9 | +DOTNET_DIST_X86_64=$DIST_DIR/dotnet.x86_64.zip |
| 10 | + |
| 11 | +AGENT_DIST_ZIP=agent.zip |
| 12 | + |
| 13 | +source ../libBuild.sh |
| 14 | + |
| 15 | +function usage { |
| 16 | + echo "./publish-layers.sh" |
| 17 | +} |
| 18 | + |
| 19 | +function build-dotnet-x86-64 { |
| 20 | + echo "Building New Relic layer for .NET 6, 7 and 8 (x86_64)" |
| 21 | + rm -rf $BUILD_DIR $DOTNET_DIST_X86_64 |
| 22 | + mkdir -p $DIST_DIR |
| 23 | + get_agent amd64 |
| 24 | + # MAKE CONFIG CHANGES HERE |
| 25 | + download_extension x86_64 |
| 26 | + zip -rq $DOTNET_DIST_X86_64 $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE |
| 27 | + rm -rf $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE |
| 28 | + echo "Build complete: ${DOTNET_DIST_X86_64}" |
| 29 | +} |
| 30 | + |
| 31 | +function publish-dotnet-x86-64 { |
| 32 | + if [ ! -f $DOTNET_DIST_X86_64 ]; then |
| 33 | + echo "Package not found: ${DOTNET_DIST_X86_64}" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + |
| 37 | + for region in "${REGIONS_X86[@]}"; do |
| 38 | + publish_layer $DOTNET_DIST_X86_64 $region dotnet x86_64 |
| 39 | + done |
| 40 | +} |
| 41 | + |
| 42 | +function build-dotnet-arm64 { |
| 43 | + echo "Building New Relic layer for .NET 6, 7 and 8 (ARM64)" |
| 44 | + rm -rf $BUILD_DIR $DOTNET_DIST_ARM64 |
| 45 | + mkdir -p $DIST_DIR |
| 46 | + get_agent arm64 |
| 47 | + # MAKE CONFIG CHANGES HERE |
| 48 | + download_extension arm64 |
| 49 | + zip -rq $DOTNET_DIST_ARM64 $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE |
| 50 | + rm -rf $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE |
| 51 | + echo "Build complete: ${DOTNET_DIST_ARM64}" |
| 52 | +} |
| 53 | + |
| 54 | +function publish-dotnet-arm64 { |
| 55 | + if [ ! -f $DOTNET_DIST_ARM64 ]; then |
| 56 | + echo "Package not found: ${DOTNET_DIST_ARM64}" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + |
| 60 | + for region in "${REGIONS_ARM[@]}"; do |
| 61 | + publish_layer $DOTNET_DIST_ARM64 $region dotnet arm64 |
| 62 | + done |
| 63 | +} |
| 64 | + |
| 65 | +# exmaple https://download.newrelic.com/dot_net_agent/latest_release/newrelic-dotnet-agent_10.22.0_amd64.tar.gz |
| 66 | +function get_agent { |
| 67 | + arch=$1 |
| 68 | + |
| 69 | + url="https://download.newrelic.com/dot_net_agent/latest_release/newrelic-dotnet-agent_${AGENT_VERSION}_${arch}.tar.gz" |
| 70 | + rm -rf $AGENT_DIST_ZIP |
| 71 | + curl -L $url -o $AGENT_DIST_ZIP |
| 72 | + mkdir -p $BUILD_DIR |
| 73 | + tar -xvf $AGENT_DIST_ZIP -C ./$BUILD_DIR # under $BUILD_DIR/newrelic-dotnet-agent |
| 74 | + rm -f $AGENT_DIST_ZIP |
| 75 | +} |
| 76 | + |
| 77 | +if [ -z $AGENT_VERSION ]; then |
| 78 | + echo "Missing required AGENT_VERSION environment variable: ${AGENT_VERSION}." |
| 79 | + exit 1 |
| 80 | +fi |
| 81 | + |
| 82 | +build-dotnet-arm64 |
| 83 | +publish-dotnet-arm64 |
| 84 | +build-dotnet-x86-64 |
| 85 | +publish-dotnet-x86-64 |
| 86 | + |
0 commit comments