Skip to content

Commit 83f32f0

Browse files
committed
adding binary to release
1 parent 5cebe84 commit 83f32f0

File tree

6 files changed

+573
-0
lines changed

6 files changed

+573
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Publish Lambda Layer
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
artifact-name:
7+
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.'
8+
required: true
9+
type: string
10+
layer-name:
11+
description: 'Layer name not including other parts like arch or version.'
12+
required: true
13+
type: string
14+
component-version:
15+
description: 'Version of the component included in this release. Not the same as the layer/tagged version.'
16+
required: true
17+
type: string
18+
architecture:
19+
description: '(optional) amd64 or arm64'
20+
required: false
21+
type: string
22+
runtimes:
23+
description: '(optional) a space delimited list of compatible runtimes (from https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)'
24+
required: false
25+
type: string
26+
release-group:
27+
description: 'Release to dev or prod? "prod" yields empty value. (Default: dev)'
28+
required: true
29+
default: dev
30+
type: string
31+
aws_region:
32+
description: 'Publish to which AWS region?'
33+
required: true
34+
type: string
35+
36+
37+
permissions:
38+
id-token: write
39+
contents: read
40+
41+
jobs:
42+
publish_layer:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
47+
- name: Construct Layer Name
48+
shell: bash
49+
run: |
50+
LAYER_NAME=${{ inputs.layer-name }}
51+
52+
if [[ -n "${{ inputs.architecture }}" ]]; then
53+
LAYER_NAME=$LAYER_NAME-${{ inputs.architecture }}
54+
ARCH=$(echo "${{ inputs.architecture }}" | sed -r 's/amd64/x86_64/g')
55+
else
56+
ARCH="x86_64 arm64"
57+
fi
58+
echo "ARCH=$ARCH" >> $GITHUB_ENV
59+
60+
if [[ -n "${{ inputs.runtimes }}" ]]; then
61+
RUNTIMES="--compatible-runtimes ${{ inputs.runtimes }}"
62+
fi
63+
echo "RUNTIMES=$RUNTIMES" >> $GITHUB_ENV
64+
65+
if [[ "${{ inputs.release-group }}" != "prod" ]]; then
66+
LAYER_NAME=$LAYER_NAME-${{ inputs.release-group }}
67+
fi
68+
69+
LAYER_VERSION=$(echo "$GITHUB_REF_NAME" | sed -r 's/.*\/[^0-9\.]*//g')
70+
LAYER_VERSION_CLEANED=$(echo "$LAYER_VERSION" | sed -r 's/\./_/g')
71+
72+
LAYER_NAME=$LAYER_NAME-$LAYER_VERSION_CLEANED
73+
echo "LAYER_NAME=$LAYER_NAME" >> $GITHUB_ENV
74+
75+
echo GITHUB_ENV:
76+
cat $GITHUB_ENV
77+
78+
- name: Download built layer
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: ${{ inputs.artifact-name }}
82+
83+
- uses: aws-actions/configure-aws-credentials@v4
84+
with:
85+
role-to-assume: ${{ secrets.PROD_LAMBDA_ROLE_ARN }}
86+
role-duration-seconds: 1200
87+
aws-region: ${{ inputs.aws_region }}
88+
mask-aws-account-id: false
89+
90+
- name: Publish Lambda Layer
91+
run: |
92+
LAYER_ARN=$(
93+
aws lambda publish-layer-version \
94+
--layer-name $LAYER_NAME \
95+
--license-info "Apache 2.0" \
96+
--compatible-architectures $ARCH $RUNTIMES \
97+
--zip-file fileb://${{ inputs.artifact-name }} \
98+
--query 'LayerVersionArn' \
99+
--output text
100+
)
101+
echo "::notice ::$LAYER_ARN component-version=${{ inputs.component-version }}"
102+
# echo "* $LAYER_ARN" >> $GITHUB_STEP_SUMMARY
103+
104+
- name: Make Layer Public
105+
run: |
106+
LAYER_VERSION=$(
107+
aws lambda list-layer-versions \
108+
--layer-name $LAYER_NAME \
109+
--query 'max_by(LayerVersions, &Version).Version'
110+
)
111+
aws lambda add-layer-version-permission \
112+
--layer-name $LAYER_NAME \
113+
--version-number $LAYER_VERSION \
114+
--principal "*" \
115+
--statement-id publish \
116+
--action lambda:GetLayerVersion
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: "Release Collector Lambda layer"
2+
3+
on:
4+
# (Using tag push instead of release to allow filtering by tag prefix.)
5+
push:
6+
tags:
7+
- layer-collector/**
8+
9+
permissions:
10+
id-token: write
11+
contents: write
12+
13+
jobs:
14+
build-layer:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
architecture:
19+
- amd64
20+
- arm64
21+
outputs:
22+
COLLECTOR_VERSION: ${{ steps.save-collector-version.outputs.COLLECTOR_VERSION }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-go@v5
26+
with:
27+
go-version: '^1.23.1'
28+
- name: build
29+
run: make -C collector package GOARCH=${{ matrix.architecture }}
30+
- uses: actions/upload-artifact@v4
31+
with:
32+
name: opentelemetry-collector-layer-${{ matrix.architecture }}.zip
33+
path: ${{ github.workspace }}/collector/build/opentelemetry-collector-layer-${{ matrix.architecture }}.zip
34+
- name: Add Binary to Release
35+
run: |
36+
gh release upload ${{github.ref_name}} ${{ github.workspace }}/collector/build/opentelemetry-collector-layer-${{ matrix.architecture }}.zip
37+
- name: Save Collector Version
38+
if: ${{ matrix.architecture == 'amd64' }}
39+
id: save-collector-version
40+
shell: bash
41+
# `./collector -v` output is in the form `v0.75.0`
42+
run: |
43+
COLLECTOR_VERSION=$( ${{ github.workspace }}/collector/build/extensions/collector -v)
44+
echo "COLLECTOR_VERSION=$COLLECTOR_VERSION" >> $GITHUB_OUTPUT
45+
46+
publish-layer:
47+
uses: ./.github/workflows/layer-publish.yml
48+
needs: build-layer
49+
strategy:
50+
matrix:
51+
architecture:
52+
- amd64
53+
- arm64
54+
aws_region:
55+
- ap-northeast-1
56+
- ap-northeast-2
57+
- ap-south-1
58+
- ap-southeast-1
59+
- ap-southeast-2
60+
- ca-central-1
61+
- eu-central-1
62+
- eu-north-1
63+
- eu-west-1
64+
- eu-west-2
65+
- eu-west-3
66+
- sa-east-1
67+
- us-east-1
68+
- us-east-2
69+
- us-west-1
70+
- us-west-2
71+
with:
72+
artifact-name: opentelemetry-collector-layer-${{ matrix.architecture }}.zip
73+
layer-name: opentelemetry-collector
74+
component-version: ${{needs.build-layer.outputs.COLLECTOR_VERSION}}
75+
architecture: ${{ matrix.architecture }}
76+
release-group: prod
77+
aws_region: ${{ matrix.aws_region }}
78+
secrets: inherit
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: "Release Javaagent Lambda Layer"
2+
3+
on:
4+
# (Using tag push instead of release to allow filtering by tag prefix.)
5+
push:
6+
tags:
7+
- layer-javaagent/**
8+
9+
permissions:
10+
id-token: write
11+
contents: write
12+
13+
jobs:
14+
build-layer:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
JAVAAGENT_VERSION: ${{ steps.save-javaagent-version.outputs.JAVAAGENT_VERSION }}
18+
JAVAWRAPPER_VERSION: ${{ steps.save-javawrapper-version.outputs.JAVAWRAPPER_VERSION }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-java@v4
23+
with:
24+
distribution: corretto
25+
java-version: 17
26+
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
30+
- name: Execute Gradle build
31+
run: |
32+
cd java
33+
./gradlew :layer-javaagent:assemble :layer-wrapper:assemble --scan --stacktrace
34+
35+
- uses: actions/upload-artifact@v4
36+
name: Save javaagent layer to build
37+
with:
38+
name: opentelemetry-javaagent-layer.zip
39+
path: java/layer-javaagent/build/distributions/opentelemetry-javaagent-layer.zip
40+
41+
- uses: actions/upload-artifact@v4
42+
name: Save javawrapper layer to build
43+
with:
44+
name: opentelemetry-javawrapper-layer.zip
45+
path: java/layer-wrapper/build/distributions/opentelemetry-javawrapper-layer.zip
46+
47+
- name: Add Binary to Release
48+
run: |
49+
gh release upload ${{github.ref_name}} java/layer-wrapper/build/distributions/opentelemetry-javawrapper-layer.zip
50+
51+
- name: Save Javaagent Version
52+
id: save-javaagent-version
53+
shell: bash
54+
run: |
55+
unzip java/layer-javaagent/build/distributions/opentelemetry-javaagent-layer.zip
56+
JAVAAGENT_VERSION=$(java -jar ./opentelemetry-javaagent.jar)
57+
echo "JAVAAGENT_VERSION=$JAVAAGENT_VERSION" >> $GITHUB_OUTPUT
58+
59+
- name: Save Java Wrapper Version
60+
id: save-javawrapper-version
61+
shell: bash
62+
run: |
63+
cd java
64+
JAVAWRAPPER_VERSION=$(./gradlew layer-wrapper:printOtelJavaInstrumentationVersion -q)
65+
echo "JAVAWRAPPER_VERSION=$JAVAWRAPPER_VERSION" >> $GITHUB_OUTPUT
66+
67+
publish-javaagent-layer:
68+
uses: ./.github/workflows/layer-publish.yml
69+
needs: build-layer
70+
strategy:
71+
matrix:
72+
aws_region:
73+
- ap-northeast-1
74+
- ap-northeast-2
75+
- ap-south-1
76+
- ap-southeast-1
77+
- ap-southeast-2
78+
- ca-central-1
79+
- eu-central-1
80+
- eu-north-1
81+
- eu-west-1
82+
- eu-west-2
83+
- eu-west-3
84+
- sa-east-1
85+
- us-east-1
86+
- us-east-2
87+
- us-west-1
88+
- us-west-2
89+
with:
90+
artifact-name: opentelemetry-javaagent-layer.zip
91+
layer-name: opentelemetry-javaagent
92+
component-version: ${{needs.build-layer.outputs.JAVAAGENT_VERSION}}
93+
# architecture:
94+
runtimes: java8.al2 java11 java17
95+
release-group: prod
96+
aws_region: ${{ matrix.aws_region }}
97+
secrets: inherit
98+
99+
publish-javawrapper-layer:
100+
uses: ./.github/workflows/layer-publish.yml
101+
needs: build-layer
102+
strategy:
103+
matrix:
104+
aws_region:
105+
- ap-northeast-1
106+
- ap-northeast-2
107+
- ap-south-1
108+
- ap-southeast-1
109+
- ap-southeast-2
110+
- ca-central-1
111+
- eu-central-1
112+
- eu-north-1
113+
- eu-west-1
114+
- eu-west-2
115+
- eu-west-3
116+
- sa-east-1
117+
- us-east-1
118+
- us-east-2
119+
- us-west-1
120+
- us-west-2
121+
with:
122+
artifact-name: opentelemetry-javawrapper-layer.zip
123+
layer-name: opentelemetry-javawrapper
124+
component-version: ${{needs.build-layer.outputs.JAVAWRAPPER_VERSION}}
125+
# architecture:
126+
runtimes: java8.al2 java11 java17
127+
release-group: prod
128+
aws_region: ${{ matrix.aws_region }}
129+
secrets: inherit
130+

0 commit comments

Comments
 (0)