Skip to content

Commit 5baea9b

Browse files
committed
📃 Add copyright notices to artifacts
1 parent 6284e21 commit 5baea9b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

‎.github/workflows/build.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ jobs:
4141
"-DSOURCELINK=https://raw.githubusercontent.com/${{github.repository}}/${{github.sha}}"
4242
- name: Build
4343
run: cmake --build build --config ${{matrix.kind}} --parallel
44+
- name: Make copyright notice file
45+
shell: pwsh
46+
run: |
47+
.github/workflows/make-copyright-notices-file.ps1 `
48+
-OutputFile build/output/bin/copyright-notices.txt `
49+
-Arch ${{matrix.arch}} `
50+
-BuildDir build
4451
- name: Upload artifacts
4552
if: matrix.kind != 'Debug'
4653
uses: actions/upload-artifact@v6
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
param (
2+
[Parameter(Mandatory=$true)]
3+
[string]$OutputFile,
4+
[Parameter(Mandatory=$true)]
5+
[string]$Arch,
6+
[Parameter(Mandatory=$true)]
7+
[string]$BuildDir
8+
)
9+
10+
$vcpkgRoot = "$BuildDir/vcpkg_installed/$Arch-windows-static/share"
11+
12+
# Use an Ordered dictionary to keep wintab-adapter at the top
13+
$licenses = [ordered]@{
14+
"wintab-adapter" = "LICENSE"
15+
}
16+
17+
if (Test-Path $vcpkgRoot) {
18+
Get-ChildItem -Path $vcpkgRoot -Filter "copyright" -Recurse | ForEach-Object {
19+
$packageName = $_.Directory.Name
20+
$licenses[$packageName] = $_.FullName
21+
}
22+
} else {
23+
Write-Warning "vcpkg share directory not found at: $vcpkgRoot"
24+
}
25+
26+
$parentDir = Split-Path $OutputFile
27+
if ($parentDir -and !(Test-Path $parentDir)) {
28+
New-Item -ItemType Directory -Path $parentDir -Force
29+
}
30+
31+
$first = $true
32+
foreach ($entry in $licenses.GetEnumerator()) {
33+
$header = $entry.Key
34+
$filePath = $entry.Value
35+
36+
if (Test-Path $filePath) {
37+
$content = Get-Content $filePath -Raw
38+
39+
$output = if ($first) { "" } else { "`n`n" }
40+
$output += "$header`n" + ("=" * $header.Length) + "`n`n"
41+
$output += $content
42+
43+
if ($first) {
44+
$output | Out-File -FilePath $OutputFile -Encoding utf8
45+
$first = $false
46+
} else {
47+
$output | Out-File -FilePath $OutputFile -Append -Encoding utf8
48+
}
49+
} else {
50+
Write-Warning "License file not found for $header at $filePath"
51+
}
52+
}

0 commit comments

Comments
 (0)