Skip to content

Commit 5751f1b

Browse files
authored
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
1 parent b8c5bf2 commit 5751f1b

4 files changed

+60
-10
lines changed

tools/ci_build/github/azure-pipelines/c-api-packaging-pipelines.yml

+24-10
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,61 @@ jobs:
33
pool: Linux-CPU
44
steps:
55
- template: templates/set-test-data-variables-step.yml
6+
- template: templates/set-version-number-variables-step.yml
67

78
- 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)"'
89
displayName: 'Build and Test Linux on Docker'
910
- template: templates/c-api-artifacts-package-and-publish-steps-posix.yml
1011
parameters:
1112
buildConfig: 'Release'
12-
artifactName: 'onnxruntime-linux-x64'
13+
artifactName: 'onnxruntime-linux-x64-$(OnnxRuntimeVersion)'
1314
libraryName: 'libonnxruntime.so'
15+
commitId: $(OnnxRuntimeGitCommitHash)
1416
- template: templates/clean-agent-build-directory-step.yml
1517

1618

1719
- job: Linux_C_API_Packaging_CPU_x86
1820
pool: Linux-CPU
1921
steps:
2022
- template: templates/set-test-data-variables-step.yml
23+
- template: templates/set-version-number-variables-step.yml
2124

2225
- 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)"'
2326
displayName: 'Build and Test Linux on Docker'
2427
- template: templates/c-api-artifacts-package-and-publish-steps-posix.yml
2528
parameters:
2629
buildConfig: 'Release'
27-
artifactName: 'onnxruntime-linux-x86'
30+
artifactName: 'onnxruntime-linux-x86-$(OnnxRuntimeVersion)'
2831
libraryName: 'libonnxruntime.so'
32+
commitId: $(OnnxRuntimeGitCommitHash)
2933
- template: templates/clean-agent-build-directory-step.yml
3034

3135

3236
- job: Linux_C_API_Packaging_GPU_x64
3337
pool: Linux-GPU
3438
steps:
3539
- template: templates/set-test-data-variables-step.yml
40+
- template: templates/set-version-number-variables-step.yml
3641

3742
- 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)"'
3843
displayName: 'Build and Test Linux on Docker'
3944
- template: templates/c-api-artifacts-package-and-publish-steps-posix.yml
4045
parameters:
4146
buildConfig: 'Release'
42-
artifactName: 'onnxruntime-linux-x64-gpu'
47+
artifactName: 'onnxruntime-linux-x64-gpu-$(OnnxRuntimeVersion)'
4348
libraryName: 'libonnxruntime.so'
49+
commitId: $(OnnxRuntimeGitCommitHash)
4450
- template: templates/clean-agent-build-directory-step.yml
4551

4652

4753
- job: MacOS_C_API_Packaging_CPU_x64
4854
pool:
4955
vmImage: 'macOS-10.13'
5056
steps:
57+
5158
- template: templates/set-test-data-variables-step.yml
59+
- template: templates/set-version-number-variables-step.yml
60+
5261
- script: |
5362
sudo xcode-select --switch /Applications/Xcode_10.app/Contents/Developer
5463
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:
5766
- template: templates/c-api-artifacts-package-and-publish-steps-posix.yml
5867
parameters:
5968
buildConfig: 'RelWithDebInfo'
60-
artifactName: 'onnxruntime-osx-x64'
69+
artifactName: 'onnxruntime-osx-x64-$(OnnxRuntimeVersion)'
6170
libraryName: 'libonnxruntime.dylib'
62-
71+
commitId: $(OnnxRuntimeGitCommitHash)
72+
6373
- template: templates/clean-agent-build-directory-step.yml
6474

6575

@@ -72,6 +82,7 @@ jobs:
7282

7383
steps:
7484
- template: templates/set-test-data-variables-step.yml
85+
- template: templates/set-version-number-variables-step.yml
7586

7687
- template: templates/windows-build-tools-setup-steps.yml
7788
parameters:
@@ -89,8 +100,8 @@ jobs:
89100
- template: templates/c-api-artifacts-package-and-publish-steps-windows.yml
90101
parameters:
91102
buildConfig: $(buildConfig)
92-
artifactName: 'onnxruntime-win-$(buildArch)'
93-
103+
artifactName: 'onnxruntime-win-$(buildArch)-$(OnnxRuntimeVersion)'
104+
commitId: $(OnnxRuntimeGitCommitHash)
94105
- template: templates/clean-agent-build-directory-step.yml
95106

96107

@@ -103,6 +114,7 @@ jobs:
103114

104115
steps:
105116
- template: templates/set-test-data-variables-step.yml
117+
- template: templates/set-version-number-variables-step.yml
106118

107119
- template: templates/windows-build-tools-setup-steps.yml
108120
parameters:
@@ -120,8 +132,8 @@ jobs:
120132
- template: templates/c-api-artifacts-package-and-publish-steps-windows.yml
121133
parameters:
122134
buildConfig: $(buildConfig)
123-
artifactName: 'onnxruntime-win-$(buildArch)'
124-
135+
artifactName: 'onnxruntime-win-$(buildArch)-$(OnnxRuntimeVersion)'
136+
commitId: $(OnnxRuntimeGitCommitHash)
125137
- template: templates/clean-agent-build-directory-step.yml
126138

127139

@@ -134,6 +146,7 @@ jobs:
134146

135147
steps:
136148
- template: templates/set-test-data-variables-step.yml
149+
- template: templates/set-version-number-variables-step.yml
137150

138151
- task: CmdLine@2
139152
displayName: 'Set CUDA 9.1 path'
@@ -167,7 +180,8 @@ jobs:
167180
- template: templates/c-api-artifacts-package-and-publish-steps-windows.yml
168181
parameters:
169182
buildConfig: $(buildConfig)
170-
artifactName: 'onnxruntime-win-gpu-$(buildArch)'
183+
artifactName: 'onnxruntime-win-$(buildArch)-gpu-$(OnnxRuntimeVersion)'
184+
commitId: $(OnnxRuntimeGitCommitHash)
171185

172186
- task: PowerShell@2
173187
displayName: 'Clean up Cuda Path 9.1'

tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-posix.yml

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ parameters:
44
buildConfig: 'RelWithDebInfo'
55
artifactName: 'onnxruntime-linux-x64'
66
libraryName: 'libonnxruntime.so'
7+
commitId: ''
78
steps:
89
- task: CmdLine@2
910
displayName: 'Copy build artifacts for zipping'
@@ -20,6 +21,8 @@ steps:
2021
cp $(Build.SourcesDirectory)/docs/C_API.md $(Build.BinariesDirectory)/${{parameters.artifactName}}/C_API.md
2122
cp $(Build.SourcesDirectory)/LICENSE $(Build.BinariesDirectory)/${{parameters.artifactName}}/LICENSE
2223
cp $(Build.SourcesDirectory)/ThirdPartyNotices.txt $(Build.BinariesDirectory)/${{parameters.artifactName}}/ThirdPartyNotices.txt
24+
cp $(Build.SourcesDirectory)/VERSION_NUMBER $(Build.BinariesDirectory)/${{parameters.artifactName}}/VERSION_NUMBER
25+
echo ${{parameters.commitId}} > $(Build.BinariesDirectory)/${{parameters.artifactName}}/GIT_COMMIT_ID
2326
2427
workingDirectory: '$(Build.BinariesDirectory)/${{parameters.buildConfig}}'
2528

tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
parameters:
44
buildConfig: 'RelWithDebInfo'
55
artifactName: 'onnxruntime-win-x64'
6+
comitId: ''
67
steps:
78
- task: CmdLine@2
89
displayName: 'Copy build artifacts for zipping'
@@ -21,6 +22,8 @@ steps:
2122
copy $(Build.SourcesDirectory)\docs\C_API.md $(Build.BinariesDirectory)\${{parameters.artifactName}}\C_API.md
2223
copy $(Build.SourcesDirectory)\LICENSE $(Build.BinariesDirectory)\${{parameters.artifactName}}\LICENSE
2324
copy $(Build.SourcesDirectory)\ThirdPartyNotices.txt $(Build.BinariesDirectory)\${{parameters.artifactName}}\ThirdPartyNotices.txt
25+
copy $(Build.SourcesDirectory)/VERSION_NUMBER $(Build.BinariesDirectory)\${{parameters.artifactName}}\VERSION_NUMBER
26+
@echo ${{parameters.commitId}} > $(Build.BinariesDirectory)\${{parameters.artifactName}}\GIT_COMMIT_ID
2427
2528
workingDirectory: '$(Build.BinariesDirectory)\${{parameters.buildConfig}}'
2629

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Sets version number from VERSION.txt into a variable. As well as the git commit hash.
2+
3+
steps:
4+
- task: CmdLine@2
5+
displayName: 'Set Version Number variables for Windows'
6+
inputs:
7+
script: |
8+
SETLOCAL EnableDelayedExpansion
9+
set /p _OnnxRuntimeVersion=<$(Build.SourcesDirectory)\VERSION_NUMBER
10+
@echo ##vso[task.setvariable variable=OnnxRuntimeVersion;]%_OnnxRuntimeVersion%
11+
12+
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse HEAD`) DO (
13+
@echo ##vso[task.setvariable variable=OnnxRuntimeGitCommitHash;]%%F
14+
)
15+
16+
workingDirectory: '$(Build.SourcesDirectory)'
17+
condition: eq(variables['Agent.OS'], 'Windows_NT')
18+
19+
- task: CmdLine@2
20+
displayName: 'Set version number variables for Unix'
21+
inputs:
22+
script: |
23+
_OnnxRuntimeVersion=$(head -1 $(Build.SourcesDirectory)/VERSION_NUMBER)
24+
echo "##vso[task.setvariable variable=OnnxRuntimeVersion;]$_OnnxRuntimeVersion"
25+
26+
_OnnxRuntimeGitCommitHash=$(git rev-parse HEAD)
27+
echo "##vso[task.setvariable variable=OnnxRuntimeGitCommitHash;]$_OnnxRuntimeGitCommitHash"
28+
29+
workingDirectory: '$(Build.SourcesDirectory)'
30+
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))

0 commit comments

Comments
 (0)