Use version.hpp for package versions (#572)
* Add version.txt * Add doc generation for template * Add version.hpp parsing and update capabilities to cmake and engsys * Get-SdkVersion -> Get-PkgVersion * Move Update-PkgVersion.ps1 under eng/scripts * Get-PackageVersion -> Get-PkgVersion * Update paths, params, verbosity * Couple fixes to output and make use of new SemVer version * Add fallback support for verison.txt in cases where we still use it to unblock release artifact generation * Use version information in release pipeline * Add workaround to generate storage pipeline artifacts * eng/scripts/ * Write warning * Haven't released storage-file-shares yet according to releases on GitHub * Set release date on changelog.md * Update CHANGELOG.md to indicate this is a test release * Remove fallback exception for storage * Re-add Rick's suggestions * Revert "Remove fallback exception for storage"
This commit is contained in:
Родитель
67b21fed12
Коммит
919610f429
|
@ -52,6 +52,9 @@ include(global_compile_options)
|
|||
# Documentation automation function
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/doxygen_common.cmake)
|
||||
|
||||
# Functions for library versions
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/az_version.cmake)
|
||||
|
||||
# sub-projects
|
||||
add_subdirectory(sdk/core/performance-stress)
|
||||
add_subdirectory(sdk/core/azure-core)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
# Sets ${AZ_LIBRARY_VERSION} in the parent context with the version value
|
||||
# constructed from version.hpp. The version.hpp must follow the example in
|
||||
# templates for version information to parse correctly.
|
||||
|
||||
function(get_az_version VERSION_HPP_FILE)
|
||||
if(NOT EXISTS ${VERSION_HPP_FILE})
|
||||
message(FATAL_ERROR "Missing Version file ${VERSION_HPP_FILE}")
|
||||
endif()
|
||||
|
||||
file (STRINGS ${VERSION_HPP_FILE} VERSION_H_CONTENT NEWLINE_CONSUME)
|
||||
message(STATUS "Retrieving version from ${VERSION_HPP_FILE}")
|
||||
|
||||
# Find relevant version parts
|
||||
string(
|
||||
REGEX
|
||||
MATCH
|
||||
"#define AZURE_[A-Z]+_VERSION_MAJOR ([0-9]+)[ \t\r\n]+#define AZURE_[A-Z]+_VERSION_MINOR ([0-9]+)[ \t\r\n]+#define AZURE_[A-Z]+_VERSION_PATCH ([0-9]+)[ \t\r\n]+#define AZURE_[A-Z]+_VERSION_PRERELEASE \"([a-zA-Z0-9.]*)\""
|
||||
VERSION_PARTS
|
||||
${VERSION_H_CONTENT})
|
||||
|
||||
#Ensure we matched as expected.
|
||||
# MAJOR.MINOR.PATCH are required.
|
||||
# PRERELEASE is optional.
|
||||
if(NOT CMAKE_MATCH_1 AND NOT CMAKE_MATCH_2 AND NOT CMAKE_MATCH_3)
|
||||
message(FATAL_ERROR "Unexpected version format in ${VERSION_HPP_FILE}")
|
||||
endif()
|
||||
|
||||
set(VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
# If there is a prerelease version
|
||||
if(CMAKE_MATCH_4)
|
||||
set(VERSION_PRERELEASE ${CMAKE_MATCH_4})
|
||||
set(
|
||||
AZ_LIBRARY_VERSION
|
||||
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_PRERELEASE}"
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
set(
|
||||
AZ_LIBRARY_VERSION
|
||||
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
|
||||
PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
message(STATUS "VERSION_MAJOR " ${VERSION_MAJOR})
|
||||
message(STATUS "VERSION_MINOR " ${VERSION_MINOR})
|
||||
message(STATUS "VERSION_PATCH " ${VERSION_PATCH})
|
||||
message(STATUS "VERSION_PRERELEASE " ${VERSION_PRERELEASE})
|
||||
message(STATUS "AZ_LIBRARY_VERSION " ${AZ_LIBRARY_VERSION})
|
||||
endfunction()
|
|
@ -1,81 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Bumps up package versions after release
|
||||
|
||||
.DESCRIPTION
|
||||
This script bumps up package versions following conventions defined at https://github.com/Azure/azure-sdk/blob/master/docs/policies/releases.md#incrementing-after-release-cpp
|
||||
|
||||
.PARAMETER RepoRoot
|
||||
The Root of the repo
|
||||
|
||||
.PARAMETER ServiceDirectory
|
||||
The Name of the Service Directory
|
||||
|
||||
.PARAMETER PackageName
|
||||
The Name of the Package
|
||||
|
||||
.PARAMETER PackageDirName
|
||||
Used in the case where the package directory name is different from the package name. e.g in cognitiveservice packages
|
||||
|
||||
.PARAMETER NewVersionString
|
||||
Use this to overide version incement logic and set a version specified by this parameter
|
||||
|
||||
|
||||
.EXAMPLE
|
||||
Updating package version for azure-core
|
||||
Update-PkgVersion.ps1 -ServiceDirectory core -PackageName azure-core
|
||||
|
||||
Updating package version for azure-core with a specified verion
|
||||
Update-PkgVersion.ps1 -ServiceDirectory core -PackageName azure-core -NewVersionString 2.0.5
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $RepoRoot = "${PSScriptRoot}/..",
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string] $ServiceDirectory,
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string] $PackageName,
|
||||
[string] $PackageDirName,
|
||||
[string] $NewVersionString
|
||||
)
|
||||
|
||||
. ${PSScriptRoot}\common\scripts\SemVer.ps1
|
||||
|
||||
# Updated Version in version file and changelog using computed or set NewVersionString
|
||||
function Update-Version([AzureEngSemanticVersion]$SemVer, $Unreleased=$True, $ReplaceVersion=$False)
|
||||
{
|
||||
Write-Verbose "New Version: $SemVer"
|
||||
if ($SemVer.HasValidPrereleaseLabel() -ne $true){
|
||||
Write-Error "Invalid prerelease label"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Set-Content -Path $PackageVersionPath -Value $SemVer.ToString()
|
||||
|
||||
# Increment Version in ChangeLog file
|
||||
& "${PSScriptRoot}/common/Update-Change-Log.ps1" -Version $SemVer.ToString() -ChangeLogPath $ChangelogPath -Unreleased $Unreleased -ReplaceVersion $ReplaceVersion
|
||||
}
|
||||
|
||||
# Obtain Current Package Version
|
||||
if ([System.String]::IsNullOrEmpty($PackageDirName)) {$PackageDirName = $PackageName}
|
||||
$PackageVersionPath = Join-Path $RepoRoot "sdk" $ServiceDirectory $PackageDirName "version.txt"
|
||||
$ChangelogPath = Join-Path $RepoRoot "sdk" $ServiceDirectory $PackageDirName "CHANGELOG.md"
|
||||
$PackageVersion = Get-Content -Path $PackageVersionPath
|
||||
|
||||
if ([System.String]::IsNullOrEmpty($NewVersionString))
|
||||
{
|
||||
$SemVer = [AzureEngSemanticVersion]::new($PackageVersion)
|
||||
Write-Verbose "Current Version: ${PackageVersion}"
|
||||
|
||||
$SemVer.IncrementAndSetToPrerelease()
|
||||
Update-Version -SemVer $SemVer
|
||||
}
|
||||
else
|
||||
{
|
||||
# Use specified VersionString
|
||||
$SemVer = [AzureEngSemanticVersion]::new($NewVersionString)
|
||||
Update-Version -SemVer $SemVer -Unreleased $False -ReplaceVersion $True
|
||||
}
|
|
@ -132,8 +132,7 @@ jobs:
|
|||
- pwsh: |
|
||||
$outputPath = Join-Path -Path $(Build.ArtifactStagingDirectory) packages/${{ artifact.Name }}/package-info.json
|
||||
|
||||
# TODO: Read version from a .h file instead of version.txt
|
||||
$version = Get-Content -Path sdk/${{ parameters.ServiceDirectory }}/${{ artifact.Path }}/version.txt
|
||||
$version = eng/scripts/Get-PkgVersion -ServiceDirectory ${{ parameters.ServiceDirectory }} -PackageName ${{ artifact.Path }}
|
||||
$outputObject = @{ version = $version.ToString(); name = '${{ artifact.Name }}' } | ConvertTo-Json
|
||||
|
||||
Set-Content -Path $outputPath -Value $outputObject
|
||||
|
|
|
@ -84,7 +84,7 @@ stages:
|
|||
steps:
|
||||
- checkout: self
|
||||
- pwsh: |
|
||||
eng/Update-PkgVersion.ps1 -ServiceDirectory '${{parameters.ServiceDirectory}}' -PackageName '${{artifact.name}}'
|
||||
eng/scripts/Update-PkgVersion.ps1 -ServiceDirectory '${{parameters.ServiceDirectory}}' -PackageName '${{artifact.name}}'
|
||||
displayName: Increment package version
|
||||
- template: ../../../common/pipelines/templates/steps/create-pull-request.yml
|
||||
parameters:
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
[CmdletBinding()]
|
||||
param (
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $ServiceDirectory,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $PackageName
|
||||
)
|
||||
|
||||
. ${PSScriptRoot}/SdkVersion-Common.ps1
|
||||
|
||||
$versionFileLocation = Get-VersionHppLocaiton `
|
||||
-ServiceDirectory $ServiceDirectory `
|
||||
-PackageName $PackageName
|
||||
|
||||
if (!$versionFileLocation) {
|
||||
$fallback = Get-Content $RepoRoot/sdk/$ServiceDirectory/$PackageName/version.txt
|
||||
if ($fallback) {
|
||||
return $fallback
|
||||
} else {
|
||||
Write-Error "Cannot locate package version"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
$versionFileContents = Get-Content $versionFileLocation -Raw
|
||||
|
||||
if (!($versionFileContents -match $VersionRegex)) {
|
||||
Write-Error "does not match version information schema"
|
||||
}
|
||||
|
||||
$VersionString = if ($Matches.prerelease) {
|
||||
"$($Matches.major).$($Matches.minor).$($Matches.patch)-$($Matches.prerelease)"
|
||||
} else {
|
||||
"$($Matches.major).$($Matches.minor).$($Matches.patch)"
|
||||
}
|
||||
|
||||
return $VersionString
|
|
@ -0,0 +1,15 @@
|
|||
# NOTE: Update-PkgVersion and Get-PkgVersion relies on these variables and
|
||||
# functions
|
||||
$RepoRoot = "${PSScriptRoot}/../.."
|
||||
$VersionRegex = '(#define AZURE_\w+_VERSION_MAJOR )(?<major>[0-9]+)(\s+#define AZURE_\w+_VERSION_MINOR )(?<minor>[0-9]+)(\s+#define AZURE_\w+_VERSION_PATCH )(?<patch>[0-9]+)(\s+#define AZURE_\w+_VERSION_PRERELEASE )"(?<prerelease>[a-zA-Z0-9.]*)"';
|
||||
|
||||
function Get-VersionHppLocaiton ($ServiceDirectory, $PackageName) {
|
||||
$versionHppLocation = Get-ChildItem version.hpp -Path "$RepoRoot/sdk/$ServiceDirectory/$PackageName" -Recurse
|
||||
Write-Verbose "version.hpp location: $versionHppLocation"
|
||||
|
||||
if (!$versionHppLocation) {
|
||||
Write-Warning "Could not locate version.hpp file in sdk/$ServiceDirectory/$PackageName"
|
||||
}
|
||||
|
||||
return $versionHppLocation
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Bumps up package versions after release
|
||||
|
||||
.PARAMETER RepoRoot
|
||||
The root of the repo (defaults to ${PSScriptRoot}/..)
|
||||
|
||||
.PARAMETER ServiceDirectory
|
||||
The service directory under <repo-root>/sdk/ used to find version.hpp
|
||||
|
||||
.PARAMETER PackageName
|
||||
The package name under <repo-root>/sdk/<service-directory> used to find
|
||||
version.hpp
|
||||
|
||||
.PARAMETER NewVersionString
|
||||
New version string to use. Must follow SemVer conventions.
|
||||
|
||||
.DESCRIPTION
|
||||
This script bumps up package versions following conventions defined at https://github.com/Azure/azure-sdk/blob/master/docs/policies/releases.md#incrementing-after-release-cpp
|
||||
|
||||
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $RepoRoot = "${PSScriptRoot}/..",
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string] $ServiceDirectory,
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string] $PackageName,
|
||||
[string] $NewVersionString
|
||||
)
|
||||
|
||||
. ${RepoRoot}\common\scripts\SemVer.ps1
|
||||
. ${PSScriptRoot}\SdkVersion-Common.ps1
|
||||
|
||||
# Updated Version in version file and changelog using computed or set NewVersionString
|
||||
function Update-Version(
|
||||
[AzureEngSemanticVersion]$SemVer,
|
||||
$VersionHppLocation,
|
||||
$Unreleased=$True,
|
||||
$ReplaceVersion=$False)
|
||||
{
|
||||
Write-Verbose "New Version: $SemVer"
|
||||
if ($SemVer.HasValidPrereleaseLabel() -ne $true){
|
||||
Write-Error "Invalid prerelease label: $SemVer"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Verbose "Saving version.hpp file..."
|
||||
$versionHppContent = Get-Content $VersionHppLocation -Raw
|
||||
|
||||
if ($SemVer.IsPrerelease) {
|
||||
$newContent = $versionHppContent -replace $VersionRegex, "`${1}$($SemVer.Major)`${2}$($SemVer.Minor)`${3}$($SemVer.Patch)`${4}`"$($SemVer.PrereleaseLabel).$($SemVer.PrereleaseNumber)`""
|
||||
} else {
|
||||
$newContent = $versionHppContent -replace $VersionRegex, "`${1}$($SemVer.Major)`${2}$($SemVer.Minor)`${3}$($SemVer.Patch)`${4}`"`""
|
||||
}
|
||||
|
||||
$newContent | Set-Content $VersionHppLocation
|
||||
|
||||
# Set Version in ChangeLog file
|
||||
$ChangelogPath = Join-Path $RepoRoot "sdk" $ServiceDirectory $PackageName "CHANGELOG.md"
|
||||
& "${RepoRoot}/eng/common/Update-Change-Log.ps1" `
|
||||
-Version $SemVer.ToString() `
|
||||
-ChangeLogPath $ChangelogPath `
|
||||
-Unreleased $Unreleased `
|
||||
-ReplaceVersion $ReplaceVersion
|
||||
}
|
||||
|
||||
$versionHppLocation = Get-VersionHppLocaiton `
|
||||
-ServiceDirectory $ServiceDirectory `
|
||||
-PackageName $PackageName
|
||||
|
||||
Write-Verbose "VERSION FILE: $versionHppLocation"
|
||||
|
||||
# Obtain Current Package Version
|
||||
if ([System.String]::IsNullOrEmpty($NewVersionString))
|
||||
{
|
||||
$PackageVersion = & $PSScriptRoot/Get-PkgVersion.ps1 `
|
||||
-ServiceDirectory $ServiceDirectory `
|
||||
-PackageName $PackageName
|
||||
|
||||
$SemVer = [AzureEngSemanticVersion]::new($PackageVersion)
|
||||
Write-Verbose "Current Version: ${PackageVersion}"
|
||||
$SemVer.IncrementAndSetToPrerelease()
|
||||
Update-Version -SemVer $SemVer -VersionHppLocation $versionHppLocation
|
||||
}
|
||||
else
|
||||
{
|
||||
# Use specified VersionString
|
||||
$SemVer = [AzureEngSemanticVersion]::new($NewVersionString)
|
||||
Update-Version `
|
||||
-SemVer $SemVer `
|
||||
-VersionHppLocation $versionHppLocation `
|
||||
-Unreleased $False `
|
||||
-ReplaceVersion $True
|
||||
}
|
||||
|
|
@ -42,4 +42,5 @@ add_library (Azure::Core ALIAS ${TARGET_NAME})
|
|||
target_include_directories(${TARGET_NAME} PUBLIC ${CURL_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_NAME} PRIVATE CURL::libcurl)
|
||||
|
||||
generate_documentation(${TARGET_NAME} 1.0.0-preview.1)
|
||||
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/core/version.hpp")
|
||||
generate_documentation(azure-core ${AZ_LIBRARY_VERSION})
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
1.0.0-preview.1
|
|
@ -30,6 +30,12 @@ set (AZURE_STORAGE_BLOB_SOURCE
|
|||
add_library(azure-storage-blobs ${AZURE_STORAGE_BLOB_HEADER} ${AZURE_STORAGE_BLOB_SOURCE})
|
||||
target_include_directories(azure-storage-blobs PUBLIC inc)
|
||||
target_link_libraries(azure-storage-blobs azure::storage::common)
|
||||
|
||||
# TODO: Do not read from version.txt, use version.hpp and replace this file
|
||||
# command with:
|
||||
# get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/<package-name>/version.hpp")
|
||||
# Access the variable from this function using ${AZ_LIBRARY_VERSION}
|
||||
# Look at the CMakeLists.txt for template package for example usage
|
||||
file(READ version.txt AZURE_STORAGE_BLOBS_PACKAGE_VERSION)
|
||||
target_compile_definitions(azure-storage-common PUBLIC AZURE_STORAGE_BLOBS_PACKAGE_VERSION="${AZURE_STORAGE_BLOBS_PACKAGE_VERSION}")
|
||||
message("Azure Storage Blobs Package Version ${AZURE_STORAGE_BLOBS_PACKAGE_VERSION}")
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.0.0-beta.1
|
||||
1.0.0-beta.2
|
|
@ -54,6 +54,12 @@ else()
|
|||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(azure-storage-common OpenSSL::SSL OpenSSL::Crypto)
|
||||
endif()
|
||||
|
||||
# TODO: Do not read from version.txt, use version.hpp and replace this file
|
||||
# command with:
|
||||
# get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/<package-name>/version.hpp")
|
||||
# Access the variable from this function using ${AZ_LIBRARY_VERSION}
|
||||
# Look at the CMakeLists.txt for template package for example usage
|
||||
file(READ version.txt AZURE_STORAGE_COMMON_PACKAGE_VERSION)
|
||||
target_compile_definitions(azure-storage-common PUBLIC AZURE_STORAGE_COMMON_PACKAGE_VERSION="${AZURE_STORAGE_COMMON_PACKAGE_VERSION}")
|
||||
message("Azure Storage Common Package Version ${AZURE_STORAGE_COMMON_PACKAGE_VERSION}")
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.0.0-beta.1
|
||||
1.0.0-beta.2
|
|
@ -29,6 +29,12 @@ set (AZURE_STORAGE_DATALAKE_SOURCE
|
|||
add_library(azure-storage-files-datalake ${AZURE_STORAGE_DATALAKE_HEADER} ${AZURE_STORAGE_DATALAKE_SOURCE})
|
||||
target_include_directories(azure-storage-files-datalake PUBLIC inc)
|
||||
target_link_libraries(azure-storage-files-datalake azure-storage-blobs)
|
||||
|
||||
# TODO: Do not read from version.txt, use version.hpp and replace this file
|
||||
# command with:
|
||||
# get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/<package-name>/version.hpp")
|
||||
# Access the variable from this function using ${AZ_LIBRARY_VERSION}
|
||||
# Look at the CMakeLists.txt for template package for example usage
|
||||
file(READ version.txt AZURE_STORAGE_FILES_DATALAKE_PACKAGE_VERSION)
|
||||
target_compile_definitions(azure-storage-common PUBLIC AZURE_STORAGE_FILES_DATALAKE_PACKAGE_VERSION="${AZURE_STORAGE_FILES_DATALAKE_PACKAGE_VERSION}")
|
||||
message("Azure Storage Files DataLake Package Version ${AZURE_STORAGE_FILES_DATALAKE_PACKAGE_VERSION}")
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.0.0-beta.1
|
||||
1.0.0-beta.2
|
|
@ -26,6 +26,12 @@ set (AZURE_STORAGE_SHARES_SOURCE
|
|||
add_library(azure-storage-files-shares ${AZURE_STORAGE_SHARES_HEADER} ${AZURE_STORAGE_SHARES_SOURCE})
|
||||
target_include_directories(azure-storage-files-shares PUBLIC inc)
|
||||
target_link_libraries(azure-storage-files-shares azure-storage-common)
|
||||
|
||||
# TODO: Do not read from version.txt, use version.hpp and replace this file
|
||||
# command with:
|
||||
# get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/<package-name>/version.hpp")
|
||||
# Access the variable from this function using ${AZ_LIBRARY_VERSION}
|
||||
# Look at the CMakeLists.txt for template package for example usage
|
||||
file(READ version.txt AZURE_STORAGE_FILES_SHARES_PACKAGE_VERSION)
|
||||
target_compile_definitions(azure-storage-common PUBLIC AZURE_STORAGE_FILES_SHARES_PACKAGE_VERSION="${AZURE_STORAGE_FILES_SHARES_PACKAGE_VERSION}")
|
||||
message("Azure Storage Files Shares Package Version ${AZURE_STORAGE_FILES_SHARES_PACKAGE_VERSION}")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Release History
|
||||
|
||||
## 1.0.0-beta.1 (Unreleased)
|
||||
## 1.0.0-beta.1 (2020-09-01)
|
||||
|
||||
* Template package
|
||||
* Template package validating release pipeline
|
||||
|
|
|
@ -23,3 +23,6 @@ if(BUILD_TESTING)
|
|||
# tests
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/template/version.hpp")
|
||||
generate_documentation(azure-template ${AZ_LIBRARY_VERSION})
|
||||
|
|
Загрузка…
Ссылка в новой задаче