-
Notifications
You must be signed in to change notification settings - Fork 2
37 lines (35 loc) · 1.28 KB
/
publish-module.yml
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
name: Publish Module
on:
workflow_dispatch:
release:
types: [published]
jobs:
lint-and-publish-to-gallery:
name: Run PSScriptAnalyzer and Publish to PSGallery
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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 * -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."
}
- uses: actions/checkout@v3
- name: Build and publish
env:
NUGET_KEY: ${{ secrets.PSGALLERY_KEY }}
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Publish-Module -Path ./ -NuGetApiKey $env:NUGET_KEY -Force -Verbose