-
Notifications
You must be signed in to change notification settings - Fork 9
/
Build.ps1
31 lines (23 loc) · 921 Bytes
/
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
param([switch]$Publish)
# module variables
$ScriptPath = Split-Path (Get-Variable MyInvocation -Scope Script).Value.Mycommand.Definition -Parent
$ModuleName = (Get-Item $ScriptPath).BaseName
# create build directory
$BuildNumber = Get-Date -Format 'yy.M.d.Hmm'
$BuildDirectory = New-Item -Path "$ScriptPath\build\$BuildNumber\$ModuleName" -ItemType Directory -ErrorAction Stop
# excluded files / directories
$ExcludedFiles = '.git', '.vscode', 'build', 'Build.ps1'
# copy needed files
Get-ChildItem -Path $ScriptPath |
Where-Object { $_.Name -notin $ExcludedFiles } |
Copy-Item -Destination $BuildDirectory -Recurse
# update the build version
$ModuleManifestSplat = @{
Path = "$BuildDirectory\$ModuleName.psd1"
ModuleVersion = $BuildNumber
}
Update-ModuleManifest @ModuleManifestSplat
# publish
if ( $Publish ) {
Publish-Module -Path "$BuildDirectory" @PSGalleryPublishSplat
}