24
24
- staging
25
25
- production
26
26
27
+ ruby-version :
28
+ description : ' Supported ruby version for lambda layer'
29
+ default : ' 3.2 3.3 3.4'
30
+
27
31
permissions :
28
32
id-token : write # This is required for requesting the JWT
29
33
contents : read # This is required for actions/checkout
@@ -32,12 +36,19 @@ jobs:
32
36
# build layer on arm64 and amd64, then upload to artifacts
33
37
# act -j build_layer --container-architecture linux/arm64
34
38
build_layer :
35
- runs-on : ubuntu-latest
39
+ strategy :
40
+ fail-fast : false
41
+ matrix :
42
+ arch :
43
+ - x86_64
44
+ - arm64
45
+
46
+ runs-on : ${{ matrix.arch == 'arm64' && fromJSON('{"group":"apm-arm-runner"}') || 'ubuntu-latest' }}
36
47
37
48
steps :
38
49
- uses : actions/checkout@v4
39
50
40
- - name : Build ruby lambda layer
51
+ - name : Build ruby lambda layer on ${{ matrix.arch }}
41
52
run : |
42
53
uname -a
43
54
./build.sh
46
57
env :
47
58
GITHUB_RUBY_TOKEN : ${{ secrets.PACKAGE_GITHUB_TOKEN }}
48
59
SOLARWINDS_SOURCE : ${{ github.event.inputs.solarwinds-source }}
60
+ PUBLISH_DEST : ${{ github.event.inputs.publish-dest }}
61
+ ALLOWED_RUBY_VERSION : ${{ github.event.inputs.ruby-version }}
62
+ ARCHITECTURE : ${{ matrix.arch }}
49
63
50
64
- name : Show directory contents
51
65
run : |
@@ -55,30 +69,47 @@ jobs:
55
69
- name : Upload to artifact
56
70
uses : actions/upload-artifact@v4
57
71
with :
58
- name : ruby-layer.zip
59
- path : lambda/build/ruby-layer.zip
72
+ name : ruby-layer-${{ matrix.arch }} .zip
73
+ path : lambda/build/ruby-layer-${{ matrix.arch }} .zip
60
74
61
75
# extract the built layer from artifacts, then scan it with reverselab
62
76
reverselab_scan_layer :
63
77
needs :
64
78
- build_layer
65
- runs-on : ubuntu-latest
66
79
strategy :
67
80
fail-fast : false
81
+ matrix :
82
+ arch :
83
+ - x86_64
84
+ - arm64
85
+
86
+ runs-on : ubuntu-latest
87
+
88
+ outputs :
89
+ apm_ruby_version : ${{ steps.version.outputs.SOLARWINDS_APM_VERSION }}
68
90
69
91
steps :
70
92
- uses : actions/checkout@v4
71
93
72
94
- name : extract layer zip from artifacts
73
95
uses : actions/download-artifact@v4
74
96
with :
75
- name : ruby-layer.zip
97
+ name : ruby-layer-${{ matrix.arch }} .zip
76
98
path : lambda
77
99
78
100
- name : extract current solarwinds_apm version
101
+ id : version
79
102
run : |
80
- APM_VERSION=$(grep "gem 'solarwinds_apm'" lambda/otel/layer/Gemfile | awk -F"'" '{print $4}')
103
+ if [ $SOLARWINDS_SOURCE = 'Local' ]; then \
104
+ APM_VERSION=$(ruby -r './lib/solarwinds_apm/version.rb' -e 'puts SolarWindsAPM::Version::STRING'); \
105
+ else \
106
+ apt-get update && apt-get install -y jq curl; \
107
+ APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version); \
108
+ fi
81
109
echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV
110
+ echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_OUTPUT
111
+ env :
112
+ SOLARWINDS_SOURCE : ${{ github.event.inputs.solarwinds-source }}
82
113
83
114
- name : Scan build artifact on the Portal
84
115
id : rl-scan
@@ -88,12 +119,12 @@ jobs:
88
119
89
120
uses : reversinglabs/gh-action-rl-scanner-cloud-only@v1
90
121
with :
91
- artifact-to-scan : ./lambda/ruby-layer.zip
122
+ artifact-to-scan : ./lambda/ruby-layer-${{ matrix.arch }} .zip
92
123
rl-verbose : true
93
124
rl-portal-server : solarwinds
94
125
rl-portal-org : SolarWinds
95
126
rl-portal-group : SaaS-Agents-SWO
96
- rl-package-url : solarwinds-apm-ruby/apm-ruby-lambda-layer@${{ env.SOLARWINDS_APM_VERSION }}
127
+ rl-package-url : solarwinds-apm-ruby/apm-ruby-lambda-layer-${{ matrix.arch }} @${{ env.SOLARWINDS_APM_VERSION }}
97
128
98
129
- name : report the scan status
99
130
if : success() || failure()
@@ -104,9 +135,9 @@ jobs:
104
135
# extract the built layer from artifacts, then publish it based on region
105
136
publish_layer :
106
137
needs :
107
- - build_layer
108
- runs-on : ubuntu-latest
138
+ - reverselab_scan_layer
109
139
strategy :
140
+ fail-fast : false
110
141
matrix :
111
142
aws_region :
112
143
- ap-northeast-1
@@ -125,6 +156,11 @@ jobs:
125
156
- us-east-2
126
157
- us-west-1
127
158
- us-west-2
159
+ arch :
160
+ - x86_64
161
+ - arm64
162
+
163
+ runs-on : ubuntu-latest
128
164
129
165
steps :
130
166
- uses : actions/checkout@v4
@@ -138,30 +174,33 @@ jobs:
138
174
- name : extract layer zip from artifacts
139
175
uses : actions/download-artifact@v4
140
176
with :
141
- name : ruby-layer.zip
177
+ name : ruby-layer-${{ matrix.arch }} .zip
142
178
path : lambda
143
179
144
- - name : extract current solarwinds_apm version
180
+ - name : format version for aws lambda and define lambda ruby version
145
181
run : |
146
- APM_VERSION=$(grep "gem 'solarwinds_apm'" lambda/otel/layer/Gemfile | awk -F"'" '{print $4}')
147
- APM_VERSION="${APM_VERSION//./_}"
182
+ APM_VERSION=$(echo "$APM_VERSION" | tr '.' '_')
148
183
echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV
184
+ echo "LAMBDA_RUBY_VERSION=$(echo $ALLOWED_RUBY_VERSION | sed 's/\([0-9]\+\.[0-9]\+\)/ruby\1/g')" >> $GITHUB_ENV
185
+ env :
186
+ APM_VERSION : ${{needs.reverselab_scan_layer.outputs.apm_ruby_version}}
187
+ ALLOWED_RUBY_VERSION : ${{ github.event.inputs.ruby-version }}
149
188
150
189
- name : publish lambda layer
151
190
run : |
152
191
cd lambda/
153
192
aws lambda publish-layer-version \
154
- --layer-name solarwinds-apm-ruby-${{ env.SOLARWINDS_APM_VERSION }} \
193
+ --layer-name solarwinds-apm-ruby-${{ matrix.arch }}-${{ env.SOLARWINDS_APM_VERSION }} \
155
194
--license-info "Apache 2.0" \
156
- --compatible-architectures x86_64 arm64 \
157
- --compatible-runtimes ruby3.2 ruby3.3 ruby3.4 \
158
- --zip-file fileb://ruby-layer.zip \
195
+ --compatible-architectures ${{ matrix.arch }} \
196
+ --compatible-runtimes ${{ env.LAMBDA_RUBY_VERSION }} \
197
+ --zip-file fileb://ruby-layer-${{ matrix.arch }} .zip \
159
198
--query 'LayerVersionArn' \
160
199
--output text
161
200
162
201
- name : grant permissions to public for the published layer
163
202
run : |
164
- layer_name=solarwinds-apm-ruby-${{ env.SOLARWINDS_APM_VERSION }}
203
+ layer_name=solarwinds-apm-ruby-${{ matrix.arch }}-${{ env.SOLARWINDS_APM_VERSION }}
165
204
latest_version=$(aws lambda list-layer-versions --layer-name $layer_name | jq -r '.LayerVersions | max_by(.Version) | .Version')
166
205
aws lambda add-layer-version-permission \
167
206
--layer-name $layer_name \
0 commit comments