diff --git a/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml index b9c2168ccc..96e40b8c38 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml @@ -4,42 +4,48 @@ jobs: pool: Linux-CPU steps: - template: templates/set-test-data-variables-step.yml + - template: templates/set-version-number-variables-step.yml - script: 'tools/ci_build/github/linux/run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -x " --test_data_url $(TestDataUrl) --test_data_checksum $(TestDataChecksum)"' displayName: 'Build and Test Linux on Docker' - template: templates/c-api-artifacts-package-and-publish-steps-posix.yml parameters: buildConfig: 'Release' - artifactName: 'onnxruntime-linux-x64' + artifactName: 'onnxruntime-linux-x64-$(OnnxRuntimeVersion)' libraryName: 'libonnxruntime.so' + commitId: $(OnnxRuntimeGitCommitHash) - template: templates/clean-agent-build-directory-step.yml - job: Linux_C_API_Packaging_CPU_x86 pool: Linux-CPU steps: - template: templates/set-test-data-variables-step.yml + - template: templates/set-version-number-variables-step.yml - script: 'tools/ci_build/github/linux/run_dockerbuild.sh -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -a x86 -x " --x86 --test_data_url $(TestDataUrl) --test_data_checksum $(TestDataChecksum)"' displayName: 'Build and Test Linux on Docker' - template: templates/c-api-artifacts-package-and-publish-steps-posix.yml parameters: buildConfig: 'Release' - artifactName: 'onnxruntime-linux-x86' + artifactName: 'onnxruntime-linux-x86-$(OnnxRuntimeVersion)' libraryName: 'libonnxruntime.so' + commitId: $(OnnxRuntimeGitCommitHash) - template: templates/clean-agent-build-directory-step.yml - job: Linux_C_API_Packaging_GPU_x64 pool: Linux-GPU steps: - template: templates/set-test-data-variables-step.yml + - template: templates/set-version-number-variables-step.yml - script: 'tools/ci_build/github/linux/run_dockerbuild.sh -o ubuntu16.04 -d gpu -c cuda9.1-cudnn7.1 -r $(Build.BinariesDirectory) -x " --test_data_url $(TestDataUrl) --test_data_checksum $(TestDataChecksum)"' displayName: 'Build and Test Linux on Docker' - template: templates/c-api-artifacts-package-and-publish-steps-posix.yml parameters: buildConfig: 'Release' - artifactName: 'onnxruntime-linux-x64-gpu' + artifactName: 'onnxruntime-linux-x64-gpu-$(OnnxRuntimeVersion)' libraryName: 'libonnxruntime.so' + commitId: $(OnnxRuntimeGitCommitHash) - template: templates/clean-agent-build-directory-step.yml @@ -47,7 +53,10 @@ jobs: pool: vmImage: 'macOS-10.13' steps: + - template: templates/set-test-data-variables-step.yml + - template: templates/set-version-number-variables-step.yml + - script: | sudo xcode-select --switch /Applications/Xcode_10.app/Contents/Developer python3 $(Build.SourcesDirectory)/tools/ci_build/build.py --use_openmp --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --parallel --build_shared_lib --config RelWithDebInfo --enable_onnx_tests --test_data_url $(TestDataUrl) --test_data_checksum $(TestDataChecksum) @@ -55,9 +64,10 @@ jobs: - template: templates/c-api-artifacts-package-and-publish-steps-posix.yml parameters: buildConfig: 'RelWithDebInfo' - artifactName: 'onnxruntime-osx-x64' + artifactName: 'onnxruntime-osx-x64-$(OnnxRuntimeVersion)' libraryName: 'libonnxruntime.dylib' - + commitId: $(OnnxRuntimeGitCommitHash) + - template: templates/clean-agent-build-directory-step.yml @@ -70,6 +80,7 @@ jobs: steps: - template: templates/set-test-data-variables-step.yml + - template: templates/set-version-number-variables-step.yml - template: templates/windows-build-tools-setup-steps.yml parameters: @@ -87,8 +98,8 @@ jobs: - template: templates/c-api-artifacts-package-and-publish-steps-windows.yml parameters: buildConfig: $(buildConfig) - artifactName: 'onnxruntime-win-$(buildArch)' - + artifactName: 'onnxruntime-win-$(buildArch)-$(OnnxRuntimeVersion)' + commitId: $(OnnxRuntimeGitCommitHash) - template: templates/clean-agent-build-directory-step.yml @@ -101,6 +112,7 @@ jobs: steps: - template: templates/set-test-data-variables-step.yml + - template: templates/set-version-number-variables-step.yml - template: templates/windows-build-tools-setup-steps.yml parameters: @@ -118,8 +130,8 @@ jobs: - template: templates/c-api-artifacts-package-and-publish-steps-windows.yml parameters: buildConfig: $(buildConfig) - artifactName: 'onnxruntime-win-$(buildArch)' - + artifactName: 'onnxruntime-win-$(buildArch)-$(OnnxRuntimeVersion)' + commitId: $(OnnxRuntimeGitCommitHash) - template: templates/clean-agent-build-directory-step.yml @@ -132,6 +144,7 @@ jobs: steps: - template: templates/set-test-data-variables-step.yml + - template: templates/set-version-number-variables-step.yml - task: CmdLine@2 displayName: 'Set CUDA 9.1 path' @@ -164,7 +177,8 @@ jobs: - template: templates/c-api-artifacts-package-and-publish-steps-windows.yml parameters: buildConfig: $(buildConfig) - artifactName: 'onnxruntime-win-gpu-$(buildArch)' + artifactName: 'onnxruntime-win-$(buildArch)-gpu-$(OnnxRuntimeVersion)' + commitId: $(OnnxRuntimeGitCommitHash) - task: PowerShell@2 displayName: 'Clean up Cuda Path 9.1' diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-posix.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-posix.yml index 16bd4440d1..1c40811034 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-posix.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-posix.yml @@ -4,6 +4,7 @@ parameters: buildConfig: 'RelWithDebInfo' artifactName: 'onnxruntime-linux-x64' libraryName: 'libonnxruntime.so' + commitId: '' steps: - task: CmdLine@2 displayName: 'Copy build artifacts for zipping' @@ -20,6 +21,8 @@ steps: cp $(Build.SourcesDirectory)/docs/C_API.md $(Build.BinariesDirectory)/${{parameters.artifactName}}/C_API.md cp $(Build.SourcesDirectory)/LICENSE $(Build.BinariesDirectory)/${{parameters.artifactName}}/LICENSE cp $(Build.SourcesDirectory)/ThirdPartyNotices.txt $(Build.BinariesDirectory)/${{parameters.artifactName}}/ThirdPartyNotices.txt + cp $(Build.SourcesDirectory)/VERSION_NUMBER $(Build.BinariesDirectory)/${{parameters.artifactName}}/VERSION_NUMBER + echo ${{parameters.commitId}} > $(Build.BinariesDirectory)/${{parameters.artifactName}}/GIT_COMMIT_ID workingDirectory: '$(Build.BinariesDirectory)/${{parameters.buildConfig}}' diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml index 24a4dee797..3dfac64597 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml @@ -3,6 +3,7 @@ parameters: buildConfig: 'RelWithDebInfo' artifactName: 'onnxruntime-win-x64' + comitId: '' steps: - task: CmdLine@2 displayName: 'Copy build artifacts for zipping' @@ -21,6 +22,8 @@ steps: copy $(Build.SourcesDirectory)\docs\C_API.md $(Build.BinariesDirectory)\${{parameters.artifactName}}\C_API.md copy $(Build.SourcesDirectory)\LICENSE $(Build.BinariesDirectory)\${{parameters.artifactName}}\LICENSE copy $(Build.SourcesDirectory)\ThirdPartyNotices.txt $(Build.BinariesDirectory)\${{parameters.artifactName}}\ThirdPartyNotices.txt + copy $(Build.SourcesDirectory)/VERSION_NUMBER $(Build.BinariesDirectory)\${{parameters.artifactName}}\VERSION_NUMBER + @echo ${{parameters.commitId}} > $(Build.BinariesDirectory)\${{parameters.artifactName}}\GIT_COMMIT_ID workingDirectory: '$(Build.BinariesDirectory)\${{parameters.buildConfig}}' diff --git a/tools/ci_build/github/azure-pipelines/templates/set-version-number-variables-step.yml b/tools/ci_build/github/azure-pipelines/templates/set-version-number-variables-step.yml new file mode 100644 index 0000000000..007d40b7ae --- /dev/null +++ b/tools/ci_build/github/azure-pipelines/templates/set-version-number-variables-step.yml @@ -0,0 +1,30 @@ +# Sets version number from VERSION.txt into a variable. As well as the git commit hash. + +steps: +- task: CmdLine@2 + displayName: 'Set Version Number variables for Windows' + inputs: + script: | + SETLOCAL EnableDelayedExpansion + set /p _OnnxRuntimeVersion=<$(Build.SourcesDirectory)\VERSION_NUMBER + @echo ##vso[task.setvariable variable=OnnxRuntimeVersion;]%_OnnxRuntimeVersion% + + FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse HEAD`) DO ( + @echo ##vso[task.setvariable variable=OnnxRuntimeGitCommitHash;]%%F + ) + + workingDirectory: '$(Build.SourcesDirectory)' + condition: eq(variables['Agent.OS'], 'Windows_NT') + +- task: CmdLine@2 + displayName: 'Set version number variables for Unix' + inputs: + script: | + _OnnxRuntimeVersion=$(head -1 $(Build.SourcesDirectory)/VERSION_NUMBER) + echo "##vso[task.setvariable variable=OnnxRuntimeVersion;]$_OnnxRuntimeVersion" + + _OnnxRuntimeGitCommitHash=$(git rev-parse HEAD) + echo "##vso[task.setvariable variable=OnnxRuntimeGitCommitHash;]$_OnnxRuntimeGitCommitHash" + + workingDirectory: '$(Build.SourcesDirectory)' + condition: not(eq(variables['Agent.OS'], 'Windows_NT')) \ No newline at end of file