-
Notifications
You must be signed in to change notification settings - Fork 64
255 lines (214 loc) · 8.33 KB
/
release.yaml
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: Release
on:
workflow_dispatch:
inputs:
pre_version:
description: Previous Version
required: true
version:
description: Release Version
required: true
env:
GO_VERSION: 1.17
OTEL_COLLECTOR_VERSION: 0.60.0
permissions:
packages: write
contents: write
jobs:
verification:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- shell: bash
run: |
sudo apt-get install libpcap-dev
- name: Check licenses
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make license-check
- name: Run verification
run: make check
- name: Previous tag validation
run: |
tag='${{ github.event.inputs.pre_version }}'
[[ $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1
- name: Tag validation
run: |
tag='${{ github.event.inputs.version }}'
[[ $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1
release:
needs: verification
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Tag
run: |
tag='${{ github.event.inputs.version }}'
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
sed -i 's/image: ghcr.io\/openclarity\/kong-plugin:latest/image: ghcr.io\/openclarity\/kong-plugin:'"$tag"'/g' plugins/gateway/kong/deploy/patch-deployment.yaml
git commit plugins/gateway/kong/deploy/patch-deployment.yaml -m "workflow: update tag in kong deploy script"
sed -i 's/image: ghcr.io\/openclarity\/tyk-plugin-v3.2.2:latest/image: ghcr.io\/openclarity\/tyk-plugin-v3.2.2:'"$tag"'/g' plugins/gateway/tyk/deploy/patch-deployment.yaml
git commit plugins/gateway/tyk/deploy/patch-deployment.yaml -m "workflow: update tag in tyk deploy script"
git tag --annotate --message "Tag for release $tag" "$tag"
git push origin "refs/tags/$tag"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Get current timestamp
id: timestamp
run: echo "::set-output name=timestamp::$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push APIClarity
uses: docker/build-push-action@v2
with:
context: .
tags: ghcr.io/openclarity/apiclarity:${{ github.event.inputs.version }}
file: Dockerfile
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
VERSION=${{ github.event.inputs.version }}
BUILD_TIMESTAMP=${{ steps.timestamp.outputs.timestamp }}
COMMIT_HASH=${{ github.sha }}
- name: Build and Push Kong plugin
uses: docker/build-push-action@v2
with:
context: plugins
tags: ghcr.io/openclarity/kong-plugin:${{ github.event.inputs.version }}
file: plugins/Dockerfile.kong
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Fix Tyk Plugin API dep
id: tyk-dep
run: |
cd plugins/gateway/tyk/v3.2.2
go mod edit -replace github.com/openclarity/apiclarity/plugins/[email protected]=./../api
go mod edit -replace github.com/openclarity/apiclarity/plugins/[email protected]=./../common
- name: Build and Push Tyk plugin
uses: docker/build-push-action@v2
with:
context: plugins
tags: ghcr.io/openclarity/tyk-plugin-v3.2.2:${{ github.event.inputs.version }}
file: plugins/Dockerfile.tyk.v3.2.2
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Undo Tyk Plugin API dep change
id: undo-tyk-dep
run: git checkout -- plugins/gateway/tyk/v3.2.2/go.mod
- name: Build and Push passive taper
uses: docker/build-push-action@v2
with:
context: plugins
tags: ghcr.io/openclarity/passive-taper:${{ github.event.inputs.version }}
file: plugins/Dockerfile.taper
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
VERSION=${{ github.event.inputs.version }}
- name: Build and Push OpenTelemetry Collector with APIClarity plugin
uses: docker/build-push-action@v2
with:
context: plugins
tags: ghcr.io/openclarity/otel-apiclarityexporter:${{ github.event.inputs.version }}
file: plugins/Dockerfile.otel-collector
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
build-args: |
OTEL_COLLECTOR_VERSION=${{ env.OTEL_COLLECTOR_VERSION }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: v0.178.0
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ github.event.inputs.version }}
GORELEASER_PREVIOUS_TAG: ${{ github.event.inputs.pre_version }}
helm_release:
needs: release
name: Publish Helm Chart
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Tag validation
run: |
tag='${{ github.event.inputs.version }}'
[[ $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1
- name: Replace release version
id: replace_version
run: find . -type f -name "values.yaml" -o -name "Chart.yaml" |
xargs sed -i -e s/latest/${{ github.event.inputs.version }}/g
- name: Replace wasm filter commit id and sha256
id: replace_wasm_filter_commit_id_for_kuma
run: |
WASM_COMMIT="$(git rev-parse HEAD:wasm-filters)"
WASM_SHA256="$(sha256sum wasm-filters/bin/release/http-trace-filter.wasm | cut -d' ' -f1)"
WASM_URI="https://raw.githubusercontent.com/openclarity/wasm-filters/${WASM_COMMIT}/bin/release/http-trace-filter.wasm"
sed -i -e "s/sha256:.*/sha256: \"${WASM_SHA256}\"/" plugins/kuma/charts/values.yaml
sed -i -e "s#wasmFilterURI:.*#wasmFilterURI: \"${WASM_URI}\"#" plugins/kuma/charts/values.yaml
- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.10.3
- uses: actions/[email protected]
with:
python-version: 3.7
- name: Set up chart-testing
uses: helm/[email protected]
- name: Add Bitnami Repository
run: helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Run chart-testing (lint)
run: ct lint --chart-dirs charts,plugins/kuma --check-version-increment=false --validate-maintainers=false --all
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: charts
config: charts/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Run chart-releaser for kuma plugin
uses: helm/[email protected]
with:
charts_dir: plugins/kuma
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"