-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppVeyorPublish.ps1
37 lines (31 loc) · 1.2 KB
/
AppVeyorPublish.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
# only publish if commit message starts with !publish
if ($Env:APPVEYOR_REPO_COMMIT_MESSAGE -notmatch ', publish!$') {
Write-Output "No publishing from AppVeyor, to automatically publish, finish commit message with ', publish!'"
exit
}
if ($env:OS -notmatch 'Windows') {
Write-Output 'Publishing possible only from Windows hosts'
exit
}
# check if this version already exists
$ModuleName = 'SE.IntroModule'
$Manifest = Test-ModuleManifest -Path (Join-Path . "$ModuleName.psd1")
$LocalVersion = $Manifest.Version.ToString()
try {
$RemoteModule = Find-Module $ModuleName -Repository PSGallery
$RemoteVersion = $RemoteModule.Version.ToString()
} catch {
$RemoteVersion = 'not found'
}
if ($LocalVersion -eq $RemoteVersion) {
Write-Warning "Module $ModuleName with version $LocalVersion already exists. Consider bumping version."
exit
}
# we proceed with publish
Write-Output "Publishing version $LocalVersion to PSGallery, currently published version is $RemoteVersion"
try {
Publish-Module -Path . -Repository PSGallery -NuGetApiKey $env:MyPSGalleryAPIKey -ea Stop -Verbose
Write-Output "Module successfully published!"
} catch {
Write-Output "Publishing failed: $_"
}