From 49362a447038430100bd4c99227fec9fb207a76b Mon Sep 17 00:00:00 2001 From: 1ES Gardener Date: Thu, 19 Sep 2024 18:03:55 +0000 Subject: [PATCH 1/4] Enable NuGet Central Package Management --- Directory.Build.props | 5 +++++ Directory.Packages.props | 6 ++++++ src/code/Microsoft.PowerShell.TextUtility.csproj | 6 +++--- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 Directory.Build.props create mode 100644 Directory.Packages.props diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..1932808 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,5 @@ + + + true + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..4603639 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/code/Microsoft.PowerShell.TextUtility.csproj b/src/code/Microsoft.PowerShell.TextUtility.csproj index ad59249..8dc2a25 100644 --- a/src/code/Microsoft.PowerShell.TextUtility.csproj +++ b/src/code/Microsoft.PowerShell.TextUtility.csproj @@ -14,10 +14,10 @@ - + all - + all @@ -28,4 +28,4 @@ - + \ No newline at end of file From c508ffb1395e136a0123be7d06fc8c35d94814d9 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:51:55 -0800 Subject: [PATCH 2/4] Bump packages --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4603639..cd4c377 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,6 +1,6 @@ - - + + From 12b7f8f9e36f1b1df9d5f35b7908853f1b75ac24 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Wed, 5 Mar 2025 14:54:30 -0800 Subject: [PATCH 3/4] Remove old build --- yaml/ci.yml | 68 -------------- yaml/releaseBuild.yml | 188 -------------------------------------- yaml/template/runtest.yml | 19 ---- 3 files changed, 275 deletions(-) delete mode 100644 yaml/ci.yml delete mode 100644 yaml/releaseBuild.yml delete mode 100644 yaml/template/runtest.yml diff --git a/yaml/ci.yml b/yaml/ci.yml deleted file mode 100644 index fc3c66e..0000000 --- a/yaml/ci.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: $(Date:yyyyMMdd)$(Rev:.rr) -trigger: - # Batch merge builds together while a merge build is running - batch: true - branches: - include: - - main - - release* -pr: - branches: - include: - - main - - release* - -resources: - repositories: - - repository: ComplianceRepo - type: github - endpoint: ComplianceGHRepo - name: PowerShell/compliance - -stages: -- stage: Build - displayName: Build Microsoft.PowerShell.TextUtility - jobs: - - job: Build - displayName: Build - pool: - vmImage: windows-latest - steps: - - pwsh: | - ./build.ps1 -Clean - displayName: Build - - publish: "out/" - artifact: out - -- stage: Test - displayName: Test Microsoft.PowerShell.TextUtility - jobs: - - template: template/runtest.yml - parameters: - vmImageName: windows-latest - jobName: run_test_windows - jobDisplayName: Run tests Windows - - - template: template/runtest.yml - parameters: - vmImageName: ubuntu-latest - jobName: run_test_ubuntu - jobDisplayName: Run tests Ubuntu - - - template: template/runtest.yml - parameters: - vmImageName: macos-latest - jobName: run_test_macos - jobDisplayName: Run tests macOS - -- stage: Compliance - displayName: Compliance Microsoft.PowerShell.TextUtility - dependsOn: Build - jobs: - - job: Compliance_Job - pool: - vmImage: windows-latest - steps: - - checkout: self - - checkout: ComplianceRepo - - template: ci-compliance.yml@ComplianceRepo diff --git a/yaml/releaseBuild.yml b/yaml/releaseBuild.yml deleted file mode 100644 index 6d648b6..0000000 --- a/yaml/releaseBuild.yml +++ /dev/null @@ -1,188 +0,0 @@ -# release build -name: TextUtility-Release-$(Date:yyyyMMdd)$(Rev:.rr) -trigger: none - -pr: none - -variables: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - -resources: - repositories: - - repository: ComplianceRepo - type: github - endpoint: ComplianceGHRepo - name: PowerShell/compliance - ref: master - -stages: -- stage: BuildAndSign - displayName: Build and Sign - pool: - name: PowerShell1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - jobs: - - job: 'BuildAndSign' - displayName: Build and Sign - variables: - - group: ESRP - steps: - - checkout: self - - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - packageType: sdk - includePreviewVersions: true - version: 6.x - - - pwsh: | - Get-ChildItem -Path env: - displayName: Capture environment - condition: succeededOrFailed() - - - pwsh: | - Set-Location "$(Build.SourcesDirectory)/TextUtility" - Get-ChildItem -Recurse -File -Name | Write-Verbose -Verbose - ./build.ps1 - Get-ChildItem -Recurse -File -Name | Write-Verbose -Verbose - - displayName: Execute Build - - - pwsh: | - Set-Location "$(Build.SourcesDirectory)/TextUtility" - $signSrcPath = "$(Build.SourcesDirectory)/TextUtility/out" - # Set signing src path variable - $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" - - $signOutPath = "$(Build.SourcesDirectory)/TextUtility/signed" - $null = New-Item -ItemType Directory -Path $signOutPath - # Set signing out path variable - $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - - # Set path variable for guardian codesign validation - $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - - $packageVersion = ./build.ps1 -GetPackageVersion - $vstsCommandString = "vso[task.setvariable variable=PackageVersion]$packageVersion" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" - - displayName: Setup variables for signing - - - publish: "$(Build.SourcesDirectory)/TextUtility/out/" - artifact: out - - displayName: Publish unsigned module files - - - checkout: ComplianceRepo - - - template: EsrpSign.yml@ComplianceRepo - parameters: - # the folder which contains the binaries to sign - buildOutputPath: $(signSrcPath) - # the location to put the signed output - signOutputPath: $(signOutPath) - # the certificate ID to use - certificateId: "CP-230012" - # The file pattern to use - # If not using minimatch: comma separated, with * supported - # If using minimatch: newline separated, with !, **, and * supported. - # See link in the useMinimatch comments. - pattern: '*.dll,*.psd1,*.psm1,*.ps1xml' - # decides if the task should use minimatch for the pattern matching. - # https://github.com/isaacs/minimatch#features - useMinimatch: false - - # - - pwsh: | - $repoRoot = "$(Build.SourcesDirectory)/TextUtility" - Set-Location $repoRoot - Get-ChildItem -Path ${repoRoot} -File -Recurse | Out-String -Str | Write-Verbose -Verbose - Copy-Item -Path "${repoRoot}/src/dictionary.txt" "${repoRoot}/signed/Microsoft.PowerShell.TextUtility" - - displayName: Copy dictionary.txt - - - template: Sbom.yml@ComplianceRepo - parameters: - BuildDropPath: $(Build.SourcesDirectory)/TextUtility/signed/Microsoft.PowerShell.TextUtility - Build_Repository_Uri: 'https://github.com/powershell/textutility' - PackageName: 'Microsoft.PowerShell.TextUtility' - PackageVersion: $(PackageVersion) - - - pwsh: | - set-location $(Build.SourcesDirectory)/TextUtility - ./build.ps1 -Package -Signed -NoBuild - New-Item -Type Directory nupkg - Copy-Item *.nupkg nupkg -ErrorAction Ignore -Verbose - Get-ChildItem -Recurse -File -Name | out-string -str | Write-Verbose -Verbose - - displayName: Construct Signed Module with SBOM - - - pwsh: | - New-Item -Path $(Build.SourcesDirectory)/TextUtility/SignedZip -ItemType Directory -ErrorAction Ignore - Compress-Archive -Path $(Build.SourcesDirectory)/TextUtility/signed/Microsoft.PowerShell.TextUtility -DestinationPath $(Build.SourcesDirectory)/TextUtility/SignedZip/Microsoft.PowerShell.TextUtility.zip -Force - - displayName: 'Compress archive' - condition: succeededOrFailed() - - - task: PublishPipelineArtifact@1 - inputs: - targetpath: $(Build.SourcesDirectory)/TextUtility/signed/Microsoft.PowerShell.TextUtility - artifactName: Signed - - - task: PublishPipelineArtifact@1 - inputs: - targetpath: $(Build.SourcesDirectory)/TextUtility/SignedZip - artifactName: SignedZip - - - task: PublishPipelineArtifact@1 - inputs: - targetpath: $(Build.SourcesDirectory)/TextUtility/nupkg - artifactName: nupkg - -- stage: compliance - displayName: Compliance - dependsOn: BuildAndSign - jobs: - - job: Compliance_Job - pool: - name: PowerShell1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - steps: - - checkout: self - - checkout: ComplianceRepo - - download: current - artifact: Signed - - - pwsh: | - Get-ChildItem -Path "$(Pipeline.Workspace)\Signed" -Recurse - - displayName: Capture downloaded artifacts - - - template: assembly-module-compliance.yml@ComplianceRepo - parameters: - # binskim - AnalyzeTarget: '$(Pipeline.Workspace)\*.dll' - AnalyzeSymPath: 'SRV*' - # component-governance - sourceScanPath: '$(Build.SourcesDirectory)' - # credscan - suppressionsFile: '' - # TermCheck - optionsRulesDBPath: '' - optionsFTPath: '' - # tsa-upload - codeBaseName: 'textutility_202305' - # selections - APIScan: false # set to false when not using Windows APIs. diff --git a/yaml/template/runtest.yml b/yaml/template/runtest.yml deleted file mode 100644 index c421a98..0000000 --- a/yaml/template/runtest.yml +++ /dev/null @@ -1,19 +0,0 @@ -parameters: - vmImageName: 'windows-latest' - jobName: 'run_test_windows' - jobDisplayName: 'Run test' - -jobs: - - job: '${{ parameters.jobName }}_netstandard20' - pool: - vmImage: ${{ parameters.vmImageName }} - displayName: ${{ parameters.jobDisplayName }} - Test - steps: - - task: DownloadPipelineArtifact@2 - inputs: - artifactName: out - targetPath: '$(Build.SourcesDirectory)/out' - - pwsh: | - Import-Module ./out/Microsoft.PowerShell.TextUtility - Invoke-Pester -Path ./test -OutputFormat NUnitXml -EnableExit - condition: succeeded() From ab8f9a0a83bc9eb2139a85e40a7b9f0dfa8714bb Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Wed, 5 Mar 2025 15:28:17 -0800 Subject: [PATCH 4/4] WIP: Update build --- .pipelines/TextUtility-Official.yml | 39 ++++++++++------------- Directory.Build.props | 1 + src/Microsoft.PowerShell.TextUtility.psd1 | 2 +- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/.pipelines/TextUtility-Official.yml b/.pipelines/TextUtility-Official.yml index 17816b7..703d358 100644 --- a/.pipelines/TextUtility-Official.yml +++ b/.pipelines/TextUtility-Official.yml @@ -1,29 +1,26 @@ -name: TextUtility-ModuleBuild-$(Build.BuildId) -trigger: none -pr: none +trigger: +- main schedules: - cron: '0 3 * * 1' - displayName: Weekly Build + displayName: Weekly CodeQL branches: include: - main always: true parameters: - - name: 'publishToPowerShellGallery' - displayName: 'Publish module to PowerShell gallery' - type: boolean - default: false +- name: debug + displayName: Enable debug output + type: boolean + default: false variables: + system.debug: ${{ parameters.debug }} BuildConfiguration: Release + WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest DOTNET_NOLOGO: true DOTNET_GENERATE_ASPNET_CERTIFICATE: false - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest resources: repositories: @@ -36,16 +33,17 @@ extends: # https://aka.ms/obpipelines/templates template: v2/OneBranch.Official.CrossPlat.yml@templates parameters: - featureFlags: - WindowsHostVersion: '1ESWindows2022' globalSdl: # https://aka.ms/obpipelines/sdl asyncSdl: enabled: true forStages: [build] - #credscan: - # enabled: true - # scanfolder: $(Build.SourcesDirectory) - # suppressionsFile: $(Build.SourcesDirectory)\.config\suppress.json + featureFlags: + EnableCDPxPAT: false + WindowsHostVersion: + Version: 2022 + Network: KS3 + release: + category: NonAzure stages: - stage: build jobs: @@ -54,10 +52,7 @@ extends: pool: type: windows variables: - - name: ob_outputDirectory - value: $(Build.SourcesDirectory)/out - #- name: ob_sdl_credscan_suppressionsFile - # value: $(Build.SourcesDirectory)\.config\suppress.json + ob_outputDirectory: $(Build.SourcesDirectory)/out steps: - pwsh: | Write-Verbose -Verbose ((Get-Item $(Build.SourcesDirectory)).FullName) diff --git a/Directory.Build.props b/Directory.Build.props index 1932808..cd6eb7d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,6 @@ + 0.5.0 true diff --git a/src/Microsoft.PowerShell.TextUtility.psd1 b/src/Microsoft.PowerShell.TextUtility.psd1 index 35ce7e1..a82c353 100644 --- a/src/Microsoft.PowerShell.TextUtility.psd1 +++ b/src/Microsoft.PowerShell.TextUtility.psd1 @@ -3,7 +3,7 @@ @{ RootModule = '.\Microsoft.PowerShell.TextUtility.dll' - ModuleVersion = '0.5.0' + ModuleVersion = '{{ModuleVersion}}' CompatiblePSEditions = @('Desktop', 'Core') GUID = '5cb64356-cd04-4a18-90a4-fa4072126155' Author = 'Microsoft Corporation'