-
Notifications
You must be signed in to change notification settings - Fork 4
/
psakefile.ps1
76 lines (62 loc) · 2.5 KB
/
psakefile.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
#Requires -Module psake
Task Test {
$configuration = New-PesterConfiguration
$configuration.Run.Path = './Tests/'
$configuration.Run.Throw = $true
$configuration.Output.Verbosity = if ($Detailed) {
'Detailed'
} else {
'Normal'
}
if ('True' -eq $env:CI -or $Results) {
$resultsDirectory = 'TestResults'
$configuration.TestResult.Enabled = $true
$configuration.TestResult.OutputFormat = 'NUnit3'
$configuration.TestResult.OutputPath = Join-Path $resultsDirectory 'testResults.xml'
$configuration.CodeCoverage.Enabled = $true
$configuration.CodeCoverage.Path = './Module/'
$configuration.CodeCoverage.OutputPath = Join-Path $resultsDirectory 'coverage.xml'
}
Invoke-Pester -Configuration $configuration
}
Task TagRelease {
$module = Test-ModuleManifest -Path (Join-Path 'Module' 'RicohAddressBook.psd1')
$tagName = "v$($module.Version)"
if ($PreRelease) {
$lastRelease = git tag --list "$tagName-pre.*" |
Where-Object { $_ -match '\.(\d+)$' } |
ForEach-Object { [uint32] $Matches[1] } |
Measure-Object -Maximum |
Select-Object -ExpandProperty Maximum
$next = [string] ($lastRelease + 1)
$tagName += "-pre.$next"
}
git tag -a $tagName -m $tagName
}
if ($env:CI -eq $true) {
Task InitializeDeployments {
if ($env:APPVEYOR -eq $true) {
if ($env:APPVEYOR_REPO_TAG -eq $true) {
$env:IS_PRERELEASE = $env:APPVEYOR_REPO_TAG_NAME -like '*-pre.*'
}
$env:RELEASE_DESCRIPTION = if ($null -eq $env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED) {
"Release $env:APPVEYOR_REPO_TAG_NAME"
} else {
$env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED
}
}
}
Task DeployToPowerShellGallery -precondition { $env:IS_PRERELEASE -eq $false } {
Remove-Item -Recurse './Publish/RicohAddressBook/' -ErrorAction Ignore
Copy-Item -Recurse './Module/' './Publish/RicohAddressBook/'
Publish-Module -Path './Publish/RicohAddressBook/' -NuGetApiKey $env:NuGetApiKey
}
Task UploadTestResults {
if ($env:APPVEYOR -eq $true) {
# Upload test results to AppVeyor
$client = [System.Net.WebClient]::new()
$results = Resolve-Path (Join-Path 'TestResults' 'testResults.xml')
$client.UploadFile("$env:APPVEYOR_URL/api/testresults/nunit3/$env:APPVEYOR_JOB_ID", $results)
}
}
}