Skip to content

Commit b029cc5

Browse files
authored
Merge pull request #814 from hjgraca/chore/update-examples-130
feat(workflows): update .NET version setup to support multiple versions and improve package handling
2 parents 1a8c29c + 743971d commit b029cc5

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

.github/workflows/publish-artifacts-examples-tests.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ jobs:
3232
- name: Setup .NET
3333
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
3434
with:
35-
dotnet-version: '8.x'
35+
dotnet-version: |
36+
6.0.x
37+
8.0.x
3638
3739
- name: Build libraries
3840
run: dotnet build ./libraries/ --configuration Release
@@ -61,7 +63,9 @@ jobs:
6163
- name: Set up .NET
6264
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
6365
with:
64-
dotnet-version: '8.x'
66+
dotnet-version: |
67+
6.0.x
68+
8.0.x
6569
6670
- name: Download packages
6771
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # 4.1.9
@@ -73,6 +77,11 @@ jobs:
7377
run: |
7478
dotnet nuget add source ${{ github.workspace }}/packages --name local
7579
80+
# Ensure we preserve access to NuGet.org
81+
- name: Configure NuGet.org source
82+
run: |
83+
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
84+
7685
- name: Update examples to use local packages
7786
run: |
7887
find ./examples -name "*.csproj" | while read project; do
@@ -81,17 +90,21 @@ jobs:
8190
# Extract package name and version
8291
packageName=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\1/')
8392
packageVersion=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\2/')
84-
85-
# Use xmlstarlet to check and update package references
93+
94+
# Check if project references this package
8695
if grep -q "<PackageReference.*Include=\"$packageName\"" "$project"; then
8796
echo " - Updating $packageName to version $packageVersion"
88-
dotnet add "$project" package "$packageName" --version "$packageVersion" --source ${{ github.workspace }}/packages
97+
# Use --no-restore to avoid restoring during each add
98+
dotnet add "$project" package "$packageName" --version "$packageVersion" --source "local" --no-restore
8999
fi
90100
done
91101
done
92102
103+
- name: Dotnet restore
104+
run: dotnet restore ./examples/
105+
93106
- name: Test Examples
94-
run: dotnet test ./examples/ --configuration Release --verbosity normal
107+
run: dotnet test ./examples/ --no-restore --configuration Release --verbosity normal
95108

96109
publish-packages:
97110
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
@@ -109,7 +122,9 @@ jobs:
109122
- name: Setup .NET
110123
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
111124
with:
112-
dotnet-version: '8.x'
125+
dotnet-version: |
126+
6.0.x
127+
8.0.x
113128
114129
- name: Setup GitHub Packages source
115130
run: |

0 commit comments

Comments
 (0)