CI #27
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_GENERATE_ASPNET_CERTIFICATE: false | |
DOTNET_NOLOGO: true | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup wix | |
run: | | |
dotnet.exe tool install --global wix --version 5.0.0 --verbosity diag | |
wix.exe extension add WixToolset.UI.wixext/5.0.0 --global | |
wix.exe extension list --global | |
- name: Generate version property | |
id: version | |
run: | | |
$tag = git.exe describe --tags --long | |
$version = [version]::new($tag.Split('-')[0].TrimStart('v')) | |
echo "version=$version" >> $env:GITHUB_OUTPUT | |
- name: Run tests | |
run: dotnet.exe test .\src\PSSerilog.sln | |
- name: Clean solution | |
run: dotnet.exe clean .\src\PSSerilog.sln --configuration Release | |
- name: Build project | |
run: dotnet.exe publish .\src\PSSerilog\PSSerilog.csproj --configuration Release --runtime win-x64 --output .\publish | |
- name: Prepare release | |
run: Remove-Item ./publish/* -Include *.pdb,*.xml -ErrorAction Stop | |
- name: Generate PowerShell help | |
run: | | |
Install-Module -Name platyPS -Force -Confirm:$false -ErrorAction Stop | |
Import-Module ./publish/PSSerilog.psd1 -ErrorAction Stop | |
Update-MarkdownHelp ./docs -UpdateInputOutput -Force -ErrorAction Stop | |
New-ExternalHelp ./docs -OutputPath ./publish -ErrorAction Stop | |
- name: Build installer | |
run: | | |
wix.exe ` | |
build ` | |
-arch x64 ` | |
-src src\Product.wxs ` | |
-d ProductSource="$(Resolve-Path ./publish)" ` | |
-d ProductVersion="${{ steps.version.outputs.version }}" ` | |
-ext WixToolset.UI.wixext ` | |
-out ps-serilog.msi | |
- name: Validate installer | |
run: wix.exe msi validate ps-serilog.msi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ps-serilog | |
path: | | |
./docs/ | |
./ps-serilog.msi | |
if-no-files-found: error | |
- name: Install msi | |
run: | | |
$process = Start-Process msiexec.exe -ArgumentList '/i','ps-serilog.msi','/qn' -Wait -NoNewWindow -PassThru -ErrorAction Stop | |
if ($process.ExitCode -ne 0) | |
{ | |
throw 'Non zero exit code: "{0}".' -f $process.ExitCode | |
} | |
- name: Test module | |
shell: powershell | |
run: | | |
$PSVersionTable | |
$logger = New-SerilogLoggerConfiguration |Add-SerilogSinkConsole |New-SerilogLogger |Set-SerilogDefaultLogger | |
$logger.Information('Hello world!') | |
Close-SerilogDefaultLogger | |
- name: Publish release | |
if: github.ref_type == 'tag' | |
run: gh.exe release create v${{ steps.version.outputs.version }} --title v${{ steps.version.outputs.version }} --notes 'PowerShell Serilog logging module.' ps-serilog.msi | |
env: | |
# Requires a personal access token with a fine-grained permission of contents:read/write. | |
GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} |