Skip to content

Commit 695a9de

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

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

.github/workflows/Compile.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,42 @@ 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+
$propsContent = Get-Content "source/Directory.Build.props" -Raw
28+
$matches = [regex]::Matches($propsContent, 'Release\s+(R\d+)', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
29+
$versions = @($matches | ForEach-Object { $_.Groups[1].Value.ToUpperInvariant() } | Sort-Object -Unique)
30+
if ($versions.Count -eq 0) {
31+
throw "No Release Rxx configurations found in source/Directory.Build.props"
32+
}
33+
34+
$versionsJson = $versions | ConvertTo-Json -Compress
35+
"versions=$versionsJson" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
36+
1037
compile:
11-
name: Compile
38+
needs: prepare
39+
name: Compile ${{ matrix.version }}
1240
runs-on: windows-2022
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
version: ${{ fromJson(needs.prepare.outputs.versions) }}
1345
steps:
1446
- name: Checkout
1547
uses: actions/checkout@v4
@@ -20,7 +52,7 @@ jobs:
2052
path: |
2153
.nuke/temp
2254
~/.nuget/packages
23-
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
55+
key: ${{ runner.os }}-${{ matrix.version }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
2456

2557
- name: Compile solution
26-
run: ./.nuke/build.cmd
58+
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)