Skip to content

Commit f8adb7b

Browse files
committed
update(workflows): enhance CI workflows with concurrency and version handling
1 parent b14f79d commit f8adb7b

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

.github/workflows/Compile.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,56 @@ on:
66
- '*'
77
pull_request:
88

9+
concurrency:
10+
group: ci-build-release-lock
11+
cancel-in-progress: true
12+
913
jobs:
14+
prepare:
15+
name: Prepare compile matrix
16+
runs-on: windows-2022
17+
outputs:
18+
versions: ${{ steps.versions.outputs.versions }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Read versions from Directory.Build.props
24+
id: versions
25+
shell: pwsh
26+
run: |
27+
[xml]$props = Get-Content "source/Directory.Build.props"
28+
$configEntries = @()
29+
foreach ($node in @($props.Project.PropertyGroup.Configurations)) {
30+
if ($null -ne $node -and -not [string]::IsNullOrWhiteSpace($node.InnerText)) {
31+
$configEntries += ($node.InnerText -split ';')
32+
}
33+
}
34+
35+
$versions = @()
36+
foreach ($entry in $configEntries) {
37+
$trimmed = $entry.Trim()
38+
if ($trimmed -match '^Release\s+(R\d+)$') {
39+
$versions += $Matches[1]
40+
}
41+
}
42+
43+
$versions = $versions | Sort-Object -Unique
44+
if ($versions.Count -eq 0) {
45+
throw "No Release Rxx configurations found in source/Directory.Build.props"
46+
}
47+
48+
$versionsJson = $versions | ConvertTo-Json -Compress
49+
"versions=$versionsJson" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
50+
1051
compile:
11-
name: Compile
52+
needs: prepare
53+
name: Compile ${{ matrix.version }}
1254
runs-on: windows-2022
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
version: ${{ fromJson(needs.prepare.outputs.versions) }}
1359
steps:
1460
- name: Checkout
1561
uses: actions/checkout@v4
@@ -20,7 +66,7 @@ jobs:
2066
path: |
2167
.nuke/temp
2268
~/.nuget/packages
23-
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
69+
key: ${{ runner.os }}-${{ matrix.version }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
2470

2571
- name: Compile solution
26-
run: ./.nuke/build.cmd
72+
run: ./.nuke/build.cmd --configurations "Release ${{ matrix.version }}"

.github/workflows/PublishRelease.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
required: true
1212
type: string
1313

14+
concurrency:
15+
group: ci-build-release-lock
16+
cancel-in-progress: true
17+
1418
jobs:
1519
release:
1620
name: Publish release

build/Build.Configuration.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Nuke.Common.Git;
1+
using Nuke.Common.Git;
22
using Nuke.Common.ProjectModel;
33
using Nuke.Common.Tools.Git;
44

@@ -7,6 +7,7 @@ sealed partial class Build
77
/// <summary>
88
/// Patterns of solution configurations for compiling.
99
/// </summary>
10+
[Parameter]
1011
string[] Configurations =
1112
[
1213
"Release*"

0 commit comments

Comments
 (0)