Skip to content

.NET version sweeper #31

.NET version sweeper

.NET version sweeper #31

# 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"
support:
description: "The support level to target (STS, LTS, or Preview)."
required: true
default: "LTS"
permissions:
contents: read
# Run on the latest version of Ubuntu
jobs:
version-sweep:
runs-on: ubuntu-latest
timeout-minutes: 10
# Checkout the repo into the workspace within the VM
steps:
- uses: actions/checkout@v4.2.2
# If triggered manually, print the reason why
- name: "Print manual run reason"
env:
REASON: ${{ github.event.inputs.reason }}
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "Reason: $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/versionsweeper@v4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
owner: ${{ github.repository_owner }}
name: ${{ github.repository }}
branch: ${{ github.ref }}
sdkCompliance: true
- name: Create pull requests
if: steps.dotnet-version-sweeper.outputs.has-remaining-work == 'true'
run: |
upgradeProjects: ${{ steps.dotnet-version-sweeper.outputs.upgrade-projects }}
# Install .NET Upgrade Assistant global tool
dotnet tool install --global upgrade-assistant
# Iterate all upgrade projects
for projectDir in "${upgradeProjects[@]}"; do
echo "Project Directory: $projectDir"
# Create a new branch
git checkout -b upgrade/$projectDir
# Perform the upgrade using upgrade-assistant
upgrade-assistant upgrade "$projectDir" --non-interactive -t ${{ inputs.support }}
# Commit the changes
git add .
git commit -m ".NET Version Sweeper: Upgraded $projectDir"
# Push the branch to the repository
git push origin upgrade/$projectDir
# Create a pull request
gh pr create \
--base main \
--head upgrade/$projectDir \
--title "Upgraded $projectDir" \
--body "Proposed upgrade for $projectDir"
done