diff --git a/.pipelines/Release-Official.yml b/.pipelines/Release-Official.yml
index d933f584..753b13fb 100644
--- a/.pipelines/Release-Official.yml
+++ b/.pipelines/Release-Official.yml
@@ -111,6 +111,8 @@ extends:
- stage: PublishGitHubRelease
displayName: Publish GitHub Release
dependsOn: UpdateChangeLog
+ variables:
+ ob_release_environment: Production
jobs:
- template: /.pipelines/templates/release-publish-github.yml@self
parameters:
diff --git a/.pipelines/templates/linux-package.yml b/.pipelines/templates/linux-package.yml
index ff1c94f5..58ab6aab 100644
--- a/.pipelines/templates/linux-package.yml
+++ b/.pipelines/templates/linux-package.yml
@@ -19,7 +19,7 @@ jobs:
value: true
- group: DotNetPrivateBuildAccess
- name: ob_sdl_sbom_enabled
- value: false
+ value: true
- name: ob_sdl_codeql_compiled_enabled
value: false
- name: ob_outputDirectory
diff --git a/.pipelines/templates/mac-package.yml b/.pipelines/templates/mac-package.yml
index 9f2daca6..fdee5161 100644
--- a/.pipelines/templates/mac-package.yml
+++ b/.pipelines/templates/mac-package.yml
@@ -24,7 +24,7 @@ jobs:
value: true
- group: DotNetPrivateBuildAccess
- name: ob_sdl_sbom_enabled
- value: false
+ value: true
- name: ob_sdl_codeql_compiled_enabled
value: false
- name: ob_outputDirectory
diff --git a/.pipelines/templates/module-package.yml b/.pipelines/templates/module-package.yml
index f64bfdcd..22badf81 100644
--- a/.pipelines/templates/module-package.yml
+++ b/.pipelines/templates/module-package.yml
@@ -81,7 +81,7 @@ jobs:
try {
$RepoName = "PSRLLocal"
Register-PSResourceRepository -Name $RepoName -Uri $nugetPath -Trusted
- Publish-PSResource -Repository $RepoName -Path $moduleFolder
+ Publish-PSResource -Repository $RepoName -Path $moduleFolder -SkipModuleManifestValidate
} finally {
Unregister-PSResourceRepository -Name $RepoName -ErrorAction SilentlyContinue
}
diff --git a/.pipelines/templates/release-publish-github.yml b/.pipelines/templates/release-publish-github.yml
index e87cf4c1..f0b61f30 100644
--- a/.pipelines/templates/release-publish-github.yml
+++ b/.pipelines/templates/release-publish-github.yml
@@ -8,101 +8,166 @@ jobs:
displayName: Create GitHub Release Draft
condition: succeeded()
pool:
- type: windows
+ type: release
+ os: windows
+ templateContext:
+ inputs:
+ - input: pipelineArtifact
+ pipeline: AIShellPackagePipeline
+ artifactName: drop_windows_package_arm64
+ - input: pipelineArtifact
+ pipeline: AIShellPackagePipeline
+ artifactName: drop_windows_package_x64
+ - input: pipelineArtifact
+ pipeline: AIShellPackagePipeline
+ artifactName: drop_windows_package_x86
+ - input: pipelineArtifact
+ pipeline: AIShellPackagePipeline
+ artifactName: drop_linux_package_arm64
+ - input: pipelineArtifact
+ pipeline: AIShellPackagePipeline
+ artifactName: drop_linux_package_x64
+ - input: pipelineArtifact
+ pipeline: AIShellPackagePipeline
+ artifactName: macos-pkgs
variables:
- - group: 'mscodehub-code-read-akv'
- - group: 'Azure Blob variable group'
- - group: 'GitHubTokens'
- name: ob_outputDirectory
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
- name: ob_sdl_tsa_configFile
value: $(Build.SourcesDirectory)\AIShell\.config\tsaoptions.json
steps:
- - checkout: self
- clean: true
-
- - pwsh: |
- Get-ChildItem Env:
+ - task: PowerShell@2
+ inputs:
+ targetType: inline
+ script: |
+ Get-ChildItem Env: | Out-String -Width 500
displayName: 'Capture Environment Variables'
- - download: AIShellPackagePipeline
- artifact: drop_windows_package_arm64
- displayName: Download win-arm64 zip
- patterns: '**/*.zip'
-
- - download: AIShellPackagePipeline
- artifact: drop_windows_package_x64
- displayName: Download win-x64 zip
- patterns: '**/*.zip'
-
- - download: AIShellPackagePipeline
- artifact: drop_windows_package_x86
- displayName: Download win-x86 zip
- patterns: '**/*.zip'
-
- - download: AIShellPackagePipeline
- artifact: drop_linux_package_arm64
- displayName: Download linux-arm64 tar.gz
- patterns: '**/*.tar.gz'
-
- - download: AIShellPackagePipeline
- artifact: drop_linux_package_x64
- displayName: Download linux-x64 tar.gz
- patterns: '**/*.tar.gz'
-
- - download: AIShellPackagePipeline
- artifact: macos-pkgs
- displayName: Download macOS tar.gz
- patterns: '**/*.tar.gz'
-
- - pwsh: |
- $packagesRoot = '$(Pipeline.Workspace)/release'
- $null = New-Item -ItemType Directory -Path $packagesRoot
- Get-ChildItem -Path '$(Pipeline.Workspace)\AIShellPackagePipeline' -Include *.zip,*.tar.gz -Recurse |
- Copy-Item -Destination $packagesRoot -Force -Verbose
-
- Write-Verbose -Verbose "List all packages to be published to GitHub release page:"
- Get-ChildItem -Path $packagesRoot | Out-String -Width 500 -Stream
-
- $vstsCommandString = "vso[task.setvariable variable=PackagesRoot]$packagesRoot"
- Write-Host "sending " + $vstsCommandString
- Write-Host "##$vstsCommandString"
+ - task: PowerShell@2
+ inputs:
+ targetType: inline
+ script: |
+ $packagesRoot = '$(Pipeline.Workspace)/release'
+ $null = New-Item -ItemType Directory -Path $packagesRoot
+ Get-ChildItem -Path '$(Pipeline.Workspace)/*' -Include *.zip,*.tar.gz |
+ Copy-Item -Destination $packagesRoot -Force -Verbose
+
+ Write-Verbose -Verbose "List all packages to be published to GitHub release page:"
+ Get-ChildItem -Path $packagesRoot | Out-String -Width 500
+
+ $vstsCommandString = "vso[task.setvariable variable=PackagesRoot]$packagesRoot"
+ Write-Host "sending " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
displayName: Capture downloaded artifacts
- - pwsh: |
- $macX64File = (Get-Item "$(PackagesRoot)\AIShell-*-osx-x64.tar.gz").Name
- $releaseVersion = $macX64File.Replace("AIShell-", "").Replace("-osx-x64.tar.gz", "")
-
- $vstsCommandString = "vso[task.setvariable variable=ReleaseVersion]$releaseVersion"
- Write-Host "sending " + $vstsCommandString
- Write-Host "##$vstsCommandString"
+ - task: PowerShell@2
+ inputs:
+ targetType: inline
+ script: |
+ $hashPath = Join-Path $(PackagesRoot) 'hashes.sha256'
+ $checksums = Get-ChildItem -Path $(PackagesRoot) |
+ ForEach-Object {
+ $packageName = $_.Name
+ $fullPath = $_.FullName
+ Write-Verbose -Verbose "Generating checksum for $fullPath"
+ $hash = (Get-FileHash -Path $fullPath -Algorithm SHA256).Hash.ToLower()
+ # the '*' before the packagename signifies it is a binary
+ "$hash *$packageName"
+ }
+ $checksums | Out-File -FilePath $hashPath -Force
+ Get-Content -Path $hashPath -Raw | Out-String -Width 500
+ displayName: Add sha256 hashes
+
+ - task: PowerShell@2
+ inputs:
+ targetType: inline
+ script: |
+ $macX64File = (Get-Item "$(PackagesRoot)/AIShell-*-osx-x64.tar.gz").Name
+ $releaseVersion = $macX64File.Replace("AIShell-", "").Replace("-osx-x64.tar.gz", "")
+
+ $vstsCommandString = "vso[task.setvariable variable=ReleaseVersion]$releaseVersion"
+ Write-Host "sending " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
displayName: 'Set release version'
- - pwsh: |
- git clone https://$(mscodehubCodeReadPat)@mscodehub.visualstudio.com/PowerShellCore/_git/Internal-PowerShellTeam-Tools '$(Pipeline.Workspace)\tools'
- displayName: Clone Internal-Tools repository
-
- - pwsh: |
- Import-module '$(Pipeline.Workspace)\tools\Scripts\GitHubRelease.psm1'
- $releaseTag = 'v$(ReleaseVersion)'
- $description = ''
- Publish-ReleaseDraft -Tag $releaseTag -Name "$releaseTag Release of AIShell" -Description $description -User PowerShell -Repository AIShell -PackageFolder $(PackagesRoot) -Token $(GitHubReleasePat)
- displayName: Publish Release Draft
+ - task: PowerShell@2
+ inputs:
+ targetType: inline
+ script: |
+ $content = ''
+ $StringBuilder = [System.Text.StringBuilder]::new($content, $content.Length + 2kb)
+ $StringBuilder.AppendLine().AppendLine() > $null
+ $StringBuilder.AppendLine("#### SHA256 Hashes of the release artifacts").AppendLine() > $null
+ Get-ChildItem -Path $(PackagesRoot) -File | ForEach-Object {
+ $PackageName = $_.Name
+ $SHA256 = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
+ $StringBuilder.AppendLine("- $PackageName").AppendLine(" - $SHA256") > $null
+ }
+
+ $content = $StringBuilder.ToString()
+ Write-Verbose -Verbose "Selected content: `n$content"
+ $releaseNotesFilePath = "$(Pipeline.Workspace)/release-notes.md"
+ $content | Out-File -FilePath $releaseNotesFilePath -Encoding utf8
+ Write-Host "##vso[task.setvariable variable=ReleaseNotesFilePath;]$releaseNotesFilePath"
+
+ # If it's prelease then make prerelease true as a variable
+ if ('$(ReleaseVersion)' -like '*-*') {
+ Write-Host "##vso[task.setvariable variable=IsPreRelease;]true"
+ } else {
+ Write-Host "##vso[task.setvariable variable=IsPreRelease;]false"
+ }
+ displayName: Set variables for GitHub release task
+
+ - task: PowerShell@2
+ inputs:
+ targetType: inline
+ script: |
+ Write-Host "ReleaseNotes content:"
+ Get-Content $(ReleaseNotesFilePath) | Out-String -width 500
+ displayName: Verify Release Notes
+
+ - task: GitHubRelease@1
+ displayName: 'Publish Release Draft'
condition: and(ne('${{ parameters.publish }}', 'false'), succeeded())
+ inputs:
+ gitHubConnection: ReleaseToAIShellRepo
+ repositoryName: PowerShell/AIShell
+ target: main
+ assets: '$(PackagesRoot)/*'
+ tagSource: 'userSpecifiedTag'
+ tag: 'v$(ReleaseVersion)'
+ title: 'v$(ReleaseVersion) Release of AIShell'
+ isDraft: true
+ addChangeLog: false
+ action: 'create'
+ releaseNotesFilePath: '$(ReleaseNotesFilePath)'
+ isPrerelease: '$(IsPreRelease)'
+
+- job: PushGitTag
+ dependsOn: GithubReleaseDraft
+ displayName: Push Git Tag
+ pool:
+ type: server
+ timeoutInMinutes: 1440
-- template: /.pipelines/templates/wait-for-approval.yml@self
- parameters:
+ steps:
+ - task: ManualValidation@0
displayName: Push Git Tag
- jobName: PushGitTag
- dependsOnJob: GithubReleaseDraft
- instructions: |
- Push the git tag to upstream
+ inputs:
+ instructions: Push the git tag to upstream
+ timeoutInMinutes: 1440
+
+- job: DraftPublic
+ dependsOn: PushGitTag
+ displayName: Make Draft Public
+ pool:
+ type: server
+ timeoutInMinutes: 1440
-- template: /.pipelines/templates/wait-for-approval.yml@self
- parameters:
+ steps:
+ - task: ManualValidation@0
displayName: Make Draft Public
- jobName: DraftPublic
- dependsOnJob: PushGitTag
- instructions: |
- Make the GitHub Release Draft Public
+ inputs:
+ instructions: Make the GitHub Release Draft Public
+ timeoutInMinutes: 1440
diff --git a/.pipelines/templates/windows-package.yml b/.pipelines/templates/windows-package.yml
index 24a7b684..8bc82090 100644
--- a/.pipelines/templates/windows-package.yml
+++ b/.pipelines/templates/windows-package.yml
@@ -20,7 +20,7 @@ jobs:
- group: DotNetPrivateBuildAccess
- group: certificate_logical_to_actual
- name: ob_sdl_sbom_enabled
- value: false
+ value: true
- name: ob_sdl_codeql_compiled_enabled
value: false
- name: ob_outputDirectory
diff --git a/shell/AIShell.Integration/AIShell.psm1 b/shell/AIShell.Integration/AIShell.psm1
index c9dd2ed2..c3b70a78 100644
--- a/shell/AIShell.Integration/AIShell.psm1
+++ b/shell/AIShell.Integration/AIShell.psm1
@@ -7,5 +7,10 @@ if ($null -eq $module -or $module.Version -lt [version]"2.4.2") {
throw "The PSReadLine v2.4.2-beta2 or higher is required for the AIShell module to work properly."
}
+$runspace = $Host.Runspace
+if ($null -eq $runspace) {
+ throw "Failed to import the module because '`$Host.Runspace' unexpectedly returns null.`nThe host details:`n$($Host | Out-String -Width 120)"
+}
+
## Create the channel singleton when loading the module.
-$null = [AIShell.Integration.Channel]::CreateSingleton($host.Runspace, [Microsoft.PowerShell.PSConsoleReadLine])
+$null = [AIShell.Integration.Channel]::CreateSingleton($runspace, [Microsoft.PowerShell.PSConsoleReadLine])
diff --git a/shell/AIShell.Integration/Channel.cs b/shell/AIShell.Integration/Channel.cs
index 6dfe2b68..2f05261f 100644
--- a/shell/AIShell.Integration/Channel.cs
+++ b/shell/AIShell.Integration/Channel.cs
@@ -31,6 +31,9 @@ public class Channel : IDisposable
private Channel(Runspace runspace, Type psConsoleReadLineType)
{
+ ArgumentNullException.ThrowIfNull(runspace);
+ ArgumentNullException.ThrowIfNull(psConsoleReadLineType);
+
_runspace = runspace;
_psrlType = psConsoleReadLineType;
_connSetupWaitHandler = new ManualResetEvent(false);
diff --git a/shell/shell.common.props b/shell/shell.common.props
index cabab2c5..e80881ff 100644
--- a/shell/shell.common.props
+++ b/shell/shell.common.props
@@ -8,7 +8,7 @@
net8.0
enable
12.0
- 1.0.0-preview.3
+ 1.0.0-preview.4
true
true