diff --git a/.github/workflows/layer-publish copy.yml b/.github/workflows/layer-publish copy.yml new file mode 100644 index 0000000000..08730240cf --- /dev/null +++ b/.github/workflows/layer-publish copy.yml @@ -0,0 +1,116 @@ +name: Publish Lambda Layer + +on: + workflow_call: + inputs: + artifact-name: + description: 'This should correspond to a actions/upload-artifact name earlier in the build. The file name and the name of the artifact containing it must be equal.' + required: true + type: string + layer-name: + description: 'Layer name not including other parts like arch or version.' + required: true + type: string + component-version: + description: 'Version of the component included in this release. Not the same as the layer/tagged version.' + required: true + type: string + architecture: + description: '(optional) amd64 or arm64' + required: false + type: string + runtimes: + description: '(optional) a space delimited list of compatible runtimes (from https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)' + required: false + type: string + release-group: + description: 'Release to dev or prod? "prod" yields empty value. (Default: dev)' + required: true + default: dev + type: string + aws_region: + description: 'Publish to which AWS region?' + required: true + type: string + + +permissions: + id-token: write + contents: read + +jobs: + publish_layer: + runs-on: ubuntu-latest + + steps: + + - name: Construct Layer Name + shell: bash + run: | + LAYER_NAME=${{ inputs.layer-name }} + + if [[ -n "${{ inputs.architecture }}" ]]; then + LAYER_NAME=$LAYER_NAME-${{ inputs.architecture }} + ARCH=$(echo "${{ inputs.architecture }}" | sed -r 's/amd64/x86_64/g') + else + ARCH="x86_64 arm64" + fi + echo "ARCH=$ARCH" >> $GITHUB_ENV + + if [[ -n "${{ inputs.runtimes }}" ]]; then + RUNTIMES="--compatible-runtimes ${{ inputs.runtimes }}" + fi + echo "RUNTIMES=$RUNTIMES" >> $GITHUB_ENV + + if [[ "${{ inputs.release-group }}" != "prod" ]]; then + LAYER_NAME=$LAYER_NAME-${{ inputs.release-group }} + fi + + LAYER_VERSION=$(echo "$GITHUB_REF_NAME" | sed -r 's/.*\/[^0-9\.]*//g') + LAYER_VERSION_CLEANED=$(echo "$LAYER_VERSION" | sed -r 's/\./_/g') + + LAYER_NAME=$LAYER_NAME-$LAYER_VERSION_CLEANED + echo "LAYER_NAME=$LAYER_NAME" >> $GITHUB_ENV + + echo GITHUB_ENV: + cat $GITHUB_ENV + + - name: Download built layer + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + + - uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.PROD_LAMBDA_ROLE_ARN }} + role-duration-seconds: 1200 + aws-region: ${{ inputs.aws_region }} + mask-aws-account-id: false + + - name: Publish Lambda Layer + run: | + LAYER_ARN=$( + aws lambda publish-layer-version \ + --layer-name $LAYER_NAME \ + --license-info "Apache 2.0" \ + --compatible-architectures $ARCH $RUNTIMES \ + --zip-file fileb://${{ inputs.artifact-name }} \ + --query 'LayerVersionArn' \ + --output text + ) + echo "::notice ::$LAYER_ARN component-version=${{ inputs.component-version }}" + # echo "* $LAYER_ARN" >> $GITHUB_STEP_SUMMARY + + - name: Make Layer Public + run: | + LAYER_VERSION=$( + aws lambda list-layer-versions \ + --layer-name $LAYER_NAME \ + --query 'max_by(LayerVersions, &Version).Version' + ) + aws lambda add-layer-version-permission \ + --layer-name $LAYER_NAME \ + --version-number $LAYER_VERSION \ + --principal "*" \ + --statement-id publish \ + --action lambda:GetLayerVersion diff --git a/.github/workflows/release-layer-collector copy.yml b/.github/workflows/release-layer-collector copy.yml new file mode 100644 index 0000000000..4741bdb409 --- /dev/null +++ b/.github/workflows/release-layer-collector copy.yml @@ -0,0 +1,78 @@ +name: "Release Collector Lambda layer" + +on: + # (Using tag push instead of release to allow filtering by tag prefix.) + push: + tags: + - layer-collector/** + +permissions: + id-token: write + contents: write + +jobs: + build-layer: + runs-on: ubuntu-latest + strategy: + matrix: + architecture: + - amd64 + - arm64 + outputs: + COLLECTOR_VERSION: ${{ steps.save-collector-version.outputs.COLLECTOR_VERSION }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '^1.23.1' + - name: build + run: make -C collector package GOARCH=${{ matrix.architecture }} + - uses: actions/upload-artifact@v4 + with: + name: opentelemetry-collector-layer-${{ matrix.architecture }}.zip + path: ${{ github.workspace }}/collector/build/opentelemetry-collector-layer-${{ matrix.architecture }}.zip + - name: Add Binary to Release + run: | + gh release upload ${{github.ref_name}} ${{ github.workspace }}/collector/build/opentelemetry-collector-layer-${{ matrix.architecture }}.zip + - name: Save Collector Version + if: ${{ matrix.architecture == 'amd64' }} + id: save-collector-version + shell: bash + # `./collector -v` output is in the form `v0.75.0` + run: | + COLLECTOR_VERSION=$( ${{ github.workspace }}/collector/build/extensions/collector -v) + echo "COLLECTOR_VERSION=$COLLECTOR_VERSION" >> $GITHUB_OUTPUT + + publish-layer: + uses: ./.github/workflows/layer-publish.yml + needs: build-layer + strategy: + matrix: + architecture: + - amd64 + - arm64 + aws_region: + - ap-northeast-1 + - ap-northeast-2 + - ap-south-1 + - ap-southeast-1 + - ap-southeast-2 + - ca-central-1 + - eu-central-1 + - eu-north-1 + - eu-west-1 + - eu-west-2 + - eu-west-3 + - sa-east-1 + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + with: + artifact-name: opentelemetry-collector-layer-${{ matrix.architecture }}.zip + layer-name: opentelemetry-collector + component-version: ${{needs.build-layer.outputs.COLLECTOR_VERSION}} + architecture: ${{ matrix.architecture }} + release-group: prod + aws_region: ${{ matrix.aws_region }} + secrets: inherit diff --git a/.github/workflows/release-layer-java copy.yml b/.github/workflows/release-layer-java copy.yml new file mode 100644 index 0000000000..306d34498d --- /dev/null +++ b/.github/workflows/release-layer-java copy.yml @@ -0,0 +1,130 @@ +name: "Release Javaagent Lambda Layer" + +on: + # (Using tag push instead of release to allow filtering by tag prefix.) + push: + tags: + - layer-javaagent/** + +permissions: + id-token: write + contents: write + +jobs: + build-layer: + runs-on: ubuntu-latest + outputs: + JAVAAGENT_VERSION: ${{ steps.save-javaagent-version.outputs.JAVAAGENT_VERSION }} + JAVAWRAPPER_VERSION: ${{ steps.save-javawrapper-version.outputs.JAVAWRAPPER_VERSION }} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-java@v4 + with: + distribution: corretto + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Execute Gradle build + run: | + cd java + ./gradlew :layer-javaagent:assemble :layer-wrapper:assemble --scan --stacktrace + + - uses: actions/upload-artifact@v4 + name: Save javaagent layer to build + with: + name: opentelemetry-javaagent-layer.zip + path: java/layer-javaagent/build/distributions/opentelemetry-javaagent-layer.zip + + - uses: actions/upload-artifact@v4 + name: Save javawrapper layer to build + with: + name: opentelemetry-javawrapper-layer.zip + path: java/layer-wrapper/build/distributions/opentelemetry-javawrapper-layer.zip + + - name: Add Binary to Release + run: | + gh release upload ${{github.ref_name}} java/layer-wrapper/build/distributions/opentelemetry-javawrapper-layer.zip + + - name: Save Javaagent Version + id: save-javaagent-version + shell: bash + run: | + unzip java/layer-javaagent/build/distributions/opentelemetry-javaagent-layer.zip + JAVAAGENT_VERSION=$(java -jar ./opentelemetry-javaagent.jar) + echo "JAVAAGENT_VERSION=$JAVAAGENT_VERSION" >> $GITHUB_OUTPUT + + - name: Save Java Wrapper Version + id: save-javawrapper-version + shell: bash + run: | + cd java + JAVAWRAPPER_VERSION=$(./gradlew layer-wrapper:printOtelJavaInstrumentationVersion -q) + echo "JAVAWRAPPER_VERSION=$JAVAWRAPPER_VERSION" >> $GITHUB_OUTPUT + + publish-javaagent-layer: + uses: ./.github/workflows/layer-publish.yml + needs: build-layer + strategy: + matrix: + aws_region: + - ap-northeast-1 + - ap-northeast-2 + - ap-south-1 + - ap-southeast-1 + - ap-southeast-2 + - ca-central-1 + - eu-central-1 + - eu-north-1 + - eu-west-1 + - eu-west-2 + - eu-west-3 + - sa-east-1 + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + with: + artifact-name: opentelemetry-javaagent-layer.zip + layer-name: opentelemetry-javaagent + component-version: ${{needs.build-layer.outputs.JAVAAGENT_VERSION}} + # architecture: + runtimes: java8.al2 java11 java17 + release-group: prod + aws_region: ${{ matrix.aws_region }} + secrets: inherit + + publish-javawrapper-layer: + uses: ./.github/workflows/layer-publish.yml + needs: build-layer + strategy: + matrix: + aws_region: + - ap-northeast-1 + - ap-northeast-2 + - ap-south-1 + - ap-southeast-1 + - ap-southeast-2 + - ca-central-1 + - eu-central-1 + - eu-north-1 + - eu-west-1 + - eu-west-2 + - eu-west-3 + - sa-east-1 + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + with: + artifact-name: opentelemetry-javawrapper-layer.zip + layer-name: opentelemetry-javawrapper + component-version: ${{needs.build-layer.outputs.JAVAWRAPPER_VERSION}} + # architecture: + runtimes: java8.al2 java11 java17 + release-group: prod + aws_region: ${{ matrix.aws_region }} + secrets: inherit + diff --git a/.github/workflows/release-layer-nodejs copy.yml b/.github/workflows/release-layer-nodejs copy.yml new file mode 100644 index 0000000000..d5f92a6487 --- /dev/null +++ b/.github/workflows/release-layer-nodejs copy.yml @@ -0,0 +1,82 @@ +name: "Release NodeJS Lambda Layer" + +on: + # (Using tag push instead of release to allow filtering by tag prefix.) + push: + tags: + - layer-nodejs/** + +permissions: + id-token: write + contents: write + +jobs: + build-layer: + runs-on: ubuntu-latest + outputs: + NODEJS_VERSION: ${{ steps.save-node-sdk-version.outputs.SDK_VERSION}} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Build + run: | + npm install + npm run build + working-directory: nodejs + + - name: Save Node SDK Version + id: save-node-sdk-version + run: | + SDK_VERSION=$(node version.js) + echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_OUTPUT + working-directory: nodejs/packages/layer/scripts + + - name: Rename zip file + run: mv layer.zip opentelemetry-nodejs-layer.zip + working-directory: nodejs/packages/layer/build + + - uses: actions/upload-artifact@v4 + name: Save assembled layer to build + with: + name: opentelemetry-nodejs-layer.zip + path: nodejs/packages/layer/build/opentelemetry-nodejs-layer.zip + + - name: Add Binary to Release + run: | + gh release upload ${{github.ref_name}} nodejs/packages/layer/build/opentelemetry-nodejs-layer.zip + + publish-layer: + uses: ./.github/workflows/layer-publish.yml + needs: build-layer + strategy: + matrix: + aws_region: + - ap-northeast-1 + - ap-northeast-2 + - ap-south-1 + - ap-southeast-1 + - ap-southeast-2 + - ca-central-1 + - eu-central-1 + - eu-north-1 + - eu-west-1 + - eu-west-2 + - eu-west-3 + - sa-east-1 + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + with: + artifact-name: opentelemetry-nodejs-layer.zip + layer-name: opentelemetry-nodejs + component-version: ${{needs.build-layer.outputs.NODEJS_VERSION}} + # architecture: + runtimes: nodejs18.x nodejs20.x + release-group: prod + aws_region: ${{ matrix.aws_region }} + secrets: inherit diff --git a/.github/workflows/release-layer-python copy.yml b/.github/workflows/release-layer-python copy.yml new file mode 100644 index 0000000000..474fbf813a --- /dev/null +++ b/.github/workflows/release-layer-python copy.yml @@ -0,0 +1,87 @@ +name: "Release Python Lambda Layer" + +on: + # (Using tag push instead of release to allow filtering by tag prefix.) + push: + tags: + - layer-python/** + +permissions: + id-token: write + contents: write + +jobs: + build-layer: + runs-on: ubuntu-latest + outputs: + PYTHON_OPENTELEMETRY_SDK_VERSION: ${{ steps.save-python-opentelemetry-sdk-version.outputs.PYTHON_OPENTELEMETRY_SDK_VERSION}} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: '3.9' + + - name: Save PYTHON_OPENTELEMETRY_SDK_VERSION + id: save-python-opentelemetry-sdk-version + run: | + cd python/src + echo "PYTHON_OPENTELEMETRY_SDK_VERSION=$(cat otel/otel_sdk/requirements.txt | grep opentelemetry-sdk | sed 's/.*==\([^ ]*\).*/\1/')" >> $GITHUB_ENV + echo "PYTHON_OPENTELEMETRY_SDK_VERSION=$PYTHON_OPENTELEMETRY_SDK_VERSION" >> $GITHUB_OUTPUT + shell: bash + + - name: Display PYTHON_OPENTELEMETRY_SDK_VERSION + run: | + echo "PYTHON_OPENTELEMETRY_SDK_VERSION=${{ env.PYTHON_OPENTELEMETRY_SDK_VERSION }}" + shell: bash + + - name: Build + run: | + cd python/src + ./build.sh + shell: bash + + - name: Show directory contents + run: | + ls -al + working-directory: python/src/build + + - uses: actions/upload-artifact@v4 + name: Save assembled layer to build + with: + name: opentelemetry-python-layer.zip + path: python/src/build/opentelemetry-python-layer.zip + + - name: Add Binary to Release + run: | + gh release upload ${{github.ref_name}} python/src/build/opentelemetry-python-layer.zip + + publish-layer: + uses: ./.github/workflows/layer-publish.yml + needs: build-layer + strategy: + matrix: + aws_region: + - ap-northeast-1 + - ap-northeast-2 + - ap-south-1 + - ap-southeast-1 + - ap-southeast-2 + - ca-central-1 + - eu-central-1 + - eu-north-1 + - eu-west-1 + - eu-west-2 + - eu-west-3 + - sa-east-1 + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + with: + artifact-name: opentelemetry-python-layer.zip + layer-name: opentelemetry-python + component-version: ${{needs.build-layer.outputs.PYTHON_OPENTELEMETRY_SDK_VERSION}} + release-group: prod + aws_region: ${{ matrix.aws_region }} + secrets: inherit diff --git a/.github/workflows/release-layer-ruby copy.yml b/.github/workflows/release-layer-ruby copy.yml new file mode 100644 index 0000000000..b6b4a8acc7 --- /dev/null +++ b/.github/workflows/release-layer-ruby copy.yml @@ -0,0 +1,80 @@ +name: "Release Ruby Lambda Layer" + +on: + # (Using tag push instead of release to allow filtering by tag prefix.) + push: + tags: + - layer-ruby/** + +permissions: + id-token: write + contents: write + +jobs: + build-layer: + runs-on: ubuntu-latest + outputs: + RUBY_SDK_VERSION: ${{ steps.save-ruby-sdk-version.outputs.RUBY_SDK_VERSION}} + steps: + - uses: actions/checkout@v4 + + - name: Build + run: | + ./build.sh + shell: bash + working-directory: ruby/src + + - name: Save Ruby SDK Version + id: save-ruby-sdk-version + run: | + unzip -q build/opentelemetry-ruby-layer.zip + export GEM_PATH=$PWD/ruby/gems/3.2.0/ + RUBY_SDK_VERSION=$(ruby -e 'require "opentelemetry-sdk"; puts OpenTelemetry::SDK::VERSION') + echo "RUBY_SDK_VERSION=$RUBY_SDK_VERSION" >> $GITHUB_OUTPUT + working-directory: ruby/src + + - name: Show directory contents + run: | + ls -al + working-directory: ruby/src/build + + - uses: actions/upload-artifact@v4 + name: Save assembled layer to build + with: + name: opentelemetry-ruby-layer.zip + path: ruby/src/build/opentelemetry-ruby-layer.zip + + - name: Add Binary to Release + run: | + gh release upload ${{github.ref_name}} ruby/src/build/opentelemetry-ruby-layer.zip + + publish-layer: + uses: ./.github/workflows/layer-publish.yml + needs: build-layer + strategy: + matrix: + aws_region: + - ap-northeast-1 + - ap-northeast-2 + - ap-south-1 + - ap-southeast-1 + - ap-southeast-2 + - ca-central-1 + - eu-central-1 + - eu-north-1 + - eu-west-1 + - eu-west-2 + - eu-west-3 + - sa-east-1 + - us-east-1 + - us-east-2 + - us-west-1 + - us-west-2 + with: + artifact-name: opentelemetry-ruby-layer.zip + layer-name: opentelemetry-ruby + component-version: ${{needs.build-layer.outputs.RUBY_SDK_VERSION}} + runtimes: ruby3.2 ruby3.3 + release-group: dev + aws_region: ${{ matrix.aws_region }} + secrets: inherit