Skip to content

Commit d3287dd

Browse files
authored
Support for more runtime versions (#6)
* Fix workflows (cherry picked from commit 5c3f4ea) * Try to fix extract licenses (cherry picked from commit ca41de7) * Try again * and again * Added mor runtime targets * Added more runtime targets
1 parent 2c65ca5 commit d3287dd

File tree

4 files changed

+101
-26
lines changed

4 files changed

+101
-26
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 'Collect NuGet Licenses'
2+
description: 'Generates a Markdown file containing license information for used NuGet packages.'
3+
author: 'maintainers'
4+
inputs:
5+
project:
6+
description: 'Path to the project file (.csproj) or solution (.sln)'
7+
required: true
8+
output-file:
9+
description: 'Output file for the license list'
10+
required: false
11+
default: 'licenses.md'
12+
nuget-license-version:
13+
description: 'Version of the nuget-license tool'
14+
required: false
15+
default: '4.0.0'
16+
outputs:
17+
license_file:
18+
description: 'Path to the generated license file'
19+
runs:
20+
using: 'composite'
21+
steps:
22+
- name: Ensure .NET SDK is available
23+
shell: bash
24+
run: |
25+
if ! command -v dotnet >/dev/null 2>&1; then
26+
echo 'Dotnet SDK not found. Please run actions/setup-dotnet earlier in the workflow.' >&2
27+
exit 1
28+
fi
29+
- name: Install nuget-license tool
30+
shell: bash
31+
run: |
32+
set -euo pipefail
33+
TOOL_PATH=".tools"
34+
mkdir -p "$TOOL_PATH"
35+
VERSION="${{ inputs.nuget-license-version }}"
36+
dotnet tool install --tool-path "$TOOL_PATH" nuget-license --version "$VERSION" \
37+
|| dotnet tool update --tool-path "$TOOL_PATH" nuget-license --version "$VERSION"
38+
- name: Generate license file
39+
id: gen
40+
shell: bash
41+
run: |
42+
set -euo pipefail
43+
EXE=".tools/nuget-license"
44+
if [ ! -x "$EXE" ] && [ -f ".tools/nuget-license.exe" ]; then EXE=".tools/nuget-license.exe"; fi
45+
if [ ! -f "$EXE" ]; then echo 'nuget-license tool not found' >&2; exit 1; fi
46+
PROJECT="${{ inputs.project }}"
47+
OUT_FILE="${{ inputs.output-file }}"
48+
echo "Starting license collection for $PROJECT -> $OUT_FILE"
49+
set +e
50+
"$EXE" -i "$PROJECT" -fo "$OUT_FILE" -o Markdown
51+
EXIT_CODE=$?
52+
set -e
53+
if [ ! -f "$OUT_FILE" ]; then echo 'License file was not generated' >&2; exit 1; fi
54+
if [ $EXIT_CODE -ne 0 ]; then
55+
echo "Warning: nuget-license exited with code $EXIT_CODE (possibly missing license info)." >&2
56+
fi
57+
echo "license_file=$OUT_FILE" >> "$GITHUB_OUTPUT"
58+
echo "Licenses collected at $OUT_FILE"

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name: CI
2+
3+
permissions:
4+
contents: read
25

36
on:
47
pull_request:

.github/workflows/release.yml

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Release
22

33
on:
4-
workflow_dispatch: {}
54
push:
65
tags:
76
- 'v*'
@@ -22,33 +21,43 @@ jobs:
2221
steps:
2322
- name: Checkout
2423
uses: actions/checkout@v4
24+
- name: Ensure tag commit is on main
25+
shell: bash
26+
run: |
27+
set -euo pipefail
28+
git fetch origin main --quiet
29+
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
30+
echo "Tag commit is not part of main. Aborting." >&2
31+
exit 1
32+
fi
33+
echo "Tag commit is on main."
2534
- name: Validate tag and set version
2635
id: set_version
2736
shell: bash
2837
run: |
2938
set -euo pipefail
3039
if [[ "${GITHUB_REF}" != refs/tags/v* ]]; then
31-
echo "Error: Workflow muss durch einen Tag 'v*' gestartet werden." >&2
40+
echo "Error: Workflow must be triggered by a tag 'v*'." >&2
3241
exit 1
3342
fi
3443
ver="${GITHUB_REF#refs/tags/v}"
35-
echo "Release-Version: $ver"
44+
echo "Release version: $ver"
3645
echo "release_version=$ver" >> "$GITHUB_OUTPUT"
37-
- name: Show previous tag diff (informativ)
46+
- name: Show previous tag diff (informational)
3847
shell: bash
3948
run: |
4049
git fetch --tags --quiet
4150
current="${GITHUB_REF#refs/tags/}"
42-
prev=$(git tag --sort=-creatordate | grep -v "^${current}$" | head -n1 || true)
51+
prev=$(git tag --sort=-creatordate | grep -v "^${current}$" | head -n1 || true)
4352
if [[ -z "$prev" ]]; then
44-
echo "Erster Release-Tag (kein vorheriger Tag gefunden)."
53+
echo "First release tag (no previous tag found)."
4554
exit 0
4655
fi
4756
diffCount=$(git diff --name-only "$prev" "$current" | wc -l | tr -d ' ')
4857
if [[ "$diffCount" == "0" ]]; then
49-
echo "Warnung: Keine Änderungen zwischen $prev und $current." >&2
58+
echo "Warning: No changes between $prev and $current." >&2
5059
else
51-
echo "Geänderte Dateien seit $prev: $diffCount"
60+
echo "Changed files since $prev: $diffCount"
5261
fi
5362
5463
build_and_package:
@@ -60,6 +69,16 @@ jobs:
6069
include:
6170
- os: windows-latest
6271
rid: win-x86
72+
- os: windows-latest
73+
rid: win-x64
74+
- os: ubuntu-latest
75+
rid: linux-x64
76+
- os: ubuntu-latest
77+
rid: linux-arm64
78+
- os: macos-13
79+
rid: osx-x64
80+
- os: macos-latest
81+
rid: osx-arm64
6382
steps:
6483
- name: Checkout
6584
uses: actions/checkout@v4
@@ -84,20 +103,12 @@ jobs:
84103
$outDir = Join-Path $workspace (Join-Path 'publish' $rid)
85104
Write-Host "Publishing for $rid (ReleaseVersion=${{ needs.version.outputs.release_version }})"
86105
dotnet publish MailAgent/MailAgent.csproj -c Release -r $rid /p:PublishSingleFile=true /p:PublishTrimmed=false /p:SelfContained=true -o $outDir
87-
# - name: Collect licenses
88-
# shell: pwsh
89-
# run: |
90-
# $workspace='${{ github.workspace }}'
91-
# $toolPath = Join-Path $workspace '.tools'
92-
# if (-Not (Test-Path $toolPath)) { New-Item -ItemType Directory -Path $toolPath | Out-Null }
93-
# dotnet tool install --tool-path $toolPath nuget-license --version 4.0.0 || dotnet tool update --tool-path $toolPath nuget-license --version 4.0.0
94-
# $exe = Join-Path $toolPath 'nuget-license.exe'
95-
# if (-Not (Test-Path $exe)) { $exe = Join-Path $toolPath 'nuget-license' }
96-
# if (-Not (Test-Path $exe)) { Write-Error "nuget-license not found at $toolPath"; exit 1 }
97-
# $outFile = Join-Path $toolPath 'licenses.md'
98-
# & $exe -i MailAgent/MailAgent.csproj -fo $outFile -o Markdown
99-
# if (-Not (Test-Path $outFile)) { Write-Error "License file not generated"; exit 1 }
100-
# Write-Host "Licenses collected at $outFile"
106+
- name: Collect licenses
107+
id: collect_licenses
108+
uses: ./.github/actions/collect-licenses
109+
with:
110+
project: MailAgent/MailAgent.csproj
111+
output-file: licenses.md
101112
- name: Prepare artifact folder
102113
shell: pwsh
103114
run: |
@@ -114,8 +125,9 @@ jobs:
114125
Copy-Item -Path (Join-Path $publishDir '*') -Destination $artifactDir -Recurse -Force
115126
$extras = @('MailAgent/readme.md','MailAgent/install.bat','MailAgent/uninstall.bat')
116127
foreach ($e in $extras) { $full = Join-Path $workspace $e; if (Test-Path $full) { Copy-Item -Path $full -Destination $artifactDir -Force } }
117-
# $toolLic = Join-Path $workspace '.tools/licenses.md'
118-
# if (Test-Path $toolLic) { Copy-Item -Path $toolLic -Destination (Join-Path $artifactDir 'licenses.md') -Force }
128+
# Copy collected license file (composite action output)
129+
$licenseFile = Join-Path $workspace 'licenses.md'
130+
if (Test-Path $licenseFile) { Copy-Item -Path $licenseFile -Destination (Join-Path $artifactDir 'licenses.md') -Force }
119131
- name: Create ZIP package
120132
shell: pwsh
121133
run: |
@@ -191,7 +203,7 @@ jobs:
191203
log=$(git log "$prev".."$currentCommit" --pretty=format:'* %h %s' | head -n200)
192204
if [[ -z "$log" ]]; then notes="No commit differences from $prev."; else notes="Changes since $prev:\n$log"; fi
193205
fi
194-
safe=$(echo "$notes" | sed ':a;N;$!ba;s/\r//g' | sed 's/$/%0A/'); safe=${safe%"%0A"}
206+
safe=$(echo "$notes" | sed ':a;N;$!ba;s/\r//g' | sed 's/$/%0A/'); safe=${safe%%%0A}
195207
echo "changelog=$safe" >> $GITHUB_OUTPUT
196208
- name: Create release
197209
env:

MailAgent/MailAgent.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
1717
<Version>2.2.3</Version>
1818
<UserSecretsId>8eae55bd-49a1-4a01-953b-c7fe16dd357b</UserSecretsId>
19-
<PlatformTarget>x86</PlatformTarget>
19+
<Platforms>AnyCPU;x86;x64</Platforms>
20+
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
2021
<LangVersion>latestmajor</LangVersion>
2122
<AssemblyVersion>3.0.0</AssemblyVersion>
2223
<FileVersion>3.0.0</FileVersion>
@@ -80,6 +81,7 @@
8081
</None>
8182
<None Remove="Properties\PublishProfiles\FolderProfile.pubxml" />
8283
<None Remove="obj\**" />
84+
<None Remove="publish_multi\**" />
8385
</ItemGroup>
8486

8587
<ItemGroup>

0 commit comments

Comments
 (0)