@@ -162,7 +162,11 @@ push-images-to-staging:
162162 - .copy-images
163163 stage : release
164164 needs :
165- - scan-images
165+ - job : pull-images
166+ optional : true
167+ artifacts :
168+ paths :
169+ - build-info/${CI_PIPELINE_ID}-${SAMPLE}.txt
166170 variables :
167171 IN_REGISTRY : " ${CI_REGISTRY}"
168172 IN_REGISTRY_USER : " ${CI_REGISTRY_USER}"
@@ -175,105 +179,95 @@ push-images-to-staging:
175179 OUT_REGISTRY_TOKEN : " ${NGC_REGISTRY_TOKEN}"
176180 OUT_IMAGE_NAME : " ${NGC_STAGING_REGISTRY}/cuda-samples"
177181 OUT_IMAGE_TAG : " ${CI_COMMIT_SHORT_SHA}"
182+ after_script :
183+ - mkdir -p build-info
184+ - echo "${SAMPLE}-${OUT_IMAGE_TAG} ${SAMPLE}-${CI_COMMIT_TAG}" > build-info/${CI_PIPELINE_ID}-${SAMPLE}.txt
178185
179- .release-images :
180- extends :
181- - .copy-images
182- stage : release
186+ generate-build-info :
187+ stage : ngc-publish
188+ needs :
189+ - job : push-images-to-staging
190+ artifacts :
191+ paths :
192+ - build-info/full-${CI_PIPELINE_ID}.txt
193+ script :
194+ - |
195+ for file in build-info/${CI_PIPELINE_ID}-*; do
196+ cat "$file" >> build-info/full-${CI_PIPELINE_ID}.txt
197+ done
198+
199+ .update-nspect :
200+ stage : ngc-publish
183201 needs :
184- - scan-images
185- - push-images-to-staging
202+ - job : generate-build-info
203+ image :
204+ name : " ${CNT_NGC_PUBLISH_IMAGE}"
205+ pull_policy : always
186206 variables :
187- IN_REGISTRY : " ${CI_REGISTRY} "
188- IN_REGISTRY_USER : " ${CI_REGISTRY_USER} "
189- IN_REGISTRY_TOKEN : " ${CI_REGISTRY_PASSWORD} "
190- IN_IMAGE_NAME : " ${CI_REGISTRY_IMAGE}/cuda-samples "
191- IN_IMAGE_TAG : " ${CI_COMMIT_SHORT_SHA} "
207+ PROJECT_NAME : " k8s-samples "
208+ REPO_URL : " https://github.com/NVIDIA/k8s-samples.git "
209+ script :
210+ - |
211+ cnt-ngc-publish nspect --versions-file "build-info/full-${CI_PIPELINE_ID}.txt "
192212
193- OUT_REGISTRY : " ${NGC_REGISTRY}"
194- OUT_REGISTRY_USER : " ${NGC_REGISTRY_USER}"
195- OUT_REGISTRY_TOKEN : " ${NGC_REGISTRY_TOKEN}"
196- OUT_IMAGE_NAME : " ${NGC_REGISTRY_IMAGE}"
197- OUT_IMAGE_TAG : " ${CI_COMMIT_TAG}"
213+ # Update the nspect staging environment to test the nspect publishing logic
214+ update-nspect-staging :
215+ extends :
216+ - .update-nspect
217+ except :
218+ - tags
219+ variables :
220+ ENV : " stage"
221+ RELEASE_VERSION : " test"
222+ NSPECT_CLIENT_ID : " ${NSPECT_STAGING_CLIENT_ID}"
223+ NSPECT_CLIENT_SECRET : " ${NSPECT_STAGING_CLIENT_SECRET}"
198224
199- release-images-to-ngc :
225+ # Update the nspect production environment with the new release
226+ update-nspect :
200227 extends :
201- - .release-images
228+ - .update-nspect
202229 rules :
203230 - if : $CI_COMMIT_TAG
204-
205- release-images-dummy :
206- extends :
207- - .release-images
208231 variables :
209- REGCTL : " echo [DUMMY] regctl"
210- rules :
211- - if : $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
232+ OSRB_BUG_ID : " ${OSRB_BUG_ID}"
233+ ENV : " prod"
234+ RELEASE_VERSION : " ${CI_COMMIT_TAG}"
235+ NSPECT_CLIENT_ID : " ${NSPECT_PROD_CLIENT_ID}"
236+ NSPECT_CLIENT_SECRET : " ${NSPECT_PROD_CLIENT_SECRET}"
212237
213- # .sign-images forms the base of the jobs which sign images in the NGC registry.
214- .sign-images :
215- stage : sign
216- image : ubuntu:latest
217- parallel :
218- matrix :
219- - SAMPLE :
220- - devicequery
221- - nbody
222- - nvbandwidth
223- - simplemultigpu
224- - vectoradd
225- - vulkan
238+ .publish-images :
239+ stage : ngc-publish
240+ image :
241+ name : " ${CNT_NGC_PUBLISH_IMAGE}"
242+ pull_policy : always
226243 variables :
227- IMAGE_NAME : " ${NGC_REGISTRY_IMAGE}"
228- IMAGE_TAG : " ${CI_COMMIT_TAG}"
229- NGC_CLI : " ngc-cli/ngc"
230- before_script :
231- - !reference [.ngccli-setup, before_script]
244+ GITLAB_ACCESS_TOKEN : " ${CNT_GITLAB_TOKEN}"
232245 script :
233- - |
234- # We ensure that the IMAGE_NAME and IMAGE_TAG is set
235- echo Image Name: ${IMAGE_NAME} && [[ -n "${IMAGE_NAME}" ]] || exit 1
236- echo Image Tag: ${IMAGE_TAG} && [[ -n "${IMAGE_TAG}" ]] || exit 1
237-
238- export IMAGE=${IMAGE_NAME}:${SAMPLE}-${IMAGE_TAG}
239- echo "Signing the image ${IMAGE}"
240- ${NGC_CLI} registry image publish --source ${IMAGE} ${IMAGE} --public --discoverable --allow-guest --sign --org nvidia
241-
242- # Define the external image signing steps for NGC
243- # Download the ngc cli binary for use in the sign steps
244- .ngccli-setup :
245- before_script :
246- - apt-get update && apt-get install -y curl unzip jq
247- - |
248- if [ -z "${NGCCLI_VERSION}" ]; then
249- NGC_VERSION_URL="https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions"
250- # Extract the latest version from the JSON data using jq
251- export NGCCLI_VERSION=$(curl -s $NGC_VERSION_URL | jq -r '.recipe.latestVersionIdStr')
252- fi
253- echo "NGCCLI_VERSION ${NGCCLI_VERSION}"
254- - curl -sSLo ngccli_linux.zip https://api.ngc.nvidia.com/v2/resources/nvidia/ngc-apps/ngc_cli/versions/${NGCCLI_VERSION}/files/ngccli_linux.zip
255- - unzip ngccli_linux.zip
256- - chmod u+x ngc-cli/ngc
246+ - cnt-ngc-publish render --project-name "k8s-samples" --versions-file "build-info/full-${CI_PIPELINE_ID}.txt" --output k8s-samples.yaml
247+ - cnt-ngc-publish merge-request --files "k8s-samples.yaml"
257248
258- sign-ngc-images :
249+ # Raise an MR to publish the image to NGC
250+ ngc-image-publish :
259251 extends :
260- - .sign-images
261- needs :
262- - release-images-to-ngc
252+ - .publish-images
263253 rules :
264254 - if : $CI_COMMIT_TAG
255+ needs :
256+ - job : update-nspect
257+ - job : generate-build-info
258+ artifacts : true
265259 variables :
266- NGC_CLI_API_KEY : " ${NGC_REGISTRY_TOKEN}"
267- retry :
268- max : 2
260+ NGC_PUBLISHING_PROJECT_PATH : " ${NGC_PUBLISHING_PROD_PROJECT_PATH}"
269261
270- sign-images-dummy :
262+ # Create a dummy MR that exercises the publishing logic
263+ mock-image-publish :
271264 extends :
272- - .sign-images
265+ - .publish-images
266+ except :
267+ - tags
273268 needs :
274- - release-images-dummy
269+ - job : update-nspect-staging
270+ - job : generate-build-info
271+ artifacts : true
275272 variables :
276- NGC_CLI : " echo [DUMMY] ngc-cli/ngc"
277- IMAGE_TAG : " ${CI_COMMIT_SHORT_SHA}"
278- rules :
279- - if : $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
273+ NGC_PUBLISHING_PROJECT_PATH : " ${NGC_PUBLISHING_TEST_PROJECT_PATH}"
0 commit comments