@@ -209,6 +209,48 @@ function Get-Version {
209
209
}
210
210
}
211
211
212
+ <#
213
+ . SYNOPSIS
214
+ Validates the given version string.
215
+ #>
216
+ function Test-VersionIsValid {
217
+ param (
218
+ [Parameter (Mandatory )]
219
+ [ValidateSet ([RepoNames ])]
220
+ [string ]$RepositoryName ,
221
+
222
+ [Parameter (Mandatory )]
223
+ [string ]$Version
224
+ )
225
+ if (! $Version.StartsWith (" v" )) {
226
+ throw " Version should start with 'v' prefix!"
227
+ }
228
+
229
+ $SemanticVersion = [semver ]$Version.Substring (1 )
230
+ switch ($RepositoryName ) {
231
+ " vscode-powershell" {
232
+ $Date = Get-Date
233
+ if ($SemanticVersion.Major -ne $Date.Year ) {
234
+ throw " Major version should be the current year!"
235
+ }
236
+ if ($SemanticVersion.Minor -ne $Date.Month ) {
237
+ throw " Minor version should be the current month!"
238
+ }
239
+ if ($SemanticVersion.PreReleaseLabel ) {
240
+ if ($SemanticVersion.PreReleaseLabel -ne " preview" ) {
241
+ throw " Suffix should only be 'preview'!"
242
+ }
243
+ }
244
+ }
245
+ " PowerShellEditorServices" {
246
+ if ($SemanticVersion.PreReleaseLabel ) {
247
+ throw " Version shouldn't have a pre-release label!"
248
+ }
249
+ }
250
+ }
251
+ return $true
252
+ }
253
+
212
254
<#
213
255
. SYNOPSIS
214
256
Updates the CHANGELOG file with PRs merged since the last release.
@@ -224,9 +266,8 @@ function Update-Changelog {
224
266
[ValidateSet ([RepoNames ])]
225
267
[string ]$RepositoryName ,
226
268
227
- # TODO: Validate version style for each repo.
228
269
[Parameter (Mandatory )]
229
- [ValidateScript ({ $_ .StartsWith ( " v " ) })]
270
+ [ValidateScript ({ Test-VersionIsValid - RepositoryName $RepositoryName - Version $_ })]
230
271
[string ]$Version
231
272
)
232
273
0 commit comments