Skip to content

Commit

Permalink
Merge pull request #814 from hjgraca/chore/update-examples-130
Browse files Browse the repository at this point in the history
feat(workflows): update .NET version setup to support multiple versions and improve package handling
  • Loading branch information
hjgraca authored Mar 7, 2025
2 parents 1a8c29c + 743971d commit b029cc5
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/publish-artifacts-examples-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
with:
dotnet-version: '8.x'
dotnet-version: |
6.0.x
8.0.x
- name: Build libraries
run: dotnet build ./libraries/ --configuration Release
Expand Down Expand Up @@ -61,7 +63,9 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
with:
dotnet-version: '8.x'
dotnet-version: |
6.0.x
8.0.x
- name: Download packages
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # 4.1.9
Expand All @@ -73,6 +77,11 @@ jobs:
run: |
dotnet nuget add source ${{ github.workspace }}/packages --name local
# Ensure we preserve access to NuGet.org
- name: Configure NuGet.org source
run: |
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
- name: Update examples to use local packages
run: |
find ./examples -name "*.csproj" | while read project; do
Expand All @@ -81,17 +90,21 @@ jobs:
# Extract package name and version
packageName=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\1/')
packageVersion=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\2/')
# Use xmlstarlet to check and update package references
# Check if project references this package
if grep -q "<PackageReference.*Include=\"$packageName\"" "$project"; then
echo " - Updating $packageName to version $packageVersion"
dotnet add "$project" package "$packageName" --version "$packageVersion" --source ${{ github.workspace }}/packages
# Use --no-restore to avoid restoring during each add
dotnet add "$project" package "$packageName" --version "$packageVersion" --source "local" --no-restore
fi
done
done
- name: Dotnet restore
run: dotnet restore ./examples/

- name: Test Examples
run: dotnet test ./examples/ --configuration Release --verbosity normal
run: dotnet test ./examples/ --no-restore --configuration Release --verbosity normal

publish-packages:
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
Expand All @@ -109,7 +122,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
with:
dotnet-version: '8.x'
dotnet-version: |
6.0.x
8.0.x
- name: Setup GitHub Packages source
run: |
Expand Down

0 comments on commit b029cc5

Please sign in to comment.