-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (113 loc) · 4.71 KB
/
Copy pathrelease.yml
File metadata and controls
133 lines (113 loc) · 4.71 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
name: Release All
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v1.2.6)'
required: true
releaseName:
description: 'Release title (defaults to tag)'
required: false
frameworks:
description: 'Optional TFM filter (comma/space separated), e.g. "netstandard2.0, net9.0"'
required: false
attachNupkg:
description: 'Attach .nupkg/.snupkg to the Release (no push to registries)'
type: boolean
required: true
default: true
permissions:
contents: write
jobs:
release-all:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET SDKs (6/7/8/9/10)
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
10.0.x
- name: Cache NuGet
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.sln*', '**/*.csproj') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Restore solution
run: dotnet restore OutWit.slnx
- name: Build solution (all TFM)
run: dotnet build OutWit.slnx -c Release -p:ContinuousIntegrationBuild=true --no-restore
- name: Pack solution (no build)
run: dotnet pack OutWit.slnx -c Release --no-build
- name: Collect all packages
shell: pwsh
run: |
if (!(Test-Path "NuGet")) { New-Item -ItemType Directory -Force -Path "NuGet" | Out-Null }
Get-ChildItem -Recurse -Include *.nupkg,*.snupkg -Path . |
Where-Object { $_.FullName -match "\\bin\\Release\\" } |
Copy-Item -Destination "NuGet" -Force
Write-Host "Collected packages:"; Get-ChildItem NuGet | Select-Object Name
- name: Gather per-project & per-TFM build outputs
id: gather
shell: pwsh
run: |
$solutionRoot = (Get-Location).Path
$outRoot = "out/release"
if (Test-Path $outRoot) { Remove-Item -Recurse -Force $outRoot }
$projects = Get-ChildItem -Recurse -Filter *.csproj |
Where-Object { $_.Name -notmatch '\.Tests\.csproj$' } |
Sort-Object FullName
$tfmFilter = "${{ github.event.inputs.frameworks }}"
$wanted = @()
if ($tfmFilter) { $wanted = $tfmFilter -split '[,;\s]+' | Where-Object { $_ } }
$copied = 0
foreach ($proj in $projects) {
$projDir = Split-Path $proj.FullName -Parent
$projName = [System.IO.Path]::GetFileNameWithoutExtension($proj.Name)
$releaseDir = Join-Path $projDir "bin/Release"
if (-not (Test-Path $releaseDir)) { continue }
$tfms = Get-ChildItem -Path $releaseDir -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match '^net(standard)?\d+(\.\d+)?$' } |
Select-Object -ExpandProperty Name
if ($wanted.Count -gt 0) {
$tfms = $tfms | Where-Object { $wanted -contains $_ }
}
foreach ($tfm in $tfms) {
$src = Join-Path $releaseDir $tfm
if (-not (Test-Path $src)) { continue }
$dst = Join-Path $outRoot $projName $tfm
New-Item -ItemType Directory -Force -Path $dst | Out-Null
Copy-Item -Recurse -Force -Path (Join-Path $src '*') -Destination $dst
$copied++
Write-Host "Copied $projName / $tfm"
}
}
if ($copied -eq 0) { Write-Error "No build outputs found in bin/Release for any project/TFM."; exit 1 }
"copied=$copied" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
- name: Create one zip with all projects/TFM
id: zipit
shell: pwsh
run: |
$tag = "${{ github.event.inputs.tag }}"
$zip = "OutWit.Common-$tag.zip"
if (Test-Path $zip) { Remove-Item $zip -Force }
Compress-Archive -Path (Join-Path "out/release" '*') -DestinationPath $zip -Force
"zip=$zip" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
Write-Host "Created $zip"
- name: Create GitHub Release and upload assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.tag }}
name: ${{ github.event.inputs.releaseName || github.event.inputs.tag }}
draft: false
prerelease: false
files: |
${{ steps.zipit.outputs.zip }}
${{ github.event.inputs.attachNupkg == 'true' && 'NuGet/*.nupkg' || '' }}
${{ github.event.inputs.attachNupkg == 'true' && 'NuGet/*.snupkg' || '' }}