-
Notifications
You must be signed in to change notification settings - Fork 58
311 lines (268 loc) · 10.7 KB
/
release.yml
File metadata and controls
311 lines (268 loc) · 10.7 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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
name: PyPI and Helm Releases
on:
workflow_call:
env:
GCP_WORKLOAD_IDENTITY_PROVIDER: "projects/224545243904/locations/global/workloadIdentityPools/gh-nuclia/providers/gh-nuclia-provider"
GCP_SERVICE_ACCOUNT: "github-actions@nuclia-internal.iam.gserviceaccount.com"
ARTIFACT_REGISTRY_URL: oci://europe-west4-docker.pkg.dev/nuclia-internal/charts
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
build_wheels:
name: Build wheels
runs-on: ubuntu-24.04
steps:
- name: Generate a token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }}
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }}
owner: nuclia
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.14.2
- name: Setup env
run: |
pip install wheel
pip install -U twine
- name: Install Protoc
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set dependency versions in requirements
run: |
python bump.py --build=${{github.run_number}}
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: component_changes
with:
filters: |
nucliadb_protos:
- 'nucliadb_protos/**'
nucliadb_utils:
- 'nucliadb_utils/**'
nucliadb_models:
- 'nucliadb_models/**'
nucliadb_sdk:
- 'nucliadb_sdk/**'
nucliadb_dataset:
- 'nucliadb_dataset/**'
nucliadb_telemetry:
- 'nucliadb_telemetry/**'
nidx_protos:
- 'nidx/nidx_protos/**'
- 'nucliadb_protos/**'
# Install all packages we are going to release
- name: Install all packages
run: |
pip install -e ./nucliadb_protos/
pip install -e ./nidx/nidx_protos/
pip install -e ./nucliadb_telemetry/
pip install -e ./nucliadb_utils/
pip install -e ./nucliadb_models/
pip install -e ./nucliadb_sdk/
pip install -e ./nucliadb_dataset/
pip install -e ./nucliadb/
- name: Build wheels
run: pip wheel --no-deps -w dist ./nucliadb_protos/ ./nidx/nidx_protos/ ./nucliadb_utils/ ./nucliadb_models/ ./nucliadb_sdk/ ./nucliadb_telemetry ./nucliadb_dataset/ ./nucliadb/
- name: Upload to pypi
run: twine upload --verbose dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
push-docker:
name: Build public docker image
runs-on: ${{ matrix.arch.runner }}
strategy:
fail-fast: false
matrix:
arch:
- runner: ubuntu-24.04
tag: amd64
- runner: ubuntu-24.04-arm
tag: arm64
image:
- name: nucliadb
dockerfile: Dockerfile.withbinding
- name: nidx
dockerfile: Dockerfile.nidx
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
# We need to setup buildx to be able to cache with gha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Login to DockerHub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get release version
id: version_step
run: |-
python bump.py --build=${{github.run_number}}
cargo update --manifest-path nidx/Cargo.toml nidx_binding
VERSION=`cat VERSION`
HASH=`git rev-parse --short HEAD`
echo "version_number=$VERSION" >> $GITHUB_OUTPUT
echo "hash=$HASH" >> $GITHUB_OUTPUT
- id: build
name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
context: .
file: ${{ matrix.image.dockerfile }}
push: true
tags: nuclia/${{ matrix.image.name }}
cache-from: type=gha
cache-to: type=gha,mode=min
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: echo "${{ steps.build.outputs.digest }}" > /tmp/digest-${{ matrix.image.name }}-${{ matrix.arch.tag }}
- name: Upload digest
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: digests-${{ matrix.image.name }}-${{ matrix.arch.tag }}
path: /tmp/digest-${{ matrix.image.name }}-${{ matrix.arch.tag }}
if-no-files-found: error
retention-days: 1
merge-docker:
runs-on: ubuntu-latest
needs:
- push-docker
strategy:
matrix:
image:
- nucliadb
- nidx
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Get release version
id: version_step
run: |-
python bump.py --build=${{github.run_number}}
cargo update --manifest-path nidx/Cargo.toml nidx_binding
VERSION=`cat VERSION`
HASH=`git rev-parse --short HEAD`
echo "version_number=$VERSION" >> $GITHUB_OUTPUT
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Download digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: /tmp/digests
pattern: digests-${{ matrix.image }}-*
merge-multiple: true
- name: Login to DockerHub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Create manifest list and push
working-directory: /tmp/digests
run: >
docker buildx imagetools create
--tag nuclia/${{ matrix.image }}:latest
--tag nuclia/${{ matrix.image }}:${{ steps.version_step.outputs.version_number }}
--tag nuclia/${{ matrix.image }}:${{ steps.version_step.outputs.hash }}
$(printf 'nuclia/${{ matrix.image }}@%s ' $(cat *))
deploy:
name: Deploy Helm chart and trigger internal CI
runs-on: ubuntu-24.04
needs: push-docker
steps:
- name: Generate a token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.GHAPP_ID_NUCLIABOT }}
private-key: ${{ secrets.PK_GHAPP_NUCLIABOT }}
owner: nuclia
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Authenticate to Google Cloud
id: gcp-auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
workload_identity_provider: "${{ env.GCP_WORKLOAD_IDENTITY_PROVIDER }}"
service_account: "${{ env.GCP_SERVICE_ACCOUNT }}"
token_format: access_token
- name: Login to Google Artifact Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: europe-west4-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.gcp-auth.outputs.access_token }}
- name: Calculate short sha
id: env-vars
run: |-
HASH=`git rev-parse --short HEAD`
echo "short_sha=$HASH" >> $GITHUB_OUTPUT
- name: Set helm package image
id: version_step
run: |-
python bump.py --build=${{github.run_number}}
DOCKER_VERSION=`cat VERSION`
# Helm package versioning does not support '.postX'. Convert to '+postX'
HELM_VERSION=`echo $DOCKER_VERSION | sed 's/.post/-post/'`
# Update chart with versions
echo "HELM_VERSION=$HELM_VERSION"
echo "DOCKER_VERSION=$DOCKER_VERSION"
sed -i.bak "s#99999.99999.99999#$HELM_VERSION#" ./charts/nucliadb/Chart.yaml
sed -i.bak "s#88888.88888.88888#$DOCKER_VERSION#" ./charts/nucliadb/Chart.yaml
echo "helm_version=$HELM_VERSION" >> $GITHUB_OUTPUT
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
with:
version: v3.15.3
- name: Push helm package
run: |-
helm lint charts/nucliadb
helm package charts/nucliadb
helm push nucliadb-${{ steps.version_step.outputs.helm_version }}.tgz ${{ env.ARTIFACT_REGISTRY_URL }}
- name: Send to promotion queue
id: send-to-promo
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
token: ${{ steps.app-token.outputs.token }}
repository: nuclia/core-apps
event-type: promotions
client-payload: |-
{
"commit-sha": "${{ github.sha }}",
"components": [
{
"chart-version": "${{ steps.version_step.outputs.helm_version }}",
"component": "nucliadb-standalone",
"component-type": "regional"
}
],
"environment": "stage",
"promo_production": false,
"skip_argo_health": false,
"skip_promo_queue": false,
"slack_team": "S06B7JZMC76",
"team": "nucliadb",
"tests": {
"run-e2e": false,
"run-nuclia-e2e": false
}
}