Skip to content

Commit 0aec130

Browse files
committed
Add version update script
1 parent 00dde83 commit 0aec130

File tree

3 files changed

+57
-21
lines changed

3 files changed

+57
-21
lines changed

.pipelines/ConsoleGuiTools-Official.yml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extends:
6363
displayName: Use .NET 6.x SDK
6464
inputs:
6565
packageType: sdk
66-
version: 6.x
66+
useGlobalJson: true
6767
- task: PowerShell@2
6868
displayName: Install PSResources
6969
inputs:
@@ -75,20 +75,29 @@ extends:
7575
displayName: Sign 1st-party files
7676
inputs:
7777
command: sign
78-
signing_environment: external_distribution
78+
signing_profile: external_distribution
7979
search_root: $(Build.SourcesDirectory)/module
8080
files_to_sign: |
81-
**/*.psd1;
82-
**/Microsoft.PowerShell.*.dll;
81+
*.psd1;
82+
Microsoft.PowerShell.*.dll;
8383
- task: onebranch.pipeline.signing@1
8484
displayName: Sign 3rd-party files
8585
inputs:
8686
command: sign
87-
signing_environment: 135020002
87+
signing_profile: 135020002
8888
search_root: $(Build.SourcesDirectory)/module
8989
files_to_sign: |
90-
**/NStack.dll;
91-
**/Terminal.Gui.dll;
90+
NStack.dll;
91+
Terminal.Gui.dll;
92+
- pwsh: Invoke-Build -Configuration $(BuildConfiguration) Package
93+
displayName: Package
94+
- task: onebranch.pipeline.signing@1
95+
displayName: Sign NuGet package
96+
inputs:
97+
command: sign
98+
signing_profile: external_distribution
99+
search_root: $(Build.SourcesDirectory)/out
100+
files_to_sign: "*.nupkg"
92101
- stage: release
93102
dependsOn: build
94103
variables:
@@ -104,19 +113,12 @@ extends:
104113
steps:
105114
- download: current
106115
displayName: Download artifacts
107-
- task: ArchiveFiles@2
108-
displayName: Zip signed artifacts
109-
inputs:
110-
rootFolderOrFile: $(drop)
111-
includeRootFolder: false
112-
archiveType: zip
113-
archiveFile: out/ConsoleGuiTools.zip
114116
- task: GitHubRelease@1
115117
displayName: Create GitHub release
116118
inputs:
117119
gitHubConnection: GitHub
118120
repositoryName: PowerShell/ConsoleGuiTools
119-
assets: out/ConsoleGuiTools.zip
121+
assets: $(drop)/*.nupkg
120122
tagSource: userSpecifiedTag
121123
tag: v$(version)
122124
isDraft: true
@@ -135,10 +137,10 @@ extends:
135137
notifyUsers: $(Build.RequestedForEmail)
136138
instructions: Please validate the release and then publish it!
137139
timeoutInMinutes: 1440
138-
- pwsh: |
139-
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
140-
Install-Module -Name Microsoft.PowerShell.PSResourceGet -AllowPrerelease -Scope CurrentUser -Force
141-
Import-Module -Name Microsoft.PowerShell.PSResourceGet -MinimumVersion 1.0.0
142-
Publish-PSResource -Path $(Pipeline.Workspace)/Publish/Microsoft.PowerShell.ConsoleGuiTools -Repository PSGallery -APIKey $(GalleryToken) -Verbose
140+
- task: NuGetCommand@2
143141
dependsOn: validation
144-
displayName: Publishing ConsoleGuiTools to PowerShell Gallery
142+
displayName: Publish ConsoleGuiTools to PowerShell Gallery
143+
inputs:
144+
command: push
145+
packagesToPush: $(drop)/*.nupkg
146+
publishFeedCredentials: PSGet-PSGalleryPush

ConsoleGuiTools.Common.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3+
<VersionPrefix>0.7.6</VersionPrefix>
4+
<VersionSuffix></VersionSuffix>
35
<Company>Microsoft</Company>
46
<Copyright>© Microsoft Corporation.</Copyright>
57
<LangVersion>latest</LangVersion>

tools/updateVersion.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
param(
5+
[Parameter(Mandatory)]
6+
[semver]$Version,
7+
8+
[Parameter(Mandatory)]
9+
[string]$Changes
10+
)
11+
12+
git diff --staged --quiet --exit-code
13+
if ($LASTEXITCODE -ne 0) {
14+
throw "There are staged changes in the repository. Please commit or reset them before running this script."
15+
}
16+
17+
$v = "$($Version.Major).$($Version.Minor).$($Version.Patch)"
18+
19+
$Path = "ConsoleGuiTools.Common.props"
20+
$f = Get-Content -Path $Path
21+
$f = $f -replace '^(?<prefix>\s+<VersionPrefix>)(.+)(?<suffix></VersionPrefix>)$', "`${prefix}${v}`${suffix}"
22+
$f = $f -replace '^(?<prefix>\s+<VersionSuffix>)(.*)(?<suffix></VersionSuffix>)$', "`${prefix}$($Version.PreReleaseLabel)`${suffix}"
23+
$f | Set-Content -Path $Path
24+
git add $Path
25+
26+
$Path = "src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.psd1"
27+
$f = Get-Content -Path $Path
28+
$f = $f -replace "^(?<prefix>ModuleVersion\s+=\s+')(.+)(?<suffix>')`$", "`${prefix}${v}`${suffix}"
29+
$f | Set-Content -Path $Path
30+
git add $Path
31+
32+
git commit --edit --message "v$($Version): $Changes"

0 commit comments

Comments
 (0)