microsoft/onnxruntime-extensions
Publicmirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable
.pipelines/templates/set-package-version-variable-step.yml
29lines · modecode
| 1 | parameters: |
| 2 | - name: IsReleaseBuild |
| 3 | displayName: | |
| 4 | If true, the version is a release version. Otherwise, the version has a development suffix. |
| 5 | type: boolean |
| 6 | default: false |
| 7 | |
| 8 | - name: PackageVersionVariableName |
| 9 | displayName: | |
| 10 | The name of the variable that will contain the version value. |
| 11 | type: string |
| 12 | |
| 13 | steps: |
| 14 | - bash: | |
| 15 | set -e -x |
| 16 | |
| 17 | VERSION_FILE="$(Build.SourcesDirectory)/version.txt" |
| 18 | BASE_VERSION="$(cat "${VERSION_FILE}")" |
| 19 | |
| 20 | IS_RELEASE_BUILD="$(printf "%s" "${{ parameters.IsReleaseBuild }}" | tr "[:upper:]" "[:lower:]")" |
| 21 | if [[ "${IS_RELEASE_BUILD}" == "true" ]]; then |
| 22 | VERSION="${BASE_VERSION}" |
| 23 | else |
| 24 | SHORT_COMMIT_HASH="$(git rev-parse --short HEAD)" |
| 25 | VERSION="${BASE_VERSION}-dev+$(Build.BuildId).${SHORT_COMMIT_HASH}" |
| 26 | fi |
| 27 | |
| 28 | echo "##vso[task.setvariable variable=${{ parameters.PackageVersionVariableName }}]${VERSION}" |
| 29 | displayName: "Set \"${{ parameters.PackageVersionVariableName }}\" variable to package version" |
| 30 | |