Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/ci_auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ stages:
}
else
{
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
$(Build.SourcesDirectory)/build.ps1 -Publish
}
displayName: Publish module nuget package and upload package artifact
condition: succeeded()
Expand Down
8 changes: 8 additions & 0 deletions .config/tsaoptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"instanceUrl": "https://msazure.visualstudio.com",
"projectName": "One",
"areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell\\PowerShell Core\\ThreadJob",
"codebaseName": "TFSMSAzure_ThreadJob",
"notificationAliases": [ "chungjustin@microsoft.com", "slee@microsoft.com" ],
"tools": [ "CredScan", "PoliCheck", "BinSkim" ]
}
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/src/code" # Location of package manifests
schedule:
interval: "daily"

- package-ecosystem: github-actions
directory: /
schedule:
interval: daily

- package-ecosystem: nuget
directory: /
schedule:
interval: daily

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ xhtml/
**/.vscode/**
**/out/**
**/bin/**
.vs/**/*
**/*.sln
276 changes: 276 additions & 0 deletions .pipelines/threadjobs-official.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
name: ThreadJob-ModuleBuild-$(Build.BuildId)
trigger: none
pr: none

schedules:
- cron: '0 3 * * 1'
displayName: Weekly Build
branches:
include:
- onebranch-pipelines
always: true

parameters:
- name: 'publishOfficialToPowerShellGallery'
displayName: 'Publish official module to PowerShell gallery'
type: boolean
default: false
- name : 'publishProxyToPowerShellGallery'
displayName: 'Publish proxy module to PowerShell gallery'
type: boolean
default: false

variables:
BuildConfiguration: Release
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:
- repository: templates
type: git
name: OneBranch.Pipelines/GovernedTemplates
ref: refs/heads/main

pipelines:
- pipeline: PSPackagesOfficial
source: 'PowerShell-Packages-Official'

extends:
# https://aka.ms/obpipelines/templates
template: v2/OneBranch.Official.CrossPlat.yml@templates
parameters:
release:
category: NonAzure
featureFlags:
WindowsHostVersion:
Version: 2022
Network: Netlock
globalSdl: # https://aka.ms/obpipelines/sdl
asyncSdl:
enabled: true
forStages: [build]
#credscan:
# enabled: true
# scanfolder: $(Build.SourcesDirectory)
# suppressionsFile: $(Build.SourcesDirectory)\.config\suppress.json
stages:
- stage: build
jobs:
- job: main
displayName: Build package
pool:
type: windows
variables:
- name: ob_outputDirectory
value: '$(Build.ArtifactStagingDirectory)'
- name: ob_sdl_sbom_enabled
value: true
#- name: ob_sdl_credscan_suppressionsFile
# value: $(Build.SourcesDirectory)\.config\suppress.json
steps:
- pwsh: |
Write-Verbose -Verbose $(Build.SourcesDirectory)
Get-ChildItem $(Build.SourcesDirectory) -Recurse -File -Name | Write-Verbose -Verbose
$manifestData = Import-PowerShellDataFile -Path src/Microsoft.PowerShell.ThreadJob.psd1
$moduleVersion = $manifestData.ModuleVersion
Write-Host "##vso[task.setvariable variable=version;isOutput=true]$moduleVersion"
$proxyManifestData = Import-PowerShellDataFile -Path src/ThreadJob/ThreadJob.psd1
$proxyModuleVersion = $proxyManifestData.ModuleVersion
Write-Host "##vso[task.setvariable variable=proxyVersion;isOutput=true]$proxyModuleVersion"
name: package
displayName: Get version from project properties
- task: onebranch.pipeline.version@1
displayName: Set OneBranch version
inputs:
system: Custom
customVersion: $(package.version)
- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
packageType: sdk
useGlobalJson: true
- pwsh: |
Get-ChildItem | Write-Verbose -Verbose
Register-PSRepository -Name CFS -SourceLocation "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v2" -InstallationPolicy Trusted
Install-Module -Repository CFS -Name Microsoft.PowerShell.PSResourceGet -MinimumVersion 1.0.5
.\build.ps1 -clean -Build -BuildConfiguration Release -BuildFramework netstandard2.0
displayName: Build
- pwsh: |
Get-ChildItem | Write-Verbose -Verbose
Write-Verbose -Verbose -Message "Install Microsoft.PowerShell.ThreadJob module"
Copy-Item -Path $(Build.SourcesDirectory)/out/Microsoft.PowerShell.ThreadJob -Destination ($env:PSModulePath -split ';')[0] -Recurse -Force
Write-Verbose -Verbose -Message "Test ThreadJob module manifest"
Test-ModuleManifest -Path $(Build.SourcesDirectory)/out/ThreadJob/ThreadJob.psd1
.\build.ps1 -Publish
Write-Verbose -Verbose ((Get-Item .).FullName)
Write-Verbose -Verbose $(Build.SourcesDirectory)
Get-ChildItem $(Build.SourcesDirectory) -Recurse -File -Name | Write-Verbose -Verbose
displayName: Package module
- task: onebranch.pipeline.signing@1
displayName: Sign NuGet package
inputs:
command: sign
signing_profile: external_distribution
search_root: $(Build.SourcesDirectory)
files_to_sign: "**/*.nupkg"
- pwsh: |
Get-ChildItem -Path $(Build.SourcesDirectory)/out -Filter '*.nupkg' -Recurse
| ForEach-Object {
Write-Verbose -Verbose "Copying $($_.FullName) to $(ob_outputDirectory)"
Copy-Item -Path $_.FullName -Destination $(ob_outputDirectory) -Force
}
Get-ChildItem -Path $(ob_outputDirectory) -Recurse -File -Name | Write-Verbose -Verbose
displayName: Upload Signed Nupkgs
- stage: manual
dependsOn: build
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 and then publish it!
timeoutInMinutes: 1440
- stage: release_official_MicrosoftPowerShellThreadJob_module
displayName: release official
variables:
ob_release_environment: Production
drop: $(Pipeline.Workspace)/drop_build_main
version: $[ stageDependencies.build.main.outputs['package.version'] ]
dependsOn: [build, manual]
condition: ${{ parameters.publishOfficialToPowerShellGallery }}
jobs:
- job: publish
templateContext:
inputs:
- input: pipelineArtifact
artifactName: drop_build_main
- input: pipelineArtifact
pipeline: PSPackagesOfficial
artifactName: drop_upload_upload_packages
displayName: Publish to PowerShell Gallery
pool:
type: release
os: windows
variables:
- group: ThreadJob_Gallery_API
steps:
- task: PowerShell@2
inputs:
targetType: inline
script: |
$localInstallerPath = Get-ChildItem -Path "$(Pipeline.Workspace)/GitHubPackages" -Filter '*win-x64.msi' | Select-Object -First 1 -ExpandProperty FullName
if (Test-Path -Path $localInstallerPath) {
Write-Verbose -Verbose "Installer found at $localInstallerPath"
} else {
throw "Installer not found"
}
Write-Verbose -Verbose "Installing PowerShell via msiexec"
Start-Process -FilePath msiexec -ArgumentList "/package $localInstallerPath /quiet REGISTER_MANIFEST=1" -Wait -NoNewWindow
$pwshPath = Get-ChildItem -Directory -Path 'C:\Program Files\PowerShell\7*' | Select-Object -First 1 -ExpandProperty FullName
if (Test-Path -Path $pwshPath) {
Write-Verbose -Verbose "PowerShell installed at $pwshPath"
Write-Verbose -Verbose "Adding pwsh to env:PATH"
Write-Host "##vso[task.prependpath]$pwshPath"
} else {
throw "PowerShell not installed"
}
displayName: Install pwsh 7
- task: PowerShell@2
inputs:
targetType: inline
pwsh: true
script: |
Write-Verbose -Verbose "Pwsh 7 Installed"
Write-Verbose -Verbose "env:Path: "
$env:PATH -split ';' | ForEach-Object {
Write-Verbose -Verbose $_
}
displayName: Check pwsh 7 installation
- task: Powershell@2
inputs:
pwsh: true
targetType: inline
script: |
Write-Verbose -Verbose -Message "Publish module to PSGallery"
Publish-PSResource -ApiKey $(GalleryKey) -Repository PSGallery -Path $(Pipeline.Workspace)/Microsoft.PowerShell.ThreadJob.($version).nupkg
displayName: Publish to PowerShell Gallery
- stage: release_proxy_ThreadJob_module
displayName: release proxy
variables:
ob_release_environment: Production
drop: $(Pipeline.Workspace)/drop_build_main
version: $[ stageDependencies.build.main.outputs['package.proxyVersion'] ]
dependsOn: [build, manual]
condition: ${{ parameters.publishProxyToPowerShellGallery }}
jobs:
- job: publish
templateContext:
inputs:
- input: pipelineArtifact
artifactName: drop_build_main
- input: pipelineArtifact
pipeline: PSPackagesOfficial
artifactName: drop_upload_upload_packages
displayName: Publish to PowerShell Gallery
pool:
type: release
os: windows
variables:
- group: ThreadJob_Gallery_API
steps:
- task: PowerShell@2
inputs:
targetType: inline
script: |
$localInstallerPath = Get-ChildItem -Path "$(Pipeline.Workspace)/GitHubPackages" -Filter '*win-x64.msi' | Select-Object -First 1 -ExpandProperty FullName
if (Test-Path -Path $localInstallerPath) {
Write-Verbose -Verbose "Installer found at $localInstallerPath"
} else {
throw "Installer not found"
}
Write-Verbose -Verbose "Installing PowerShell via msiexec"
Start-Process -FilePath msiexec -ArgumentList "/package $localInstallerPath /quiet REGISTER_MANIFEST=1" -Wait -NoNewWindow
$pwshPath = Get-ChildItem -Directory -Path 'C:\Program Files\PowerShell\7*' | Select-Object -First 1 -ExpandProperty FullName
if (Test-Path -Path $pwshPath) {
Write-Verbose -Verbose "PowerShell installed at $pwshPath"
Write-Verbose -Verbose "Adding pwsh to env:PATH"
Write-Host "##vso[task.prependpath]$pwshPath"
} else {
throw "PowerShell not installed"
}
displayName: Install pwsh 7
- task: PowerShell@2
inputs:
targetType: inline
pwsh: true
script: |
Write-Verbose -Verbose "Pwsh 7 Installed"
Write-Verbose -Verbose "env:Path: "
$env:PATH -split ';' | ForEach-Object {
Write-Verbose -Verbose $_
}
displayName: Check pwsh 7 installation
- task: Powershell@2
inputs:
pwsh: true
targetType: inline
script: |
Write-Verbose -Verbose -Message "Install Microsoft.PowerShell.ThreadJob module"
Copy-Item -Path $(Pipeline.Workspace)/Microsoft.PowerShell.ThreadJob -Destination ($env:PSModulePath -split ';')[0] -Recurse -Force -Verbose
Write-Verbose -Verbose -Message "Test ThreadJob module manifest"
Test-ModuleManifest -Path $(Pipeline.Workspace)/ThreadJob/ThreadJob.psd1
Write-Verbose -Verbose -Message "Publish module to PSGallery"
Publish-PSResource -ApiKey $(GalleryKey) -Repository PSGallery -Path $(Pipeline.Workspace)/ThreadJob
displayName: Publish to PowerShell Gallery

20 changes: 7 additions & 13 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@ param (
[switch]
$Publish,

[Parameter(ParameterSetName="publish")]
[switch]
$Signed,

[ValidateSet("Debug", "Release")]
[string] $BuildConfiguration = "Debug",

[ValidateSet("net461")]
[string] $BuildFramework = "net461"
[ValidateSet("netstandard2.0")]
[string] $BuildFramework = "netstandard2.0"
)

Import-Module -Name "$PSScriptRoot/buildtools.psd1" -Force

$config = Get-BuildConfiguration -ConfigPath $PSScriptRoot

$script:ModuleName = $config.ModuleName
$script:ProxyModuleName = $config.ProxyModuleName
$script:SrcPath = $config.SourcePath
$script:OutDirectory = $config.BuildOutputPath
$script:SignedDirectory = $config.SignedOutputPath
$script:TestPath = $config.TestPath

$script:ModuleRoot = $PSScriptRoot
Expand All @@ -47,13 +43,9 @@ if ($env:TF_BUILD) {
$vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"

$vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
}

. $PSScriptRoot/dobuild.ps1
. $PSScriptRoot/doBuild.ps1

if ($Clean -and (Test-Path $OutDirectory))
{
Expand All @@ -73,6 +65,7 @@ if ($Clean -and (Test-Path $OutDirectory))
if (-not (Test-Path $OutDirectory))
{
$script:OutModule = New-Item -ItemType Directory -Path (Join-Path $OutDirectory $ModuleName)
$script:ProxyOutModule = New-Item -itemType Directory -Path (Join-Path $OutDirectory $ProxyModuleName)
}
else
{
Expand All @@ -87,5 +80,6 @@ if ($Build.IsPresent)

if ($Publish.IsPresent)
{
Publish-ModulePackage -Signed:$Signed.IsPresent
Publish-ModulePackage
}

2 changes: 1 addition & 1 deletion buildtools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Get-BuildConfiguration', 'Invoke-ModuleBuild', 'Publish-ModulePackage', 'Install-ModulePackageForTest', 'Invoke-ModuleTests')

# Variables to export from this module
VariablesToExport = '*'

Expand Down
Loading