-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (116 loc) · 4.33 KB
/
main.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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
wix.exe extension add WixToolset.UI.wixext --global
nuget.exe install WixToolset.Heat -NonInteractive
Get-ChildItem -Path .\WixToolset.Heat* -Recurse |
Where-Object { $_.FullName.EndsWith('x64\heat.exe') } |
Select-Object -ExpandProperty DirectoryName |
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Generate module manifest and version properties
id: version
run: |
New-Item ./publish -ItemType Directory -ErrorAction Stop |Out-Null
if ('${{ github.ref_type }}' -eq 'tag')
{
$tag = "${{ github.ref_name }}".TrimStart("v")
./src/ModuleManifest.ps1 -Path ./publish/PSSerilog.psd1 -Verbose -ErrorAction Stop
./src/VersionInfo.ps1 -Verbose -ErrorAction Stop
}
else
{
$tag = '0.0.1'
./src/ModuleManifest.ps1 -Version $tag -Path ./publish/PSSerilog.psd1 -Verbose -ErrorAction Stop
./src/VersionInfo.ps1 -Version $tag -Verbose -ErrorAction Stop
}
$version = [version]::new($tag)
echo "version=$version" >> $env:GITHUB_OUTPUT
- 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: Harvest installer
run: |
heat.exe `
dir `
.\publish `
-nologo `
-cg ProductComponents `
-dr INSTALLDIR `
-var var.ProductSource `
-g1 `
-ag `
-ke `
-srd `
-sfrag `
-sreg `
-o Fragment.wxs
- name: Build installer
run: |
wix.exe `
build `
-arch x64 `
-src Fragment.wxs src\Product.wxs `
-d ProductSource=publish `
-d ProductVersion="${{ steps.version.outputs.version }}" `
-ext WixToolset.UI.wixext `
-out ps-serilog.msi
- name: Update installer
run: |
$path = Resolve-Path 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\msiinfo.exe' -ErrorAction Stop
& $path ps-serilog.msi -t "PowerShell Serilog Module" -o "PSSerilog v${{ steps.version.outputs.version }}"
- name: Validate installer
run: wix.exe msi validate ps-serilog.msi
- name: Upload artifacts
uses: actions/upload-artifact@v3
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'
uses: ncipollo/release-action@v1
with:
artifacts: ps-serilog.msi