From 8e864b17a24ed50493196f47f8d64107de42516a Mon Sep 17 00:00:00 2001 From: Goswin Rothenthal Date: Sat, 15 Feb 2025 23:00:32 +0100 Subject: [PATCH] use dotnet outdated --- .github/dependabot.yml | 23 +++--- .github/workflows/build.yml | 2 +- .github/workflows/outdatedNuget.yml | 112 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 2 +- Fesh.Rhino.fsproj | 1 + 5 files changed, 126 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/outdatedNuget.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 19f89b3..f3a545f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,17 +6,16 @@ updates: schedule: interval: "weekly" - # Update to newer NuGet dependencies - - package-ecosystem: "nuget" - directory: "/" - schedule: - interval: "daily" - ignore: - # keep at Rhino 7 - - dependency-name: "RhinoCommon" +# don't do nuget here, WPF does not build correctly on linux +# to work on FSharp.Core too the fsproj needs : true +# and Actions -> General -> Workflow Permissions: +# 'Read and write permissions' and +# 'Allow Github Actions to create and approve pull requests' + +# for FSharp.Core to be updated use +# true +# and the 'Include' instead of the 'Update' syntax: +# + +on: + # Allows you to run this workflow manually from the Actions tab in Github.com + workflow_dispatch: + + schedule: + - cron: '0 0 * * *' # Runs daily at midnight UTC + # - cron: '0 * * * *' # Runs every hour for testing + # - cron: '*/6 * * * *' # Runs every 6 minutes for testing + + # push: cannot trigger a pull request , see https://github.com/peter-evans/create-pull-request/tree/v7/?tab=readme-ov-file#token + +permissions: # https://github.com/peter-evans/create-pull-request/tree/v7/?tab=readme-ov-file#token + contents: write + pull-requests: write + +jobs: + nuget-update: + runs-on: windows-latest # so that WPF build works too + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.x' # Specify the .NET version you are using + + - name: Restore NuGet packages + run: dotnet restore + + - name: Install dotnet-outdated + run: dotnet tool install -g dotnet-outdated-tool + + - name: Simulate Update NuGet packages to get JSON output + run: dotnet outdated --output outdated.json --exclude RhinoCommon + + - name: Parse JSON and concatenate unique versions + shell: pwsh + run: | + if (Test-Path 'outdated.json') { + $json = Get-Content 'outdated.json' | ConvertFrom-Json + $uniqueDeps = @{} + foreach ($project in $json.Projects) { + foreach ($framework in $project.TargetFrameworks) { + foreach ($dep in $framework.Dependencies) { + if (-not $uniqueDeps.ContainsKey($dep.Name)) { + $uniqueDeps[$dep.Name] = "$($dep.Name) to $($dep.LatestVersion) (from $($dep.ResolvedVersion))" + } + } + } + } + $result = $uniqueDeps.Values + $concatenated = "Bump " + ($result -join '; ') + echo "COMMIT_MSG=$concatenated" >> $env:GITHUB_ENV + Remove-Item -Path outdated.json -Force + } + else { + echo 'No outdated.json file found' + echo "COMMIT_MSG=" >> $env:GITHUB_ENV + } + + - name: Update NuGet packages and get Markdown output + # if no updates are available, no output.json file is created + if: ${{env.COMMIT_MSG }} + run: dotnet outdated --upgrade --output outdated.md --output-format Markdown --exclude RhinoCommon + + + - name: Read outdated.md file + if: ${{env.COMMIT_MSG }} + id: read-md + uses: juliangruber/read-file-action@v1 + with: + path: ./outdated.md + + - name: Delete outdated.md file + if: ${{env.COMMIT_MSG }} + shell: pwsh + run: Remove-Item -Path outdated.md -Force + + # This will not create a duplicate PR if one exists already + - name: Create Pull Request + if: ${{env.COMMIT_MSG }} + uses: peter-evans/create-pull-request@v7 + with: + commit-message: ${{ env.COMMIT_MSG }} + committer: github-actions[bot] + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> + branch: dotnet-outdated-bot + delete-branch: true + title: ${{ env.COMMIT_MSG }} + body: ${{ steps.read-md.outputs.content }} + labels: "dotnet-outdated" + + + + + + + + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 372b975..e11f257 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: '9.0.x' + dotnet-version: '9.x' - name: Build run: dotnet build --configuration Release diff --git a/Fesh.Rhino.fsproj b/Fesh.Rhino.fsproj index 2da109d..9c576c5 100644 --- a/Fesh.Rhino.fsproj +++ b/Fesh.Rhino.fsproj @@ -15,6 +15,7 @@ targeting net 7 actually fails to find the System.Drawing.Bitmap reference during build even if System.Drawing.Common is included. using net48 target on net7 will not allow async evaluation. --> + preview en en