Skip to content

Commit

Permalink
update release version for prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
gcampbell-msft committed Jul 8, 2024
1 parent 7b621f4 commit 7dbb63f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
41 changes: 40 additions & 1 deletion jobs/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,43 @@ extends:
- checkout: self
clean: true
fetchTags: false
- template: /jobs/shared/build.yml@self
- task: PowerShell@2
displayName: Update ReleaseVersion for pre-release builds
condition: eq(variables.IsPreRelease, '1')
inputs:
targetType: inline
script: |
#
# Query the Marketplace for the latest version of CMake Tools
# https://github.com/microsoft/vscode/blob/main/src/vs/platform/extensionManagement/common/extensionGalleryService.ts
#
$uri = 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery'
$contentType = 'application/json'
$headers = @{
"Accept" = "application/json; api-version=3.0-preview"
}
$data = '{"filters": [{"criteria": [{"filterType": 7, "value": "ms-vscode.cmake-tools"}]}], "flags": 529}'
$response = Invoke-WebRequest -Method 'POST' -Uri $uri -UseBasicParsing -ContentType $contentType -Headers $headers -Body $data
$newVersion = ''
if ($response.StatusCode.Equals(200)) {
$result = $response.Content | ConvertFrom-Json
# Check the $result.results[0].extensions.versions.properties for the 'Microsoft.VisualStudio.Code.PreRelease' key to make sure it's true,
# if not, we need to bump the .Minor version and reset .Build to 0
$index = $result.results[0].extensions.versions.properties.key.IndexOf("Microsoft.VisualStudio.Code.PreRelease")
$isPreRelease = "false"
if ($index -ge 0) {
$isPreRelease = $result.results[0].extensions.versions.properties.value[$index]
}
$v = [System.Version]::Parse($result.results[0].extensions.versions.version)
if ($isPreRelease.Equals('true')) {
$newVersion = [System.Version]::new($v.Major, $v.Minor, $v.Build + 1).ToString()
} else {
$newVersion = [System.Version]::new($v.Major, $v.Minor + 1, 0).ToString()
}
}
Write-Host "New version is: $newVersion"
Write-Host "##vso[task.setvariable variable=ReleaseVersion]$newVersion"
ignoreLASTEXITCODE: true
- template: /jobs/shared/build.yml@self
parameters:
ReleaseVersion: ${{ variables.ReleaseVersion }}
37 changes: 0 additions & 37 deletions jobs/shared/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,6 @@ steps:
displayName: npm install VSCE
inputs:
arguments: -g vsce
- task: PowerShell@2
displayName: Update ReleaseVersion for pre-release builds
condition: eq(variables.IsPreRelease, '1')
inputs:
targetType: inline
script: |
#
# Query the Marketplace for the latest version of CMake Tools
# https://github.com/microsoft/vscode/blob/main/src/vs/platform/extensionManagement/common/extensionGalleryService.ts
#
$uri = 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery'
$contentType = 'application/json'
$headers = @{
"Accept" = "application/json; api-version=3.0-preview"
}
$data = '{"filters": [{"criteria": [{"filterType": 7, "value": "ms-vscode.cmake-tools"}]}], "flags": 529}'
$response = Invoke-WebRequest -Method 'POST' -Uri $uri -UseBasicParsing -ContentType $contentType -Headers $headers -Body $data
$newVersion = ''
if ($response.StatusCode.Equals(200)) {
$result = $response.Content | ConvertFrom-Json
# Check the $result.results[0].extensions.versions.properties for the 'Microsoft.VisualStudio.Code.PreRelease' key to make sure it's true,
# if not, we need to bump the .Minor version and reset .Build to 0
$index = $result.results[0].extensions.versions.properties.key.IndexOf("Microsoft.VisualStudio.Code.PreRelease")
$isPreRelease = "false"
if ($index -ge 0) {
$isPreRelease = $result.results[0].extensions.versions.properties.value[$index]
}
$v = [System.Version]::Parse($result.results[0].extensions.versions.version)
if ($isPreRelease.Equals('true')) {
$newVersion = [System.Version]::new($v.Major, $v.Minor, $v.Build + 1).ToString()
} else {
$newVersion = [System.Version]::new($v.Major, $v.Minor + 1, 0).ToString()
}
}
Write-Host "New version is: $newVersion"
Write-Host "##vso[task.setvariable variable=ReleaseVersion]$newVersion"
ignoreLASTEXITCODE: true
- task: PowerShell@2
displayName: Set build name
inputs:
Expand Down

0 comments on commit 7dbb63f

Please sign in to comment.