Skip to content

Commit 2e6f0df

Browse files
committed
[no-relnote] Add NSpect release automation
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent e03ac36 commit 2e6f0df

File tree

1 file changed

+85
-15
lines changed

1 file changed

+85
-15
lines changed

.nvidia-ci.yml

Lines changed: 85 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,53 +229,121 @@ push-images-to-staging:
229229
OUT_IMAGE_NAME: "${NGC_STAGING_REGISTRY}/container-toolkit"
230230
OUT_IMAGE_TAG: "${CI_COMMIT_SHORT_SHA}"
231231

232+
# The .create-version-file job creates a text file consisting of the images
233+
# that are to be released for this particular version.
234+
# The container images with the tags:
235+
# ${IN_IMAGE_TAG} and ${IN_IMAGE_TAG}-packaging
236+
# are scheduled for release as
237+
# ${OUT_IMAGE_TAG} and ${OUT_IMAGE_TAG}-packaging
238+
# respectively.
239+
.create-version-file:
240+
variables:
241+
VERSION_FILE: "build-info-${CI_PIPELINE_ID}.txt"
242+
PROJECT_NAME: "nvidia-container-toolkit"
243+
before_script:
244+
before_script:
245+
- |
246+
if [ -z ${IN_IMAGE_TAG} ]; then
247+
echo "IN_IMAGE_TAG not set"
248+
exit 1
249+
fi
250+
if [ -z ${OUT_IMAGE_TAG} ]; then
251+
echo "OUT_IMAGE_TAG not set"
252+
exit 1
253+
fi
254+
255+
rm -f ${VERSION_FILE}
256+
echo "${IN_IMAGE_TAG} ${OUT_IMAGE_TAG}" >> ${VERSION_FILE}
257+
echo "${IN_IMAGE_TAG}-packaging ${OUT_IMAGE_TAG}-packaging" >> ${VERSION_FILE}
258+
cat ${VERSION_FILE}
259+
artifacts:
260+
paths:
261+
- "${VERSION_FILE}"
262+
232263
.publish-images:
233264
stage: ngc-publish
234265
needs:
235266
- scan-images
236267
- push-images-to-staging
268+
extends:
269+
- .create-version-file
237270
image:
238271
name: "${CNT_NGC_PUBLISH_IMAGE}"
239272
pull_policy: always
240-
variables:
241-
242273
variables:
243274
GITLAB_ACCESS_TOKEN: "${CNT_GITLAB_TOKEN}"
244275

245276
IN_IMAGE_TAG: "${CI_COMMIT_SHORT_SHA}"
246277
OUT_IMAGE_TAG: "${CI_COMMIT_TAG}"
247-
248-
VERSION_FILE: "build-info-${CI_PIPELINE_ID}.txt"
249-
PROJECT_NAME: "nvidia-container-toolkit"
250-
before_script:
278+
script:
251279
- |
252280
if [ -n "${OVERRIDE_PUBLISHING_PROJECT_PATH}" ]; then
253281
NGC_PUBLISHING_PROJECT_PATH="${OVERRIDE_PUBLISHING_PROJECT_PATH}"
254282
fi
255-
256283
if [ -z "${NGC_PUBLISHING_PROJECT_PATH}" ]; then
257284
echo "NGC_PUBLISHING_PROJECT_PATH not set"
258285
exit 1
259286
fi
260287
261288
echo "publishing to ${NGC_PUBLISHING_PROJECT_PATH}"
262289
263-
rm -f ${VERSION_FILE}
264-
echo "${IN_IMAGE_TAG} ${OUT_IMAGE_TAG}" >> ${VERSION_FILE}
265-
echo "${IN_IMAGE_TAG}-packaging ${OUT_IMAGE_TAG}-packaging" >> ${VERSION_FILE}
266-
cat ${VERSION_FILE}
267-
script:
268-
- cnt-ngc-publish render --project-name "${PROJECT_NAME}" --versions-file "${VERSION_FILE}" --output "${PROJECT_NAME}".yaml
269-
- cnt-ngc-publish merge-request --files "${PROJECT_NAME}.yaml"
290+
cnt-ngc-publish render --project-name "${PROJECT_NAME}" --versions-file "${VERSION_FILE}" --output "${PROJECT_NAME}".yaml
291+
cnt-ngc-publish merge-request --files "${PROJECT_NAME}.yaml"
270292
artifacts:
271293
paths:
272-
- "${VERSION_FILE}"
273294
- "${PROJECT_NAME}.yaml"
274295

296+
.update-nspect:
297+
stage: ngc-publish
298+
needs:
299+
- push-images-to-staging
300+
extends:
301+
- .create-version-file
302+
image:
303+
name: "${CNT_NGC_PUBLISH_IMAGE}"
304+
pull_policy: always
305+
variables:
306+
REPO_URL: "https://github.com/NVIDIA/nvidia-container-toolkit.git"
307+
script:
308+
- |
309+
if [ -z "${OSRB_BUG_ID}" ]; then
310+
echo "OSRB_BUG_ID not set"
311+
exit 1
312+
fi
313+
if [ -z "${RELEASE_VERSION}" ]; then
314+
export RELEASE_VERSION="${CI_COMMIT_TAG//-*}"
315+
fi
316+
cnt-ngc-publish nspect --versions-file "${VERSION_FILE}"
317+
318+
# Update the nspect staging environment to test the nspect publishing logic
319+
update-nspect-staging:
320+
extends:
321+
- .update-nspect
322+
rules:
323+
- if: $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
324+
variables:
325+
ENV: "stage"
326+
RELEASE_VERSION: "test"
327+
NSPECT_CLIENT_ID: "${NSPECT_STAGING_CLIENT_ID}"
328+
NSPECT_CLIENT_SECRET: "${NSPECT_STAGING_CLIENT_SECRET}"
329+
330+
# Update the nspect production environment with the new release
331+
update-nspect:
332+
extends:
333+
- .update-nspect
334+
rules:
335+
- if: $CI_COMMIT_TAG
336+
variables:
337+
OSRB_BUG_ID: "${OSRB_BUG_ID}"
338+
ENV: "prod"
339+
NSPECT_CLIENT_ID: "${NSPECT_PROD_CLIENT_ID}"
340+
NSPECT_CLIENT_SECRET: "${NSPECT_PROD_CLIENT_SECRET}"
275341

276342
publish-images-to-ngc:
277343
extends:
278344
- .publish-images
345+
needs:
346+
- update-nspec
279347
rules:
280348
- if: $CI_COMMIT_TAG
281349

@@ -284,6 +352,8 @@ publish-images-to-ngc:
284352
publish-images-dummy:
285353
extends:
286354
- .publish-images
355+
needs:
356+
- update-nspec-staging
287357
variables:
288358
OVERRIDE_PUBLISHING_PROJECT_PATH: "dl/container-dev/ngc-automation"
289359
OUT_IMAGE_TAG: "publish-${CI_COMMIT_SHORT_SHA}"

0 commit comments

Comments
 (0)