-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.ps1
94 lines (79 loc) · 3.41 KB
/
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
param(
[string]$Version = ''
)
$ErrorActionPreference = 'Stop'
if ($env:APPVEYOR_BUILD_VERSION) {
$Version = [regex]::match($env:APPVEYOR_BUILD_VERSION,'[0-9]+\.[0-9]+\.[0-9]+').Groups[0].Value
$lastPublishedVersion = [Version]::new((Find-Module -Name JournalCli | Select-Object -ExpandProperty Version))
if ([Version]::new($Version) -le $lastPublishedVersion) {
throw "Version must be greater than the last published version, which is 'v$lastPublishedVersion'."
}
Write-Host "Last published version: 'v$lastPublishedVersion'. Current version: 'v$Version'"
} elseif ($Version -eq '') {
throw "Missing version parameter"
}
if (Test-Path "$PSScriptRoot\publish") {
Remove-Item -Path "$PSScriptRoot\publish" -Recurse -Force
}
$appName = "WhatsNew"
$publishOutputDir = "$PSScriptRoot\publish\$appName"
$proj = Get-ChildItem -Filter "$appName.csproj" -Recurse -Path $PSScriptRoot | Select-Object -First 1 -ExpandProperty FullName
dotnet publish $proj --output $publishOutputDir -c Release
if ($LASTEXITCODE -ne 0) {
throw "Failed to publish application."
}
Remove-Item "$publishOutputDir\*.pdb"
Import-Module "$publishOutputDir\$appName.dll"
$moduleInfo = Get-Module WhatsNew
$cmdletNames = Export-BinaryCmdletNames -ModuleInfo $moduleInfo
$cmdletAliases = Export-BinaryCmdletAliases -ModuleInfo $moduleInfo
$scriptFiles = Get-ChildItem -Path "$PSScriptRoot\src\script-modules" -File
$scriptAliases = $scriptFiles | Select-Object -ExpandProperty FullName | Export-PSScriptAliases
$scriptFunctions = $scriptFiles | Select-Object -ExpandProperty FullName | Export-PSScriptFunctionNames
$modules = $scriptFiles |
Select-Object -ExpandProperty Name |
ForEach-Object { ".\script-modules\$_" }
$modules += ".\$appName.dll"
$manifestPath = "$publishOutputDir\$appName.psd1"
$newManifestArgs = @{
Path = $manifestPath
}
$updateManifestArgs = @{
Path = $manifestPath
CopyRight = "(c) $((Get-Date).Year) Nick Spreitzer"
Description = "Powershell functions for versioning a git repo with tags and more!"
Guid = '861e5d28-8348-47d3-a2f6-cdd23e33bb55'
Author = 'Nick Spreitzer'
CompanyName = 'RAWR! Productions'
ModuleVersion = $Version
AliasesToExport = $cmdletAliases + $scriptAliases
NestedModules = $modules
CmdletsToExport = $cmdletNames
FunctionsToExport = $scriptFunctions
CompatiblePSEditions = @("Desktop","Core")
HelpInfoUri = "https://github.com/refactorsaurusrex/whats-new/wiki"
PowerShellVersion = "6.0"
PrivateData = @{
Tags = 'git','semver', 'markdown'
LicenseUri = 'https://github.com/refactorsaurusrex/whats-new/blob/master/LICENSE.md'
ProjectUri = 'https://github.com/refactorsaurusrex/whats-new'
}
}
New-ModuleManifest @newManifestArgs
Update-ModuleManifest @updateManifestArgs
Import-Module "$PSScriptRoot\src\script-modules\RemoveModuleManifestComments.psm1" -Force
Remove-ModuleManifestComments $manifestPath -NoConfirm
New-item -ItemType Directory -Path "$publishOutputDir\script-modules\" | Out-Null
Get-ChildItem -Path "$PSScriptRoot\src\script-modules" -Filter "*.ps*1" | Copy-Item -Destination "$publishOutputDir\script-modules\"
Install-Module platyPS
Import-Module platyPS
$docs = "$PSScriptRoot\docs"
try {
git clone https://github.com/refactorsaurusrex/whats-new.wiki.git $docs
Switch-CodeFenceToYamlFrontMatter -Path $docs -NoConfirm
New-ExternalHelp -Path $docs -OutputPath $publishOutputDir
} finally {
if (Test-Path $docs) {
Remove-Item -Path $docs -Recurse -Force
}
}