Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
166 changes: 166 additions & 0 deletions lib/modules/manager/github-actions/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,20 @@ describe('modules/manager/github-actions/extract', () => {
jobs:
build:
steps:
- name: "Setup .NET"
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: "Setup .NET with exact version"
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.303'
- name: "Setup .NET with multiple versions"
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
9.0.x
- name: "Setup Node.js"
uses: actions/setup-node@v3
with:
Expand All @@ -609,6 +623,39 @@ describe('modules/manager/github-actions/extract', () => {

const res = extractPackageFile(yamlContent, 'workflow.yml');
expect(res?.deps).toMatchObject([
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
commitMessageTopic: '{{{depName}}} action',
currentValue: 'v3',
datasource: 'github-tags',
depName: 'actions/setup-dotnet',
depType: 'action',
replaceString: 'actions/setup-dotnet@v3',
versioning: 'docker',
},
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
commitMessageTopic: '{{{depName}}} action',
currentValue: 'v3',
datasource: 'github-tags',
depName: 'actions/setup-dotnet',
depType: 'action',
replaceString: 'actions/setup-dotnet@v3',
versioning: 'docker',
},
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
commitMessageTopic: '{{{depName}}} action',
currentValue: 'v3',
datasource: 'github-tags',
depName: 'actions/setup-dotnet',
depType: 'action',
replaceString: 'actions/setup-dotnet@v3',
versioning: 'docker',
},
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
Expand Down Expand Up @@ -664,6 +711,42 @@ describe('modules/manager/github-actions/extract', () => {
replaceString: 'actions/setup-node@v3',
versioning: 'docker',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '8.0.x',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '9.0.303',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '8.0.x',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '9.0.x',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'node',
packageName: 'actions/node-versions',
Expand Down Expand Up @@ -717,6 +800,20 @@ describe('modules/manager/github-actions/extract', () => {
runs:
using: 'composite'
steps:
- name: "Setup .NET"
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: "Setup .NET with exact version"
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.303'
- name: "Setup .NET with multiple versions"
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
9.0.x
- name: "Setup Node.js"
uses: actions/setup-node@v3
with:
Expand All @@ -741,6 +838,39 @@ describe('modules/manager/github-actions/extract', () => {

const res = extractPackageFile(yamlContent, 'action.yml');
expect(res?.deps).toMatchObject([
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
commitMessageTopic: '{{{depName}}} action',
currentValue: 'v3',
datasource: 'github-tags',
depName: 'actions/setup-dotnet',
depType: 'action',
replaceString: 'actions/setup-dotnet@v3',
versioning: 'docker',
},
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
commitMessageTopic: '{{{depName}}} action',
currentValue: 'v3',
datasource: 'github-tags',
depName: 'actions/setup-dotnet',
depType: 'action',
replaceString: 'actions/setup-dotnet@v3',
versioning: 'docker',
},
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
commitMessageTopic: '{{{depName}}} action',
currentValue: 'v3',
datasource: 'github-tags',
depName: 'actions/setup-dotnet',
depType: 'action',
replaceString: 'actions/setup-dotnet@v3',
versioning: 'docker',
},
{
autoReplaceStringTemplate:
'{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}',
Expand Down Expand Up @@ -796,6 +926,42 @@ describe('modules/manager/github-actions/extract', () => {
replaceString: 'actions/setup-node@v3',
versioning: 'docker',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '8.0.x',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '9.0.303',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '8.0.x',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'dotnet',
packageName: 'dotnet-sdk',
currentValue: '9.0.x',
datasource: 'dotnet-version',
versioning: 'dotnet-sdk',
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$',
depType: 'uses-with',
},
{
depName: 'node',
packageName: 'actions/node-versions',
Expand Down
47 changes: 33 additions & 14 deletions lib/modules/manager/github-actions/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { GlobalConfig } from '../../../config/global';
import { logger, withMeta } from '../../../logger';
import { detectPlatform } from '../../../util/common';
import { newlineRegex, regEx } from '../../../util/regex';
import { DotnetVersionDatasource } from '../../datasource/dotnet-version';
import { ForgejoTagsDatasource } from '../../datasource/forgejo-tags';
import { GiteaTagsDatasource } from '../../datasource/gitea-tags';
import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { GithubRunnersDatasource } from '../../datasource/github-runners';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import * as dockerVersioning from '../../versioning/docker';
import * as dotnetSdkVersioning from '../../versioning/dotnet-sdk';
import * as nodeVersioning from '../../versioning/node';
import * as npmVersioning from '../../versioning/npm';
import { getDep } from '../dockerfile/extract';
Expand Down Expand Up @@ -175,12 +177,22 @@ function extractRunner(runner: string): PackageDependency | null {
return dependency;
}

const versionedActions: Record<string, string> = {
go: npmVersioning.id,
node: nodeVersioning.id,
python: npmVersioning.id,
interface VersionedAction {
versioning: string;
datasource?: string;
packageName?: string;
}

const versionedActions: Record<string, VersionedAction> = {
dotnet: {
versioning: dotnetSdkVersioning.id,
datasource: DotnetVersionDatasource.id,
packageName: 'dotnet-sdk',
},
go: { versioning: npmVersioning.id },
node: { versioning: nodeVersioning.id },
python: { versioning: npmVersioning.id },
// Not covered yet because they use different datasources/packageNames:
// - dotnet
// - java
};

Expand All @@ -195,20 +207,27 @@ function extractSteps(
continue;
}

for (const [action, versioning] of Object.entries(versionedActions)) {
for (const [
action,
{ versioning, datasource, packageName },
] of Object.entries(versionedActions)) {
const actionName = `actions/setup-${action}`;
if (step.uses === actionName || step.uses?.startsWith(`${actionName}@`)) {
const fieldName = `${action}-version`;
const currentValue = step.with?.[fieldName];
if (currentValue) {
deps.push({
datasource: GithubReleasesDatasource.id,
depName: action,
packageName: `actions/${action}-versions`,
versioning,
extractVersion: '^(?<version>\\d+\\.\\d+\\.\\d+)(-\\d+)?$', // Actions release tags are like 1.24.1-13667719799
currentValue,
depType: 'uses-with',
currentValue.split(newlineRegex).forEach((value) => {
if (value) {
Comment on lines +219 to +220
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.

deps.push({
datasource: datasource ?? GithubReleasesDatasource.id,
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.

Copy link
Member

Choose a reason for hiding this comment

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

use for-of loop

currentValue: value,
depType: 'uses-with',
});
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/github-actions/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ This means that Renovate will:

### with:version support for built-in Actions

Renovate supports updating the "with" version for `actions/setup-go`, `actions/setup-node`, and `actions/setup-python`, although not all syntaxes are supported out of the box.
Renovate supports updating the "with" version for `actions/setup-dotnet`, `actions/setup-go`, `actions/setup-node`, and `actions/setup-python`, although not all syntaxes are supported out of the box.

By default, Renovate will use `npm`-style semver versioning for `go` and `python`, and Renovate's built-in `node` versioning for updating `node`.
The goal of these defaults is to match as closely as possible to what these GitHub Actions support.
Expand Down
2 changes: 2 additions & 0 deletions lib/modules/versioning/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as deb from './deb';
import * as debian from './debian';
import * as devbox from './devbox';
import * as docker from './docker';
import * as dotnetSdk from './dotnet-sdk';
import * as git from './git';
import * as glasskube from './glasskube';
import * as goModDirective from './go-mod-directive';
Expand Down Expand Up @@ -61,6 +62,7 @@ api.set(deb.id, deb.api);
api.set(debian.id, debian.api);
api.set(devbox.id, devbox.api);
api.set(docker.id, docker.api);
api.set(dotnetSdk.id, dotnetSdk.api);
api.set(git.id, git.api);
api.set(glasskube.id, glasskube.api);
api.set(goModDirective.id, goModDirective.api);
Expand Down
Loading