GitHub Action
.NET version sweeper
The .NET version sweeper is designed to alert repositories that there are projects targeting versions that are no longer supported. For example, projects targeting .NET Core 3.0, or .NET Framework 4.5.1 would trigger an issue to be created to update these non-LTS or current versions. For example issues, see issues created in this repo based on the non-lts directory.
This is intended to be used as a GitHub action that will run as a scheduled CRON job. Ideally, once a month or as often as necessary to align with .NET version updates.
A schedule/cron job that runs on the first of every month is detailed below in the example workflow, '0 0 1 * *'
.
Option | Details |
---|---|
-o , owner |
The owner of the repo. Assign from ${{ github.repository_owner }} . Example, "dotnet" . |
-n , name |
The repository name. Assign from ${{ github.repository }} . Example, "dotnet/samples" . |
-b , branch |
The branch name. Assign from ${{ github.ref }} . Example, "main" . |
-t , token |
The GitHub personal-access token (PAT), or the token from GitHub action context. Assign from ${{ github.token }} . |
Option | Details |
---|---|
-d , dir |
The root directory, defaults to "/github/workspace" . |
-p , pattern |
The search pattern, defaults to "*.csproj;*.fsproj;*.vbproj;*.xproj;project.json" . |
-s , sdk-compliance |
Whether or not to report projects that are not using the new SDK-style project format. |
# The name used in the GitHub UI for the workflow
name: '.net version sweeper'
# When to run this action:
# - Scheduled on the first of every month
# - Manually runable from the GitHub UI with a reason
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: true
default: 'Manual run'
# Run on the latest version of Ubuntu
jobs:
version-sweep:
runs-on: ubuntu-latest
permissions:
issues: write
statuses: write
# Checkout the repo into the workspace within the VM
steps:
- uses: actions/checkout@v2
# If triggered manually, print the reason why
- name: 'Print manual run reason'
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "Reason: ${{ github.event.inputs.reason }}"
# Run the .NET version sweeper
# Issues will be automatically created for any non-ignored projects that are targeting non-LTS versions
- name: .NET version sweeper
id: dotnet-version-sweeper
uses: dotnet/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
owner: ${{ github.repository_owner }}
name: ${{ github.repository }}
branch: ${{ github.ref }}
sdkCompliance: true
The .NET version sweeper currently supports reporting on all of the following types:
- C# project files:
*.csproj
- F# project files:
*.fsproj
- VB project files:
*.vbproj
- DNX project files:
*.xproj
- Project JSON files:
project.json
- Solution files:
*.sln
To configure the action, you can create a file at the root of the repository named dotnet-versionsweeper.json. This config file contains a node, named "ignore"
that is an array of patterns following the globbing matcher detailed here.
{
"ignore": [
"**/SomePath/**/*.csproj",
"**/*ThisShouldNeverBeFlagged.csproj",
"IgnoreDir/**/*.*"
]
}
For an example config file, see dotnet/samples/dotnet-versionsweeper.json.
This tool will create a label named dotnet-target-version
for easier tracking of issues and pull requests that it creates. The label is created with the following description and color by default, please do not change the name - as that is what is used to determine whether or not to create a new label.
Description
: "Issues and PRs automatically generated from the .NET version sweeper."Color
: Official .NET purple #512bd4
This repo serves as a sample, as it contains a directory non-lts with projects and solutions that are intentionally targeting unsupported versions. There are issues created against these to exemplify how they render. For more information, see these issues.
This action is intended to help determine non-LTS (or current) versions, but it is not perfect. When in doubt, please refer to the official .NET support policies.
Name | NuGet package URL & license |
---|---|
CommandLineParser |
https://www.nuget.org/packages/CommandLineParser (MIT) |
MarkdownBuilder |
https://www.nuget.org/packages/MarkdownBuilder (MIT) |
NSubstitute |
https://www.nuget.org/packages/NSubstitute (LICENSE) |
Octokit |
https://www.nuget.org/packages/Octokit (MIT) |
Octokit.Extensions |
https://www.nuget.org/packages/Octokit.Extensions (MIT) |