Skip to content

Conversation

martincostello
Copy link
Contributor

Changes

Add support for extracting dotnet-version from actions/setup-dotnet in the GitHub Actions manager.

Context

Renovate does not currently support updating the value specified by dotnet-version with actions/setup-dotnet such as the below:

- uses: actions/setup-dotnet@v4
  with:
    dotnet-version: 8.0.x

These changes should light-up support based on the custom syntax for the .NET SDK version the action supports (which is not the same syntax global.json itself supports).

I'm not sure what the best name for the new versioning strategy should be as it seems specific to the actions/setup-dotnet action. For now I've called it dotnet-sdk and based it on nuget.

Examples

Example updates this PR should enable depending on configuration.

Major update for A

- dotnet-version: 8
+ dotnet-version: 9

Major update for A.x

- dotnet-version: 8.x
+ dotnet-version: 9.x

Major update for A.B

- dotnet-version: 8.0
+ dotnet-version: 9.0

Major update for A.B.x

- dotnet-version: 8.0.x
+ dotnet-version: 9.0.x

Major update for A.B.Cxx

- dotnet-version: 8.0.1xx
+ dotnet-version: 9.0.1xx

Minor update for A.B.Cxx

- dotnet-version: 8.0.1xx
+ dotnet-version: 8.0.4xx

Minor update for A.B.C

- dotnet-version: 8.0.100
+ dotnet-version: 8.0.413

Major update for A.B.C

- dotnet-version: 8.0.100
+ dotnet-version: 9.0.304

Pinning for minor A.B.x

- dotnet-version: 8.0.x
+ dotnet-version: 8.0.413

Minor update for two A.B.C values

 dotnet-version: | 
-    8.0.100
-    9.0.100
+    8.0.413
+    9.0.304

I'm not sure if the last example will work or not - I've updated the manager so that it correctly extracts multiple values, but whether they would be successfully applied to the YAML file is a different question. I couldn't immediately see where to add a test for that scenario.

Documentation

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@martincostello martincostello force-pushed the update-dotnet-version-for-setup-dotnet branch from 6282ca5 to 81406a7 Compare August 7, 2025 14:08
@martincostello martincostello mentioned this pull request Aug 7, 2025
6 tasks
depName: action,
packageName: packageName ?? `actions/${action}-versions`,
versioning,
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$', // Actions release tags are like 1.24.1-13667719799
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be correct, as it doesn't look like it would work for values with an x in.

type: 'dotnet-sdk-floating-range';
major: number;
minor?: number | 'x';
patch?: number | 'x';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example on line 16 does not match the type declared here

Copy link
Contributor Author

@martincostello martincostello Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True - it's mainly being used as a way to round-trip the string into its parts and back again for the A.B.x case when floating is minor.

Line 16 will be 8 0 400 in memory for the floating: 'patch' case.

@martincostello martincostello force-pushed the update-dotnet-version-for-setup-dotnet branch 2 times, most recently from c061318 to fcf411a Compare August 12, 2025 11:28
martincostello and others added 4 commits August 20, 2025 11:57
Add support for extracting `dotnet-version` from `actions/setup-dotnet` in the GitHub Actions manager.
Add some more test cases.
Fix typo in comment.

Co-authored-by: Anne Stellingwerf <[email protected]>
Fix typo in comment.
@martincostello martincostello force-pushed the update-dotnet-version-for-setup-dotnet branch from fcf411a to 94d5cda Compare August 20, 2025 10:57
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually don't review draft PR's

@martincostello martincostello marked this pull request as ready for review September 3, 2025 10:42
@Copilot Copilot AI review requested due to automatic review settings September 3, 2025 10:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for extracting and updating dotnet-version values from the actions/setup-dotnet GitHub Action. It implements a new .NET SDK versioning strategy specifically designed to handle the custom version syntax that actions/setup-dotnet supports.

  • Creates a new dotnet-sdk versioning strategy with full support for .NET SDK version formats
  • Updates the GitHub Actions manager to extract dotnet-version values from actions/setup-dotnet
  • Fixes a spelling error in the existing nuget version module

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
lib/modules/versioning/nuget/version.ts Fixes spelling error in comment
lib/modules/versioning/dotnet-sdk/*.ts New dotnet-sdk versioning module with parser, range handling, and comparison logic
lib/modules/versioning/api.ts Registers the new dotnet-sdk versioning strategy
lib/modules/manager/github-actions/extract.ts Updates GitHub Actions manager to support dotnet-version extraction
lib/modules/manager/github-actions/extract.spec.ts Adds comprehensive tests for dotnet-version extraction
lib/modules/manager/github-actions/readme.md Updates documentation to mention dotnet support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +45 to +46
const xPatch = x.patch ?? 100;
const yPatch = y.patch ?? 100;
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 100 is used as a default patch value without explanation. This should be documented with a comment explaining why 100 is the default patch value for .NET SDK versioning, or extracted to a named constant.

Copilot uses AI. Check for mistakes.

export function versionToString(version: DotnetSdkVersion): string {
let res = `${version.major}`;

res += `.${version.minor ?? 0}`;
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent default values are used: 0 for minor but 100 for patch. These magic numbers should be extracted to named constants to make the relationship clear and ensure consistency across the codebase.

Copilot uses AI. Check for mistakes.


res += `.${version.minor ?? 0}`;

res += `.${version.patch ?? 100}`;
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent default values are used: 0 for minor but 100 for patch. These magic numbers should be extracted to named constants to make the relationship clear and ensure consistency across the codebase.

Copilot uses AI. Check for mistakes.

Comment on lines +14 to +15
minor: minor === 'x' ? 0 : minor,
patch: patch === 'x' ? 100 : patch,
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 100 appears again as the default patch value. This should use the same named constant referenced in the previous comment to maintain consistency.

Copilot uses AI. Check for mistakes.

} else if (r.floating === 'minor') {
return v.major === r.major && (v.minor ?? 0) === (r.minor ?? 0);
} else {
const patch = r.patch === 'x' || !r.patch ? 100 : r.patch;
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another instance of the magic number 100. This reinforces the need for a named constant to represent the default .NET SDK patch value.

Copilot uses AI. Check for mistakes.

} = groups;

if (prerelease) {
res.prerelease = groups.prerelease as `${string}*`;
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type assertion as ${string}`` is incorrect. The prerelease value doesn't necessarily end with '' and this type assertion is misleading. It should be as string or the type should be corrected.

Suggested change
res.prerelease = groups.prerelease as `${string}*`;
res.prerelease = groups.prerelease as string;

Copilot uses AI. Check for mistakes.

Comment on lines +219 to +220
currentValue.split(newlineRegex).forEach((value) => {
if (value) {
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The nested forEach loop with conditional push could be refactored using filter and map for better readability: currentValue.split(newlineRegex).filter(Boolean).map(value => ({ ... })).forEach(dep => deps.push(dep))

Copilot uses AI. Check for mistakes.

@martincostello
Copy link
Contributor Author

I'm not 100% on exactly how to approach this, so feedback/guidance sought. Then I can deal with the Copilot review comments and any other feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants