-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (187 loc) · 6.23 KB
/
Copy pathrelease.yaml
File metadata and controls
215 lines (187 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Release
on:
workflow_dispatch:
inputs:
publish:
description: Publish to AWS and GHCR
required: true
default: true
type: boolean
scan:
description: Run RL scanning
required: true
default: true
type: boolean
jobs:
build:
strategy:
matrix:
arch: [x86_64, aarch64]
outputs:
version: ${{ steps.version.outputs.VERSION }}
major: ${{ steps.version.outputs.MAJOR }}
minor: ${{ steps.version.outputs.MINOR }}
patch: ${{ steps.version.outputs.PATCH }}
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
container: amazonlinux:2023
permissions:
contents: read
steps:
- run: dnf update -y && dnf install -y git tar gcc pkg-config openssl-devel
- uses: actions/checkout@v7
- uses: actions-rust-lang/setup-rust-toolchain@v2
- run: cargo build --release
- run: mkdir -p target/opt/extensions
- run: cp target/release/diet-lambda target/opt/extensions/diet-lambda
- uses: actions/upload-artifact@v7
with:
name: diet-lambda-${{ matrix.arch }}
path: target/opt
- name: Extract version
id: version
run: |
VERSION="$(cargo pkgid | awk -F'#' '{ print $NF }')"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
MAJOR="$(echo "$VERSION" | awk -F. '{ print $1 }')"
MINOR="$(echo "$VERSION" | awk -F. '{ print $2 }')"
PATCH="$(echo "$VERSION" | awk -F. '{ print $3 }')"
echo "MAJOR=$MAJOR" >> "$GITHUB_OUTPUT"
echo "MINOR=$MINOR" >> "$GITHUB_OUTPUT"
echo "PATCH=$PATCH" >> "$GITHUB_OUTPUT"
prod:
needs: build
if: inputs.publish
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]
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
permissions:
contents: read
id-token: write
steps:
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.LAMBDA_PROD_PUBLISHER_ARN }}
aws-region: ${{ matrix.region }}
- uses: actions/download-artifact@v8
id: download
with:
name: diet-lambda-${{ matrix.arch }}
skip-decompress: true
- name: Publish layer
env:
SUFFIX: -${{ needs.build.outputs.major }}_${{ needs.build.outputs.minor }}_${{ needs.build.outputs.patch }}
run: |
LAYER_ARN=$(
aws lambda publish-layer-version \
--layer-name diet-lambda-${{ matrix.arch }}$SUFFIX \
--license-info "Apache 2.0" \
--compatible-architectures ${{ matrix.arch == 'x86_64' && 'x86_64' || 'arm64' }} \
--zip-file fileb://${{ steps.download.outputs.download-path }}/diet-lambda-${{ matrix.arch }}.zip \
--query 'LayerVersionArn' \
--output text
)
echo "::notice::$LAYER_ARN"
docker:
needs: build
if: inputs.publish
strategy:
matrix:
arch: [x86_64, aarch64]
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: actions/checkout@v7
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v8
with:
name: diet-lambda-${{ matrix.arch }}
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ matrix.arch }}-${{ needs.build.outputs.version }}
multiarch:
needs:
- build
- docker
if: inputs.publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-arch manifests
env:
SUFFIX: -${{ needs.build.outputs.version }}
MAJOR: ${{ needs.build.outputs.major }}
MINOR: ${{ needs.build.outputs.major }}.${{ needs.build.outputs.minor }}
PATCH: ${{ needs.build.outputs.major }}.${{ needs.build.outputs.minor }}.${{ needs.build.outputs.patch }}
run: |
docker buildx imagetools create \
--tag ghcr.io/${{ github.repository }}:$MAJOR \
--tag ghcr.io/${{ github.repository }}:$MINOR \
--tag ghcr.io/${{ github.repository }}:$PATCH \
ghcr.io/${{ github.repository }}:x86_64$SUFFIX \
ghcr.io/${{ github.repository }}:aarch64$SUFFIX
scan:
needs: build
if: inputs.scan
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: diet-lambda-x86_64
path: x86_64
- uses: actions/download-artifact@v8
with:
name: diet-lambda-aarch64
path: aarch64
- run: ls -AR
- run: zip -r diet-lambda.zip src x86_64 aarch64 Cargo.toml Cargo.lock .cargo LICENSE
- name: RL Scan
run: |
docker run --rm -v "${{ github.workspace }}:/workspace" \
-e RLPORTAL_ACCESS_TOKEN="${{ secrets.RLPORTAL_ACCESS_TOKEN }}" \
reversinglabs/rl-scanner-cloud rl-scan \
--rl-portal-server solarwinds \
--rl-portal-org SolarWinds \
--rl-portal-group SaaS-Agents-SWO \
--purl diet-lambda/diet-lambda@${{ needs.build.outputs.version }} \
--file-path /workspace/diet-lambda.zip \
--submit-only --replace