From c4c64bcd0715278c58b07d52f2590115741d78e1 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:39:16 -0700 Subject: [PATCH] Support 'preview' in version and always publish (a draft) Removed the manual validation step because it is unnecesary (and annoying) to gate this pipeline since it opens an unpublished, draft release. The downstream triggered pipeline will gate the release to the VS Code marketplace. --- .github/release.yml | 2 +- .../PowerShellEditorServices-Official.yml | 50 +++++++------------ tools/updateVersion.ps1 | 26 +++++----- 3 files changed, 32 insertions(+), 46 deletions(-) diff --git a/.github/release.yml b/.github/release.yml index bb7a942a4..cc5a1aa80 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -3,7 +3,7 @@ changelog: labels: - Ignore authors: - - dependabot[bot] + - dependabot categories: - title: Enhancements & Features ✨ labels: diff --git a/.pipelines/PowerShellEditorServices-Official.yml b/.pipelines/PowerShellEditorServices-Official.yml index f1d47c08c..e22560e72 100644 --- a/.pipelines/PowerShellEditorServices-Official.yml +++ b/.pipelines/PowerShellEditorServices-Official.yml @@ -52,7 +52,10 @@ extends: - pwsh: | [xml]$xml = Get-Content PowerShellEditorServices.Common.props $version = $xml.Project.PropertyGroup.VersionPrefix + $prerelease = $xml.Project.PropertyGroup.VersionSuffix + if ($prerelease) { $version += "-$prerelease" } Write-Output "##vso[task.setvariable variable=version;isOutput=true]$version" + Write-Output "##vso[task.setvariable variable=prerelease;isOutput=true]$(-not [string]::IsNullOrEmpty($prerelease))" name: package displayName: Get version from project properties - task: onebranch.pipeline.version@1 @@ -61,17 +64,17 @@ extends: system: Custom customVersion: $(package.version) - task: UseDotNet@2 - displayName: Install .NET 8.x SDK + displayName: Use .NET 8.x SDK inputs: packageType: sdk version: 8.x - task: UseDotNet@2 - displayName: Install .NET 7.x runtime + displayName: Use .NET 7.x runtime (for tests) inputs: packageType: runtime version: 7.x - task: UseDotNet@2 - displayName: Install .NET 6.x runtime + displayName: Use .NET 6.x runtime (for tests) inputs: packageType: runtime version: 6.x @@ -80,29 +83,22 @@ extends: inputs: pwsh: true filePath: tools/installPSResources.ps1 - - task: PowerShell@2 + - pwsh: Invoke-Build TestFull -Configuration $(BuildConfiguration) displayName: Build and test - inputs: - targetType: inline - pwsh: true - script: Invoke-Build TestFull -Configuration $(BuildConfiguration) - task: PublishTestResults@2 displayName: Publish test results inputs: testRunner: VSTest testResultsFiles: '**/*.trx' failTaskOnFailedTests: true - - task: PowerShell@2 + - pwsh: | + $assembly = [Reflection.Assembly]::LoadFile("$(Build.SourcesDirectory)/module/PowerShellEditorServices/bin/Core/Microsoft.PowerShell.EditorServices.Hosting.dll") + if ($assembly.GetCustomAttributes([System.Diagnostics.DebuggableAttribute], $true).IsJITOptimizerDisabled) { + Write-Host "##vso[task.LogIssue type=error;]Was not built in release configuration!" + exit 1 + } displayName: Assert release configuration - inputs: - targetType: inline - pwsh: true - script: | - $assembly = [Reflection.Assembly]::LoadFile("$(Build.SourcesDirectory)/module/PowerShellEditorServices/bin/Core/Microsoft.PowerShell.EditorServices.Hosting.dll") - if ($assembly.GetCustomAttributes([System.Diagnostics.DebuggableAttribute], $true).IsJITOptimizerDisabled) { - Write-Host "##vso[task.LogIssue type=error;]Was not built in release configuration!" - exit 1 - } + continueOnError: true - task: onebranch.pipeline.signing@1 displayName: Sign 1st-party files inputs: @@ -136,22 +132,10 @@ extends: dependsOn: build variables: version: $[ stageDependencies.build.main.outputs['package.version'] ] + prerelease: $[ stageDependencies.build.main.outputs['package.prerelease'] ] drop: $(Pipeline.Workspace)/drop_build_main jobs: - - job: validation - displayName: Manual validation - pool: - type: agentless - timeoutInMinutes: 1440 - steps: - - task: ManualValidation@0 - displayName: Wait 24 hours for validation - inputs: - notifyUsers: $(Build.RequestedForEmail) - instructions: Please validate the release - timeoutInMinutes: 1440 - job: github - dependsOn: validation displayName: Publish draft to GitHub pool: type: windows @@ -176,7 +160,7 @@ extends: tagSource: userSpecifiedTag tag: v$(version) isDraft: true + isPreRelease: $(prerelease) addChangeLog: false releaseNotesSource: inline - releaseNotesInline: | - # TODO: Generate release notes on GitHub! + releaseNotesInline: "" diff --git a/tools/updateVersion.ps1 b/tools/updateVersion.ps1 index e5b94280c..85e75dfcb 100644 --- a/tools/updateVersion.ps1 +++ b/tools/updateVersion.ps1 @@ -16,30 +16,32 @@ if ($LASTEXITCODE -ne 0) { $v = "$($Version.Major).$($Version.Minor).$($Version.Patch)" -$path = "PowerShellEditorServices.Common.props" -$f = Get-Content -Path $path +$Path = "PowerShellEditorServices.Common.props" +$f = Get-Content -Path $Path $f = $f -replace '^(?\s+)(.+)(?)$', "`${prefix}${v}`${suffix}" $f = $f -replace '^(?\s+)(.*)(?)$', "`${prefix}$($Version.PreReleaseLabel)`${suffix}" -$f | Set-Content -Path $path -git add $path +$f | Set-Content -Path $Path +git add $Path -$path = "module/PowerShellEditorServices/PowerShellEditorServices.psd1" -$f = Get-Content -Path $path +$Path = "module/PowerShellEditorServices/PowerShellEditorServices.psd1" +$f = Get-Content -Path $Path $f = $f -replace "^(?ModuleVersion = ')(.+)(?')`$", "`${prefix}${v}`${suffix}" -$f | Set-Content -Path $path -git add $path +$f | Set-Content -Path $Path +git add $Path -$path = "CHANGELOG.md" -$Changelog = Get-Content -Path $path +$Path = "CHANGELOG.md" +$Changelog = Get-Content -Path $Path @( $Changelog[0..1] "## v$Version" "### $([datetime]::Now.ToString('dddd, MMMM dd, yyyy'))" "" + "See more details at the GitHub Release for [v$Version](https://github.com/PowerShell/PowerShellEditorServices/releases/tag/v$Version)." + "" $Changes "" $Changelog[2..$Changelog.Length] -) | Set-Content -Encoding utf8NoBOM -Path $path -git add $path +) | Set-Content -Encoding utf8NoBOM -Path $Path +git add $Path git commit --edit --message "v$($Version): $Changes"