-
Notifications
You must be signed in to change notification settings - Fork 1
177 lines (154 loc) · 5.99 KB
/
build.yml
File metadata and controls
177 lines (154 loc) · 5.99 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Build and Package SFTPSync
on:
push:
branches:
- master
pull_request:
jobs:
build:
runs-on: windows-latest
env:
Configuration: Release
OutputDir: ${{ github.workspace }}/artifacts
steps:
- name: Checkout source (with full history and submodules)
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup .NET 8 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- name: Install AzureSignTool
run: dotnet tool install --global AzureSignTool
- name: Restore NuGet packages
run: dotnet restore
- name: Build solution
run: dotnet build --configuration Release --no-restore
- name: Publish SFTPSync
run: |
dotnet publish SFTPSync/SFTPSync.csproj `
--configuration Release `
--runtime win-x64 `
--self-contained true `
--output SFTPSync/bin/Release/net8.0-windows `
/p:PublishSingleFile=true `
/p:PublishReadyToRun=true
- name: Publish SFTPSyncStop
run: |
dotnet publish SFTPSyncStop/SFTPSyncStop.csproj `
--configuration Release `
--runtime win-x64 `
--self-contained true `
--output SFTPSyncStop/bin/Release/net8.0-windows `
/p:PublishSingleFile=true `
/p:PublishReadyToRun=true
- name: Publish SFTPSyncUI
run: |
dotnet publish SFTPSyncUI/SFTPSyncUI.csproj `
--configuration Release `
--runtime win-x64 `
--self-contained true `
--output SFTPSyncUI/bin/Release/net8.0-windows `
/p:PublishSingleFile=true `
/p:PublishReadyToRun=true
- name: Sign executables
env:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_APPLICATION_ID: ${{ secrets.AZURE_APPLICATION_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_KEY_VAULT_URL: ${{ secrets.AZURE_KEY_VAULT_URL }}
AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }}
shell: pwsh
run: |
$solutionPath = "SFTPSync.sln"
$projectPaths = @()
$projectMatches = Select-String -Path $solutionPath -Pattern 'Project\(\".*\"\)\s=\s\".*\",\s\"(?<path>[^\"]+\.csproj)\"'
foreach ($match in $projectMatches) {
$projectPaths += $match.Matches[0].Groups["path"].Value
}
$targets = @()
foreach ($projectPath in $projectPaths) {
if (!(Test-Path $projectPath)) {
Write-Host "Project not found: $projectPath"
continue
}
[xml]$projXml = Get-Content $projectPath
$assemblyName = ($projXml.Project.PropertyGroup | Where-Object { $_.AssemblyName } | Select-Object -First 1).AssemblyName
if ([string]::IsNullOrWhiteSpace($assemblyName)) {
$assemblyName = [System.IO.Path]::GetFileNameWithoutExtension($projectPath)
}
$outputType = ($projXml.Project.PropertyGroup | Where-Object { $_.OutputType } | Select-Object -First 1).OutputType
$extension = if ($outputType -in @("Exe", "WinExe")) { ".exe" } else { ".dll" }
$projectDir = Split-Path $projectPath -Parent
$releaseDir = Join-Path $projectDir "bin/Release"
if (!(Test-Path $releaseDir)) {
Write-Host "Release output not found: $releaseDir"
continue
}
$targets += Get-ChildItem -Path $releaseDir -Recurse -Filter "$assemblyName$extension"
}
$targets = $targets | Sort-Object -Property FullName -Unique
foreach ($file in $targets) {
Write-Host "Signing $($file.FullName)"
AzureSignTool sign `
-kvu $env:AZURE_KEY_VAULT_URL `
-kvi $env:AZURE_APPLICATION_ID `
-kvs $env:AZURE_CLIENT_SECRET `
-kvt $env:AZURE_TENANT_ID `
-kvc $env:AZURE_CERT_NAME `
-tr http://timestamp.digicert.com `
-fd sha256 `
-td sha256 `
$file.FullName
}
- name: Add WiX Toolset to PATH
run: echo "C:\Program Files (x86)\WiX Toolset v3.14\bin" >> $env:GITHUB_PATH
- name: Find MSBuild path
id: find-msbuild
run: |
$msbuild = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
if (!(Test-Path $msbuild)) {
$msbuild = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"
}
if (!(Test-Path $msbuild)) {
$msbuild = "${env:ProgramFiles}\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
}
"path=$msbuild" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Build WiX Setup Project
run: |
& "${{ steps.find-msbuild.outputs.path }}" "SFTPSyncSetup\SFTPSyncSetup.wixproj" /p:Configuration=Release
shell: pwsh
- name: Sign MSI
env:
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_APPLICATION_ID: ${{ secrets.AZURE_APPLICATION_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_KEY_VAULT_URL: ${{ secrets.AZURE_KEY_VAULT_URL }}
AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }}
shell: pwsh
run: |
$msiFiles = Get-ChildItem -Path . -Recurse -Include *.msi
foreach ($msi in $msiFiles) {
Write-Host "Signing MSI: $($msi.FullName)"
AzureSignTool sign `
-kvu $env:AZURE_KEY_VAULT_URL `
-kvi $env:AZURE_APPLICATION_ID `
-kvs $env:AZURE_CLIENT_SECRET `
-kvt $env:AZURE_TENANT_ID `
-kvc $env:AZURE_CERT_NAME `
-tr http://timestamp.digicert.com `
-fd sha256 `
-td sha256 `
$msi.FullName
}
- name: Upload MSI artifact
uses: actions/upload-artifact@v4
with:
name: MSI
path: |
**\*.msi