Skip to content

Commit f56acf2

Browse files
skywing918Kyle Zhang
andauthored
Support Changelog and version Update (#36555)
Azure/azure-sdk-tools#12383 1. add script for update change log content and version update. 2. update config for cli <img width="1578" height="807" alt="image" src="https://github.com/user-attachments/assets/b444cd7e-e535-4f5d-b6ca-1781090dc79c" /> <img width="1593" height="823" alt="image" src="https://github.com/user-attachments/assets/eb664447-fdcd-4e31-9a2b-7cdf582f8bdf" /> cc: @MaryGao ### Packages impacted by this PR ### Issues associated with this PR ### Describe the problem that is addressed by this PR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: Kyle Zhang <[email protected]>
1 parent c2481c3 commit f56acf2

File tree

3 files changed

+198
-0
lines changed

3 files changed

+198
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#Requires -Version 7.0
2+
<#
3+
.SYNOPSIS
4+
Updates the CHANGELOG.md for a specific Azure SDK package.
5+
.DESCRIPTION
6+
This script updates the CHANGELOG.md file by invoking the update-changelog-content
7+
command from @azure-tools/js-sdk-release-tools.
8+
9+
The script validates the package path and runs the changelog update tool.
10+
.PARAMETER SdkRepoPath
11+
The absolute path to the root folder of the local SDK repository.
12+
.PARAMETER PackagePath
13+
The absolute path to the root folder of the local SDK project (package).
14+
Must contain a valid package.json file.
15+
.EXAMPLE
16+
.\update-changelog-content.ps1 `
17+
-SdkRepoPath "D:\GithubSource\tmpSource\azure-sdk-for-js" `
18+
-PackagePath "D:\GithubSource\tmpSource\azure-sdk-for-js\sdk\storage\arm-storage"
19+
20+
Updates the CHANGELOG.md for the arm-storage package.
21+
.NOTES
22+
- Requires js-sdk-release-tools to be installed in eng/tools/js-sdk-release-tools.
23+
- The tool will analyze git history and package changes to update the changelog.
24+
#>
25+
[CmdletBinding()]
26+
param (
27+
[Parameter(Mandatory = $true, HelpMessage = "Absolute path to the SDK repository root")]
28+
[string]$SdkRepoPath,
29+
30+
[Parameter(Mandatory = $true, HelpMessage = "Absolute path to the SDK package directory")]
31+
[string]$PackagePath
32+
)
33+
34+
# Import common helpers
35+
. (Join-Path $PSScriptRoot ".." "common" "scripts" "Helpers" "CommandInvocation-Helpers.ps1")
36+
# Main execution
37+
try {
38+
# Validate SDK repository path
39+
if (-not (Test-Path $SdkRepoPath)) {
40+
throw "SDK repository path does not exist: $SdkRepoPath"
41+
}
42+
# Validate package path
43+
if (-not (Test-Path $PackagePath)) {
44+
throw "Package path does not exist: $PackagePath"
45+
}
46+
47+
Push-Location $SdkRepoPath
48+
49+
# Install js-sdk-release-tools if needed
50+
$releaseToolsPath = "eng\tools\js-sdk-release-tools"
51+
if (-not (Test-Path $releaseToolsPath)) {
52+
throw "Release tools path does not exist: $releaseToolsPath"
53+
}
54+
55+
Write-Host "Installing js-sdk-release-tools dependencies..." -ForegroundColor Cyan
56+
Invoke-LoggedCommand "npm --prefix $releaseToolsPath ci"
57+
Write-Host ""
58+
59+
60+
# Run the update-changelog command using npm exec
61+
Write-Host "Updating CHANGELOG.md..." -ForegroundColor Cyan
62+
Write-Host ""
63+
$command = "npm --prefix $releaseToolsPath exec --no -- update-changelog -- --sdkRepoPath `"$SdkRepoPath`" --packagePath `"$PackagePath`""
64+
Invoke-LoggedCommand $command
65+
66+
Write-Host ""
67+
Write-Host "CHANGELOG.md update completed successfully!" -ForegroundColor Green
68+
}
69+
catch {
70+
Write-Host ""
71+
Write-Host "Update changelog failed: $($_.Exception.Message)" -ForegroundColor Red
72+
exit 1
73+
}
74+
finally {
75+
Pop-Location
76+
}

eng/scripts/update-version.ps1

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#Requires -Version 7.0
2+
<#
3+
.SYNOPSIS
4+
Updates the version for a specific Azure SDK package.
5+
.DESCRIPTION
6+
This script updates the package version by invoking the update-version
7+
command from @azure-tools/js-sdk-release-tools.
8+
9+
The script validates the package path and runs the version update tool.
10+
.PARAMETER SdkRepoPath
11+
The absolute path to the root folder of the local SDK repository.
12+
.PARAMETER PackagePath
13+
The absolute path to the root folder of the local SDK project (package).
14+
Must contain a valid package.json file.
15+
.PARAMETER ReleaseType
16+
The type of release: 'beta' or 'stable'.
17+
.PARAMETER Version
18+
The version number to set (e.g., '1.0.0' or '1.0.0-beta.1').
19+
.PARAMETER ReleaseDate
20+
The release date in YYYY-MM-DD format.
21+
.EXAMPLE
22+
.\update-version.ps1 `
23+
-SdkRepoPath "D:\GithubSource\tmpSource\azure-sdk-for-js" `
24+
-PackagePath "D:\GithubSource\tmpSource\azure-sdk-for-js\sdk\storage\arm-storage" `
25+
-ReleaseType "stable" `
26+
-Version "1.0.0" `
27+
-ReleaseDate "2025-11-13"
28+
29+
Updates the version for the arm-storage package.
30+
.NOTES
31+
- Requires js-sdk-release-tools to be installed in eng/tools/js-sdk-release-tools.
32+
- The tool will update package.json and CHANGELOG.md with the new version.
33+
#>
34+
[CmdletBinding()]
35+
param (
36+
[Parameter(Mandatory = $true, HelpMessage = "Absolute path to the SDK repository root")]
37+
[string]$SdkRepoPath,
38+
39+
[Parameter(Mandatory = $true, HelpMessage = "Absolute path to the SDK package directory")]
40+
[string]$PackagePath,
41+
42+
[Parameter(Mandatory = $false, HelpMessage = "Release type: 'beta' or 'stable'")]
43+
[ValidateSet('beta', 'stable')]
44+
[string]$ReleaseType,
45+
46+
[Parameter(Mandatory = $false, HelpMessage = "Version number (e.g., '1.0.0' or '1.0.0-beta.1')")]
47+
[string]$Version,
48+
49+
[Parameter(Mandatory = $false, HelpMessage = "Release date in YYYY-MM-DD format")]
50+
[string]$ReleaseDate
51+
)
52+
53+
# Import common helpers
54+
. (Join-Path $PSScriptRoot ".." "common" "scripts" "Helpers" "CommandInvocation-Helpers.ps1")
55+
56+
# Validate that at least one of ReleaseType or Version is provided
57+
if (-not $ReleaseType -and -not $Version) {
58+
Write-Host "Error: Either -ReleaseType or -Version must be provided" -ForegroundColor Red
59+
exit 1
60+
}
61+
62+
# Main execution
63+
try {
64+
# Validate SDK repository path
65+
if (-not (Test-Path $SdkRepoPath)) {
66+
throw "SDK repository path does not exist: $SdkRepoPath"
67+
}
68+
# Validate package path
69+
if (-not (Test-Path $PackagePath)) {
70+
throw "Package path does not exist: $PackagePath"
71+
}
72+
73+
Push-Location $SdkRepoPath
74+
75+
# Install js-sdk-release-tools if needed
76+
$releaseToolsPath = "eng\tools\js-sdk-release-tools"
77+
if (-not (Test-Path $releaseToolsPath)) {
78+
throw "Release tools path does not exist: $releaseToolsPath"
79+
}
80+
81+
Write-Host "Installing js-sdk-release-tools dependencies..." -ForegroundColor Cyan
82+
Invoke-LoggedCommand "npm --prefix $releaseToolsPath ci"
83+
Write-Host ""
84+
85+
# Build the command arguments string
86+
$cmdArgs = "--sdkRepoPath $SdkRepoPath --packagePath $PackagePath"
87+
88+
if ($ReleaseType) {
89+
$cmdArgs += " --releaseType $ReleaseType"
90+
}
91+
92+
if ($Version) {
93+
$cmdArgs += " --version $Version"
94+
}
95+
96+
if ($ReleaseDate) {
97+
$cmdArgs += " --releaseDate $ReleaseDate"
98+
}
99+
100+
# Run the update-version command using npm exec
101+
Write-Host "Updating package version..." -ForegroundColor Cyan
102+
Write-Host ""
103+
$command = "npm --prefix $releaseToolsPath exec --no -- update-version -- $cmdArgs"
104+
Invoke-LoggedCommand $command
105+
106+
Write-Host ""
107+
Write-Host "Package version update completed successfully!" -ForegroundColor Green
108+
}
109+
catch {
110+
Write-Host ""
111+
Write-Host "Update version failed: $($_.Exception.Message)" -ForegroundColor Red
112+
exit 1
113+
}
114+
finally {
115+
Pop-Location
116+
}

eng/swagger_to_sdk_config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
"breakingChangesLabel": "BreakingChange-JavaScript-Sdk",
3737
"buildScript": {
3838
"path": "./eng/scripts/build-sdk.ps1"
39+
},
40+
"updateChangelogContentScript": {
41+
"path": "./eng/scripts/update-changelog-content.ps1"
42+
},
43+
"updateVersionScript": {
44+
"path": "./eng/scripts/update-version.ps1"
3945
}
4046
}
4147
}

0 commit comments

Comments
 (0)