Skip to content

Commit 08c7077

Browse files
committed
Move dotnet setup to composite action
Also introduces a repo custom property we can set to request a different set of dotnet versions easily without having to modify the workflow itself, making it more future-proof. For now, since --allow-downgrade used by the sleet step requires .NET 9.x to be explicitly setup to get latest, this will run always on all our repos since we set the DOTNET prop to `9.x` by default. When dotnet 10 ships, this will likely not be needed anymore and we'll remove it.
1 parent db918f0 commit 08c7077

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

.github/actions/dotnet/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: ⚙ dotnet
2+
description: Configures dotnet if the repo/org defines the DOTNET custom property
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: 🔎 dotnet
8+
id: dotnet
9+
shell: bash
10+
run: |
11+
VERSIONS=$(gh api /repos/${{ github.repository }}/properties/values | jq -r '.[] | select(.property_name == "DOTNET") | .value')
12+
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
13+
14+
- name: ⚙ dotnet
15+
if: steps.dotnet.outputs.versions != ''
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: ${{ steps.dotnet.outputs.versions }}

.github/workflows/build.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ jobs:
6666
fetch-depth: 0
6767

6868
- name: ⚙ dotnet
69-
uses: actions/setup-dotnet@v4
70-
with:
71-
dotnet-version: |
72-
6.x
73-
8.x
74-
9.x
69+
uses: ./.github/actions/dotnet
7570

7671
- name: 🙏 build
7772
run: dotnet build -m:1 -bl:build.binlog

.github/workflows/publish.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ jobs:
2828
fetch-depth: 0
2929

3030
- name: ⚙ dotnet
31-
uses: actions/setup-dotnet@v4
32-
with:
33-
dotnet-version: |
34-
6.x
35-
8.x
36-
9.x
31+
uses: ./.github/actions/dotnet
3732

3833
- name: 🙏 build
3934
run: dotnet build -m:1 -bl:build.binlog

0 commit comments

Comments
 (0)