forked from jhoneill/MsftGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quick_publish.ps1
33 lines (29 loc) · 1.28 KB
/
quick_publish.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
[cmdletbinding(SupportsShouldProcess=$true)]
param (
[Parameter(Mandatory=$true,Position=0)]
$key
)
Get-item *.dll | Remove-Item -ErrorAction stop
if (Get-Item *.dll) {throw 'Remove DLLs' ; break}
if (Select-String -Path .\Microsoft.Graph.PlusPlus.settings.ps1 -Pattern 'clientsecret\s+["''](?!xxx)|TenantID\s+["''](?!xxx)') {
throw "Settings contains secrets!"; break
}
#two chances to find things in settings
git update-index --no-skip-worktree .\Microsoft.Graph.PlusPlus.settings.ps1
if (-not (( git status ) -match "nothing to commit, working tree clean")) {throw "Unclean !" ; break}
$files = @{}
(Import-PowerShellDataFile .\Microsoft.Graph.PlusPlus.psd1 ).filelist | ForEach-Object {
$i = Get-Item $_ -ErrorAction stop
$files[$i.FullName] = $true
}
#we will use git to bring these back
Remove-Item .\.vscode\* -Force -Recurse
Remove-Item .\.gitignore
Get-ChildItem -Recurse -File -Exclude $MyInvocation.MyCommand.name, .\.git |
Where-Object {-not $files[$_.FullName] } |
Remove-Item
if ($PSCmdlet.ShouldProcess('Publish')) {
Publish-Module -NuGetApiKey $key -Repository PSGallery -AllowPrerelease -Name Microsoft.Graph.PlusPlus
}
git reset HEAD --hard
git update-index --skip-worktree .\Microsoft.Graph.PlusPlus.settings.ps1