-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPSKeystore.build.ps1
60 lines (51 loc) · 2.55 KB
/
PSKeystore.build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
[CmdletBinding()]
param ()
task InitializeBuildEnvironment {
Set-BuildEnvironment -Force
Get-BuildEnvironment
}
task CleanBuildOutputFolder {
$Script:moduleOutputPath = Join-Path -Path $Env:BHBuildOutput -ChildPath $Env:BHProjectName
$Script:moduleOutputManifest = "$moduleOutputPath\$Env:BHProjectName.psd1"
#if (Test-Path -Path $moduleOutputPath) {
Write-Verbose 'Clearing build output folder' -Verbose
Get-ChildItem -Path $Env:BHBuildOutput -Exclude Modules | Remove-Item -Recurse -Force
#}
}
task StageModuleFiles {
Copy-Item -Path $Env:BHModulePath -Destination $Env:BHBuildOutput -Recurse -Force
}
task UpdateModuleVersion -if { $null -ne $Env:APPVEYOR_BUILD_VERSION } {
Write-Verbose "Updating module version to $Env:APPVEYOR_BUILD_VERSION" -Verbose
$manifest = Get-Content -Path $moduleOutputManifest -Raw
$manifest = $manifest -replace "'0.0.1'", "'$($Env:APPVEYOR_BUILD_VERSION)'"
Set-Content -Path $moduleOutputManifest -Value $manifest -Encoding Ascii
}
task GenerateModuleHelp -if ($Configuration -eq 'Release') {
Write-Verbose "Generating module external help" -Verbose
Remove-Module $Env:BHProjectName -ErrorAction Ignore
Import-Module $moduleOutputPath
$null = New-ExternalHelp -Path "$Env:BHProjectPath\Docs\Module" -OutputPath "$moduleOutputPath\en-US" -ShowProgress -Force
Write-Verbose "Module external help saved to: $moduleOutputPath\en-US" -Verbose
}
task CreateArtifact -if ($Configuration -eq 'Release') {
Write-Verbose "Creating $Env:BHProjectName module artifact" -Verbose
$repoName = 'LocalGallery'
$repoPath = "$Env:BHBuildOutput\$repoName"
if (!(Test-Path -Path $repoPath)) {
$null = New-Item -Path $repoPath -ItemType Directory -Force
}
Register-PSRepository -Name $repoName -SourceLocation $repoPath -InstallationPolicy Trusted
Write-Verbose 'Publishing required modules to a temporary local repository' -Verbose
foreach ($requiredModule in (Get-Module -Name $Env:BHProjectName).RequiredModules) {
Publish-Module -Name $requiredModule.Name -RequiredVersion $requiredModule.Version -Repository $repoName
}
if (!($Env:PSModulePath.Split(';').Contains((Get-Module -Name $Env:BHProjectName).ModuleBase))) {
$Env:PSModulePath = (Get-Module -Name $Env:BHProjectName).ModuleBase + ";$Env:PSModulePath"
}
Write-Verbose 'Publishing module to temporary local repository' -Verbose
Publish-Module -Name $Env:BHProjectName -Repository $repoName
Write-Verbose 'Removing required modules from temporary local repository' -Verbose
Get-ChildItem -Path $repoPath -Exclude $Env:BHProjectName* | Remove-Item
Unregister-PSRepository -Name $repoName
}