Skip to content

Instantly share code, notes, and snippets.

@MateuszNad
Created September 14, 2020 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MateuszNad/81adfd3ab0b0fef66d42cd1bde27196a to your computer and use it in GitHub Desktop.
Save MateuszNad/81adfd3ab0b0fef66d42cd1bde27196a to your computer and use it in GitHub Desktop.
name: Publish PowerShell module
# Ustawiamy, kiedy przepływ zostanie uruchomiona.
# Wyzwalaczem będzie push do gałęzi master
on:
push:
branches: [master]
# Definiujemy jeden lub więcej zadań
jobs:
publish:
# https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
# Wybór maszyny gdzie zostaną uruchamiane akcje i polecenia
runs-on: windows-latest
steps:
# pobranie repozytorium do maszyny
- uses: actions/checkout@v2
# wykonanie poleceń powershell
# pobranie niezbenych modulow
- name: Install dependencies
shell: powershell
run: |
Install-Module -Name Pester -RequiredVersion 4.10.1 -Force
Install-Module -Name PSScriptAnalyzer -Force
# wykonanie testow
- name: Run test
shell: powershell
run: |
Import-Module -Name Pester -MaximumVersion 4.10.1
if((Invoke-Pester -Strict -PassThru).FailedCount -ne 0) {
Throw 'Failed unit tests.'
}
# analiza kodu
- name: Run script analyze
shell: powershell
run: |
$scriptAnalyzerParams = @{
Path = "$($env:GITHUB_WORKSPACE)\public"
Severity = @('Error', 'Warning')
Recurse = $true
ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments', 'PSAvoidOverwritingBuiltInCmdlets'
}
Invoke-ScriptAnalyzer @scriptAnalyzerParams -OutVariable ResultScriptAnalyzer
if($ResultScriptAnalyzer) {
Throw "One or more PSScriptAnalyzer errors/warnings where found."
}
# publikacja do repozytorium
- name: Publish
env:
# pobranie do zmiennej klucza API
NuGetApiKey: ${{ secrets.NUGET_KEY }}
shell: powershell
run: |
Publish-Module -Path $env:GITHUB_WORKSPACE -NuGetApiKey $env:NuGetApiKey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment