-
Notifications
You must be signed in to change notification settings - Fork 320
Add SetPackageVersion and GetExistingPackageVersions #2032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
12cb1d2
Add SetPackageVersion and GetExistingPackageVersions to support Prepa…
hallipr f757cef
Add Update-PackageVersion.ps1
hallipr f9a1f66
Sort versions using AzureEngSemanticVersion
hallipr 7698edf
Fix package lookup by service directory
hallipr a8211cb
Remove cargo-set-version from Update-PackageVersion.ps1
hallipr f0c91f2
Clean up output messages in Update-PackageVersion.ps1
hallipr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <# | ||
| .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/main/docs/policies/releases.md#incrementing-after-release-net | ||
|
|
||
| .PARAMETER ServiceDirectory | ||
| The Name of the Service Directory | ||
|
|
||
| .PARAMETER PackageName | ||
| The Name of the Package | ||
|
|
||
| .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-PackageVersion.ps1 -ServiceDirectory core -PackageName azure_core | ||
|
|
||
| Updating package version for Azure.Core with a specified verion | ||
| Update-PackageVersion.ps1 -ServiceDirectory core -PackageName azure_core -NewVersionString 2.0.5 | ||
|
|
||
| Updating package version for Azure.Core with a specified verion and release date | ||
| Update-PackageVersion.ps1 -ServiceDirectory core -PackageName azure_core -NewVersionString 2.0.5 -ReleaseDate "2020-05-01" | ||
| #> | ||
|
|
||
| [CmdletBinding()] | ||
| Param ( | ||
| [Parameter(Mandatory = $True)] | ||
| [string] $ServiceDirectory, | ||
| [Parameter(Mandatory = $True)] | ||
| [string] $PackageName, | ||
| [string] $NewVersionString, | ||
| [string] $ReleaseDate, | ||
| [boolean] $ReplaceLatestEntryTitle = $true | ||
| ) | ||
|
|
||
| . (Join-Path $PSScriptRoot '../common/scripts/common.ps1') | ||
|
|
||
| $pkgProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory | ||
| $packageVersion = $pkgProperties.Version | ||
|
|
||
| $packageSemVer = [AzureEngSemanticVersion]::new($packageVersion) | ||
|
|
||
| if ([System.String]::IsNullOrEmpty($NewVersionString)) { | ||
| $packageSemVer.IncrementAndSetToPrerelease(); | ||
heaths marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| & "$EngCommonScriptsDir/Update-ChangeLog.ps1" -Version $packageSemVer.ToString() ` | ||
| -ChangelogPath $pkgProperties.ChangeLogPath -Unreleased $True | ||
| } | ||
| else { | ||
| $packageSemVer = [AzureEngSemanticVersion]::new($NewVersionString) | ||
|
|
||
| & "$EngCommonScriptsDir/Update-ChangeLog.ps1" -Version $packageSemVer.ToString() ` | ||
| -ChangelogPath $pkgProperties.ChangeLogPath -Unreleased $False ` | ||
| -ReplaceLatestEntryTitle $ReplaceLatestEntryTitle -ReleaseDate $ReleaseDate | ||
| } | ||
|
|
||
|
|
||
| if ($packageSemVer.HasValidPrereleaseLabel() -ne $true) { | ||
| Write-Error "Invalid prerelease label: $packageSemVer" | ||
| exit 1 | ||
| } | ||
|
|
||
| $tomlPath = Join-Path $pkgProperties.DirectoryPath "Cargo.toml" | ||
| $content = Get-Content -Path $tomlPath -Raw | ||
| $updated = $content -replace '([package](.|\n)+?version\s*=\s*)"(.+?)"', "`$1`"$packageSemVer`"" | ||
|
|
||
| if($content -ne $updated) | ||
| { | ||
| $updated | Set-Content -Path $tomlPath -Encoding utf8 -NoNewLine | ||
| Write-Host "Updated version in $tomlPath from $packageVersion to $packageSemVer." | ||
|
|
||
| cargo metadata --format-version 1 | Out-Null | ||
| Write-Host "Updated Cargo.lock using 'cargo metadata'." | ||
| } | ||
| else | ||
| { | ||
| Write-Host "$tomlPath already contains version $packageSemVer" | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.