Skip to content

Commit e3ee60c

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

File tree

1 file changed

+94
-20
lines changed

1 file changed

+94
-20
lines changed

.nvidia-ci.yml

Lines changed: 94 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -229,53 +229,123 @@ 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+
244+
IN_IMAGE_TAG: "${CI_COMMIT_SHORT_SHA}"
245+
OUT_IMAGE_TAG: "${CI_COMMIT_TAG}"
246+
before_script:
247+
- |
248+
if [ -z ${IN_IMAGE_TAG} ]; then
249+
echo "IN_IMAGE_TAG not set"
250+
exit 1
251+
fi
252+
if [ -z ${OUT_IMAGE_TAG} ]; then
253+
echo "OUT_IMAGE_TAG not set"
254+
exit 1
255+
fi
256+
257+
rm -f ${VERSION_FILE}
258+
echo "${IN_IMAGE_TAG} ${OUT_IMAGE_TAG}" >> ${VERSION_FILE}
259+
echo "${IN_IMAGE_TAG}-packaging ${OUT_IMAGE_TAG}-packaging" >> ${VERSION_FILE}
260+
cat ${VERSION_FILE}
261+
artifacts:
262+
paths:
263+
- "${VERSION_FILE}"
264+
232265
.publish-images:
233266
stage: ngc-publish
234267
needs:
235268
- scan-images
236269
- push-images-to-staging
270+
extends:
271+
- .create-version-file
237272
image:
238273
name: "${CNT_NGC_PUBLISH_IMAGE}"
239274
pull_policy: always
240-
variables:
241-
242275
variables:
243276
GITLAB_ACCESS_TOKEN: "${CNT_GITLAB_TOKEN}"
244-
245-
IN_IMAGE_TAG: "${CI_COMMIT_SHORT_SHA}"
246-
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:
277+
script:
251278
- |
252279
if [ -n "${OVERRIDE_PUBLISHING_PROJECT_PATH}" ]; then
253280
NGC_PUBLISHING_PROJECT_PATH="${OVERRIDE_PUBLISHING_PROJECT_PATH}"
254281
fi
255-
256282
if [ -z "${NGC_PUBLISHING_PROJECT_PATH}" ]; then
257283
echo "NGC_PUBLISHING_PROJECT_PATH not set"
258284
exit 1
259285
fi
260286
261287
echo "publishing to ${NGC_PUBLISHING_PROJECT_PATH}"
262288
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"
289+
cnt-ngc-publish render --project-name "${PROJECT_NAME}" --versions-file "${VERSION_FILE}" --output "${PROJECT_NAME}".yaml
290+
cnt-ngc-publish merge-request --files "${PROJECT_NAME}.yaml"
270291
artifacts:
271292
paths:
272-
- "${VERSION_FILE}"
273293
- "${PROJECT_NAME}.yaml"
274294

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

328+
# Update the nspect staging environment to test the nspect publishing logic
329+
update-nspect-staging:
330+
extends:
331+
- .update-nspect
332+
rules:
333+
- if: $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
334+
variables:
335+
ENV: "stage"
336+
RELEASE_VERSION: "test"
337+
NSPECT_CLIENT_ID: "${NSPECT_STAGING_CLIENT_ID}"
338+
NSPECT_CLIENT_SECRET: "${NSPECT_STAGING_CLIENT_SECRET}"
339+
# We override the OUT_IMAGE_TAG so that this is different from the input tag
340+
# Note that for actual releases we use the git tag.
341+
OUT_IMAGE_TAG: "publish-${CI_COMMIT_SHORT_SHA}"
342+
343+
# Publish the images from the staging registry to NGC.
276344
publish-images-to-ngc:
277345
extends:
278346
- .publish-images
347+
needs:
348+
- update-nspect
279349
rules:
280350
- if: $CI_COMMIT_TAG
281351

@@ -284,8 +354,12 @@ publish-images-to-ngc:
284354
publish-images-dummy:
285355
extends:
286356
- .publish-images
357+
needs:
358+
- update-nspect-staging
359+
rules:
360+
- if: $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
287361
variables:
288362
OVERRIDE_PUBLISHING_PROJECT_PATH: "dl/container-dev/ngc-automation"
363+
# We override the OUT_IMAGE_TAG so that this is different from the input tag
364+
# Note that for actual releases we use the git tag.
289365
OUT_IMAGE_TAG: "publish-${CI_COMMIT_SHORT_SHA}"
290-
rules:
291-
- if: $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""

0 commit comments

Comments
 (0)