-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (76 loc) · 2.77 KB
/
Copy pathps-module.yml
File metadata and controls
82 lines (76 loc) · 2.77 KB
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
name: Test PowerShell on Ubuntu
on: push
jobs:
lint-with-PSScriptAnalyzer:
name: Install and run PSScriptAnalyzer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install PSScriptAnalyzer module
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: Lint with PSScriptAnalyzer
shell: pwsh
run: |
Invoke-ScriptAnalyzer -Path MathFunctions.psm1 -Recurse -Outvariable issues
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
} else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
pester-test:
name: Pester test
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Perform a Pester test from the Tests.ps1 file
shell: pwsh
run: |
Invoke-Pester .\tests\*.Tests.ps1 -CodeCoverage .\MathFunctions.psm1
generate-docs:
name: Generate docs
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v2
- name: Generate documentation for module
shell: pwsh
run: |
Install-Module platyPS -Force
Import-Module platyPS
Import-Module .\MathFunctions.psd1
New-MarkdownHelp -Module MathFunctions -OutputFolder .\docs -Force
- name: Commit files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Add changes" -a
- name: Should push
shell: pwsh
run: |
$FilesChanged = (git diff HEAD HEAD~1 --name-only -- .\docs).count
if($FilesChanged -gt 0) { echo "ShouldPush=true" >> $GITHUB_ENV }
- name: Push changes
if: env.ShouldPush == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
publish-to-gallery:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and publish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
shell: pwsh
run: |
mkdir MathFunctions
mv ./MathFunctions.psd1 ./MathFunctions
mv ./MathFunctions.psm1 ./MathFunctions
Publish-Module -Path ./MathFunctions -NuGetApiKey $env:NUGET_API_KEY -Verbose