@@ -163,6 +163,9 @@ push-images-to-staging:
163163 stage : release
164164 needs :
165165 - scan-images
166+ artifacts :
167+ paths :
168+ - build-info/${CI_PIPELINE_ID}-${SAMPLE}.txt
166169 variables :
167170 IN_REGISTRY : " ${CI_REGISTRY}"
168171 IN_REGISTRY_USER : " ${CI_REGISTRY_USER}"
@@ -175,105 +178,93 @@ push-images-to-staging:
175178 OUT_REGISTRY_TOKEN : " ${NGC_REGISTRY_TOKEN}"
176179 OUT_IMAGE_NAME : " ${NGC_STAGING_REGISTRY}/cuda-samples"
177180 OUT_IMAGE_TAG : " ${CI_COMMIT_SHORT_SHA}"
181+ after_script :
182+ - mkdir -p build-info
183+ - echo "${IN_IMAGE_NAME}:${SAMPLE}-${IN_IMAGE_TAG} ${NGC_REGISTRY_IMAGE}:${SAMPLE}-${CI_COMMIT_TAG}" > build-info/${CI_PIPELINE_ID}-${SAMPLE}.txt
178184
179- .release-images :
180- extends :
181- - .copy-images
182- stage : release
185+ generate-build-info :
186+ stage : ngc-publish
187+ artifacts :
188+ paths :
189+ - build-info/full-${CI_PIPELINE_ID}.txt
190+ script :
191+ - |
192+ for file in build-info/${CI_PIPELINE_ID}-*; do
193+ cat "$file" >> build-info/full-${CI_PIPELINE_ID}.txt
194+ done
195+
196+ .update-nspect :
197+ stage : ngc-publish
183198 needs :
184- - scan-images
185- - push-images-to-staging
199+ - job : generate-build-info
200+ image :
201+ name : " ${CNT_NGC_PUBLISH_IMAGE}"
202+ pull_policy : always
186203 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} "
204+ PROJECT_NAME : " k8s-samples "
205+ REPO_URL : " https://github.com/NVIDIA/k8s-samples.git "
206+ script :
207+ - |
208+ cnt-ngc-publish nspect --versions-file "build-info/full-${CI_PIPELINE_ID}.txt "
192209
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}"
210+ # Update the nspect staging environment to test the nspect publishing logic
211+ update-nspect-staging :
212+ extends :
213+ - .update-nspect
214+ except :
215+ - tags
216+ variables :
217+ ENV : " stage"
218+ RELEASE_VERSION : " test"
219+ NSPECT_CLIENT_ID : " ${NSPECT_STAGING_CLIENT_ID}"
220+ NSPECT_CLIENT_SECRET : " ${NSPECT_STAGING_CLIENT_SECRET}"
198221
199- release-images-to-ngc :
222+ # Update the nspect production environment with the new release
223+ update-nspect :
200224 extends :
201- - .release-images
225+ - .update-nspect
202226 rules :
203227 - if : $CI_COMMIT_TAG
204-
205- release-images-dummy :
206- extends :
207- - .release-images
208228 variables :
209- REGCTL : " echo [DUMMY] regctl"
210- rules :
211- - if : $CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""
229+ OSRB_BUG_ID : " ${OSRB_BUG_ID}"
230+ ENV : " prod"
231+ RELEASE_VERSION : " ${CI_COMMIT_TAG}"
232+ NSPECT_CLIENT_ID : " ${NSPECT_PROD_CLIENT_ID}"
233+ NSPECT_CLIENT_SECRET : " ${NSPECT_PROD_CLIENT_SECRET}"
212234
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
235+ .publish-images :
236+ stage : ngc-publish
237+ image :
238+ name : " ${CNT_NGC_PUBLISH_IMAGE}"
239+ pull_policy : always
226240 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]
241+ GITLAB_ACCESS_TOKEN : " ${CNT_GITLAB_TOKEN}"
232242 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
243+ - cnt-ngc-publish render --project-name "k8s-samples" --versions-file "build-info/full-${CI_PIPELINE_ID}.txt" --output k8s-samples.yaml
244+ - cnt-ngc-publish merge-request --files "k8s-samples.yaml"
257245
258- sign-ngc-images :
246+ # Raise an MR to publish the image to NGC
247+ ngc-image-publish :
259248 extends :
260- - .sign-images
261- needs :
262- - release-images-to-ngc
249+ - .publish-images
263250 rules :
264251 - if : $CI_COMMIT_TAG
252+ needs :
253+ - job : update-nspect
254+ - job : generate-build-info
255+ artifacts : true
265256 variables :
266- NGC_CLI_API_KEY : " ${NGC_REGISTRY_TOKEN}"
267- retry :
268- max : 2
257+ NGC_PUBLISHING_PROJECT_PATH : " ${NGC_PUBLISHING_PROD_PROJECT_PATH}"
269258
270- sign-images-dummy :
259+ # Create a dummy MR that exercises the publishing logic
260+ mock-image-publish :
271261 extends :
272- - .sign-images
262+ - .publish-images
263+ except :
264+ - tags
273265 needs :
274- - release-images-dummy
266+ - job : update-nspect-staging
267+ - job : generate-build-info
268+ artifacts : true
275269 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 == ""
270+ NGC_PUBLISHING_PROJECT_PATH : " ${NGC_PUBLISHING_TEST_PROJECT_PATH}"
0 commit comments