-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cebe84
commit 83f32f0
Showing
6 changed files
with
573 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
Oops, something went wrong.