@@ -162,11 +162,13 @@ function Update-Changelog {
162
162
$Release = $Repo | Get-GitHubRelease - Latest
163
163
$Commits = git rev- list " $ ( $Release.tag_name ) ..."
164
164
165
- # NOTE: This is a slow API as it gets all closed PRs, and then filters.
166
- $Bullets = $Repo | Get-GitHubPullRequest - State Closed |
165
+ # NOTE: This is a slow API as it gets all PRs, and then filters.
166
+ $Bullets = $Repo | Get-GitHubPullRequest - State All |
167
167
Where-Object { $_.merge_commit_sha -in $Commits } |
168
168
Where-Object { -not $_.user.UserName.EndsWith (" [bot]" ) } |
169
169
Where-Object { -not $_.title.StartsWith (" [Ignore]" ) } |
170
+ Where-Object { -not $_.title.StartsWith (" Update CHANGELOG" ) } |
171
+ Where-Object { -not $_.title.StartsWith (" Bump version" ) } |
170
172
Get-Bullets - RepositoryName $RepositoryName
171
173
172
174
$NewSection = switch ($RepositoryName ) {
@@ -206,6 +208,95 @@ function Update-Changelog {
206
208
Pop-Location
207
209
}
208
210
211
+ <#
212
+ . SYNOPSIS
213
+ Updates version in repository.
214
+ . DESCRIPTION
215
+ Note that our Git tags and changelog prefix all versions with `v`.
216
+
217
+ PowerShellEditorServices: version is `x.y.z-preview.d`
218
+
219
+ - PowerShellEditorServices.psd1:
220
+ - `ModuleVersion` variable with `'x.y.z'` string, no pre-release info
221
+ - PowerShellEditorServices.Common.props:
222
+ - `VersionPrefix` field with `x.y.z`
223
+ - `VersionSuffix` field with pre-release portion excluding hyphen
224
+
225
+ vscode-powershell: version is `yyyy.mm.x-preview`
226
+
227
+ - package.json:
228
+ - `version` field with `"x.y.z"` and no prefix or suffix
229
+ - `preview` field set to `true` or `false` if version is a preview
230
+ - `name` field has `-preview` appended similarly
231
+ - `displayName` field has ` Preview` appended similarly
232
+ - `description` field has `(Preview) ` prepended similarly
233
+ #>
234
+ function Update-Version {
235
+ [CmdletBinding (SupportsShouldProcess )]
236
+ param (
237
+ [Parameter (Mandatory )]
238
+ [ValidateSet ([RepoNames ])]
239
+ [string ]$RepositoryName
240
+ )
241
+ # NOTE: This a side effect neccesary for Git operations to work.
242
+ Push-Location - Path " $PSScriptRoot /../../$RepositoryName "
243
+
244
+ $Version = Get-Version - RepositoryName $RepositoryName
245
+ $v = " $ ( $Version.Major ) .$ ( $Version.Minor ) .$ ( $Version.Patch ) "
246
+ # TODO: Maybe cleanup the replacement logic.
247
+ switch ($RepositoryName ) {
248
+ " vscode-powershell" {
249
+ $d = " Develop PowerShell scripts in Visual Studio Code!"
250
+ if ($Version.PreReleaseLabel ) {
251
+ $name = " powershell-preview"
252
+ $displayName = " PowerShell Preview"
253
+ $preview = " true"
254
+ $description = " (Preview) $d "
255
+ } else {
256
+ $name = " powershell"
257
+ $displayName = " PowerShell"
258
+ $preview = " false"
259
+ $description = $d
260
+ }
261
+ $path = " package.json"
262
+ $f = Get-Content - Path $path
263
+ # NOTE: The prefix regex match two spaces exactly to avoid matching
264
+ # nested objects in the file.
265
+ $f = $f -replace ' ^(?<prefix> "name":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${name} `$ {suffix}"
266
+ $f = $f -replace ' ^(?<prefix> "displayName":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${displayName} `$ {suffix}"
267
+ $f = $f -replace ' ^(?<prefix> "version":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${v} `$ {suffix}"
268
+ $f = $f -replace ' ^(?<prefix> "preview":\s+)(.+)(?<suffix>,)$' , " `$ {prefix}${preview} `$ {suffix}"
269
+ $f = $f -replace ' ^(?<prefix> "description":\s+")(.+)(?<suffix>",)$' , " `$ {prefix}${description} `$ {suffix}"
270
+ $f | Set-Content - Path $path
271
+ git add $path
272
+ }
273
+ " PowerShellEditorServices" {
274
+ $path = " PowerShellEditorServices.Common.props"
275
+ $f = Get-Content - Path $path
276
+ $f = $f -replace ' ^(?<prefix>\s+<VersionPrefix>)(.+)(?<suffix></VersionPrefix>)$' , " `$ {prefix}${v} `$ {suffix}"
277
+ $f = $f -replace ' ^(?<prefix>\s+<VersionSuffix>)(.*)(?<suffix></VersionSuffix>)$' , " `$ {prefix}$ ( $Version.PreReleaseLabel ) `$ {suffix}"
278
+ $f | Set-Content - Path $path
279
+ git add $path
280
+
281
+ $path = " module/PowerShellEditorServices/PowerShellEditorServices.psd1"
282
+ $f = Get-Content - Path $path
283
+ $f = $f -replace " ^(?<prefix>ModuleVersion = ')(.+)(?<suffix>')`$ " , " `$ {prefix}${v} `$ {suffix}"
284
+ $f | Set-Content - Path $path
285
+ git add $path
286
+ }
287
+ }
288
+
289
+ if ($PSCmdlet.ShouldProcess (" $RepositoryName /v$Version " , " git commit" )) {
290
+ git commit - m " Bump version to v$Version "
291
+ }
292
+
293
+ if ($PSCmdlet.ShouldProcess (" $RepositoryName /v$Version " , " git tag" )) {
294
+ git tag " v$Version "
295
+ }
296
+
297
+ Pop-Location
298
+ }
299
+
209
300
<#
210
301
. SYNOPSIS
211
302
Creates a new draft GitHub release from the updated changelog.
@@ -237,4 +328,4 @@ function New-DraftRelease {
237
328
New-GitHubRelease @ReleaseParams
238
329
}
239
330
240
- Export-ModuleMember - Function Update-Changelog , New-DraftRelease
331
+ Export-ModuleMember - Function Update-Changelog , Update-Version , New-DraftRelease
0 commit comments