Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(workflows): update .NET version setup to support multiple versions and improve package handling #814

Merged
merged 2 commits into from
Mar 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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