-
Notifications
You must be signed in to change notification settings - Fork 26
141 lines (141 loc) · 5.82 KB
/
Copy pathcommit.yml
File metadata and controls
141 lines (141 loc) · 5.82 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
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: Commit
on:
push:
branches:
- '**'
pull_request:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
# Leftover MSBuild nodes keep obj/ files open and break subsequent WPF markup compilation.
MSBUILDDISABLENODEREUSE: 1
jobs:
ci:
name: CI
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '8.x'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.7.0
with:
versionSpec: '6.x'
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v4.7.0
- name: Set version
id: version
shell: pwsh
run: |
$version = "${{ steps.gitversion.outputs.fullSemVer }}"
$safeVersion = $version -replace '[^a-zA-Z0-9\.\-]', '_'
$mp = "${{ steps.gitversion.outputs.majorMinorPatch }}"
$runNumber = [int64]"${{ github.run_number }}"
$runAttempt = [int]"${{ github.run_attempt }}"
# Chocolatey Community does not accept SemVer 2; flatten like publish-dev.yml.
$chocolateyVersion = '{0}-dev{1:D10}{2:D3}' -f $mp, $runNumber, $runAttempt
Add-Content $env:GITHUB_ENV "VERSION=$version"
Add-Content $env:GITHUB_ENV "SAFE_VERSION=$safeVersion"
Add-Content $env:GITHUB_ENV "CHOCO_VERSION=$chocolateyVersion"
Add-Content $env:GITHUB_ENV "INSTALLER_VERSION=$mp.0"
Add-Content $env:GITHUB_OUTPUT "safe_version=$safeVersion"
Add-Content $env:GITHUB_OUTPUT "chocolatey_version=$chocolateyVersion"
- name: Build solution
# NLogViewer.CI.slnf omits WiX so compile/test does not harvest a 1.0.0.0 MSI.
# -m:1 serializes the build: parallel projects race on the shared WPF obj/ folder.
run: dotnet build NLogViewer.CI.slnf -c Release -m:1
- name: Run tests
run: dotnet test NLogViewer.CI.slnf -c Release --no-build --verbosity normal
- name: Pack NuGet packages
run: dotnet pack NLogViewer.CI.slnf -c Release --no-build -o nuget
- name: Publish Self-Contained
run: |
dotnet publish app/Sentinel.NLogViewer.App/Sentinel.NLogViewer.App.csproj `
-c Release `
-p:SelfContained=true `
-p:PublishSingleFile=true `
-p:RuntimeIdentifier=win-x64 `
-p:Version=$env:VERSION `
-p:IncludeNativeLibrariesForSelfExtract=true `
-o publish/self-contained
- name: Publish Framework-Dependent
run: |
dotnet publish app/Sentinel.NLogViewer.App/Sentinel.NLogViewer.App.csproj `
-c Release `
-p:SelfContained=false `
-p:RuntimeIdentifier=win-x64 `
-p:Version=$env:VERSION `
-o publish/framework-dependent
- name: Rename folders with version
run: |
$version = $env:SAFE_VERSION
Rename-Item -Path "publish/self-contained" -NewName "Sentinel.LogViewer-SelfContained-win-x64-$version"
Rename-Item -Path "publish/framework-dependent" -NewName "Sentinel.LogViewer-FrameworkDependent-win-x64-$version"
- name: Add portable marker and readme to published folders
run: |
$version = $env:SAFE_VERSION
$folders = @(
"publish/Sentinel.LogViewer-SelfContained-win-x64-$version",
"publish/Sentinel.LogViewer-FrameworkDependent-win-x64-$version"
)
foreach ($d in $folders) {
New-Item -ItemType File -Path (Join-Path $d "NLogViewer.portable") -Force | Out-Null
Copy-Item -Path "dist/portable/README-Portable.txt" -Destination (Join-Path $d "README-Portable.txt") -Force
}
- name: Build installer MSI
run: |
dotnet build installer/Sentinel.NLogViewer.Installer.wixproj `
-c Release `
-m:1 `
-p:InstallerVersion=$env:INSTALLER_VERSION
Copy-Item "installer/bin/Release/Sentinel.LogViewer.msi" `
"publish/Sentinel.LogViewer-$($env:SAFE_VERSION)-win-x64.msi"
- name: Pack Chocolatey package
env:
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
./chocolatey/pack.ps1 `
-Version $env:CHOCO_VERSION `
-MsiPath "publish/Sentinel.LogViewer-$env:SAFE_VERSION-win-x64.msi" `
-OutputDirectory chocolatey-packages
- name: Upload NuGet packages
uses: actions/upload-artifact@v7
with:
name: NuGet-${{ steps.version.outputs.safe_version }}
path: nuget
if-no-files-found: error
retention-days: 7
- name: Upload MSI
uses: actions/upload-artifact@v7
with:
name: Sentinel.LogViewer-msi-${{ steps.version.outputs.safe_version }}
path: publish/Sentinel.LogViewer-${{ steps.version.outputs.safe_version }}-win-x64.msi
if-no-files-found: error
retention-days: 7
- name: Upload Self-Contained artifact
uses: actions/upload-artifact@v7
with:
name: Sentinel.LogViewer-SelfContained-win-x64-${{ steps.version.outputs.safe_version }}
path: publish/Sentinel.LogViewer-SelfContained-win-x64-${{ steps.version.outputs.safe_version }}
if-no-files-found: error
retention-days: 7
- name: Upload Framework-Dependent artifact
uses: actions/upload-artifact@v7
with:
name: Sentinel.LogViewer-FrameworkDependent-win-x64-${{ steps.version.outputs.safe_version }}
path: publish/Sentinel.LogViewer-FrameworkDependent-win-x64-${{ steps.version.outputs.safe_version }}
if-no-files-found: error
retention-days: 7
- name: Upload Chocolatey package
uses: actions/upload-artifact@v7
with:
name: Chocolatey-Sentinel.LogViewer-${{ steps.version.outputs.chocolatey_version }}
path: chocolatey-packages
if-no-files-found: error
retention-days: 7