From 5751f1b4be7d2b39602e80156feea08ef95321c3 Mon Sep 17 00:00:00 2001 From: shahasad <43590019+shahasad@users.noreply.github.com> Date: Tue, 12 Mar 2019 20:22:22 -0700 Subject: [PATCH] fix version number for tarball packages (#600) (#610) * add variables for version number and git commit hash * fix typo * fix typo * some logging * some logging * some logging * some logging * some logging * some logging * some logging * some logging * some more edits to see generic scripts can print * working * fixing windows git hash * try quoted echo * fix git rev-parse * echo without quotes * removed commit hash from artifact filename, added long commit hash as a file inside * added the missing commit id parameter * fix windows pipeline * keep only win 64, others disabled * remove disabling conditions --- .../c-api-packaging-pipelines.yml | 34 +++++++++++++------ ...ifacts-package-and-publish-steps-posix.yml | 3 ++ ...acts-package-and-publish-steps-windows.yml | 3 ++ .../set-version-number-variables-step.yml | 30 ++++++++++++++++ 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 tools/ci_build/github/azure-pipelines/templates/set-version-number-variables-step.yml 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 97e15f2cb81e3..e52f3e3cde23c 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 @@ -3,14 +3,16 @@ 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 @@ -18,14 +20,16 @@ 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) -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 @@ -33,14 +37,16 @@ jobs: 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 @@ -48,7 +54,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) @@ -57,9 +66,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 @@ -72,6 +82,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: @@ -89,8 +100,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 @@ -103,6 +114,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: @@ -120,8 +132,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 @@ -134,6 +146,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' @@ -167,7 +180,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 16bd4440d1e9f..1c40811034487 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 24a4dee7978ad..3dfac64597215 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 0000000000000..007d40b7aef0f --- /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