This repository contains reusable GitHub Actions workflows and PowerShell tools for the Zonit organization. These workflows can be called from any repository in the organization to standardize CI/CD processes.
🚀 Quick Start: Use our setup script to configure a new repository in seconds!
File: .github/workflows/reusable-update-nugets.yml
Automatically updates NuGet packages to their latest compatible versions within the same major version.
name: Update NuGet Packages
on:
schedule:
- cron: '0 2 * * 1' # Every Monday at 2 AM
workflow_dispatch: # Manual trigger
jobs:
update-nugets:
uses: Zonit/.github/.github/workflows/reusable-update-nugets.yml@main
permissions:
contents: write
pull-requests: write
with:
root-dir: '.' # Optional, defaults to '.'- ✅ Updates packages in
Directory.Packages.propsand conditional.csprojreferences - ✅ Maintains major version compatibility
- ✅ Creates a pull request with detailed change log
- ✅ Automatically adds
automated-tasklabel
File: .github/workflows/reusable-publish-nuget.yml
Builds, packs, and publishes NuGet packages to nuget.org.
name: Publish NuGet Package
on:
push:
tags:
- 'v*' # Triggers on version tags like v1.0.0
jobs:
publish:
uses: Zonit/.github/.github/workflows/reusable-publish-nuget.yml@main
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
with:
source_directory: 'Source' # Optional, defaults to 'Source'- ✅ Auto-detects required .NET SDK versions (.NET 6, 7, 8, 9, 10)
- ✅ Multi-targeting support
- ✅ Builds and publishes all projects in the source directory
- ✅ Publishes both packages (.nupkg) and symbols (.snupkg)
NUGET_API_KEY- Your nuget.org API key
File: .github/workflows/reusable-check-nuget-and-publish.yml
Compares local package versions with published versions on nuget.org and triggers publish if local is newer.
name: Check and Publish NuGet
on:
push:
branches:
- main
workflow_dispatch:
jobs:
check-publish:
uses: Zonit/.github/.github/workflows/reusable-check-nuget-and-publish.yml@main
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}- ✅ Scans all
.csprojfiles inSourcedirectory - ✅ Compares versions with nuget.org
- ✅ Triggers publish workflow only when needed
File: .github/workflows/reusable-update-dotnet-version.yml
Updates .NET framework version across all project files in the repository.
name: Update .NET Version
on:
workflow_dispatch:
inputs:
from-version:
description: 'Current .NET version'
required: true
default: '9.0'
to-version:
description: 'Target .NET version'
required: true
default: '10.0'
jobs:
update-dotnet:
uses: Zonit/.github/.github/workflows/reusable-update-dotnet-version.yml@main
permissions:
contents: write
pull-requests: write
with:
from-version: ${{ github.event.inputs.from-version }}
to-version: ${{ github.event.inputs.to-version }}
create-pr: true # Optional, defaults to true- ✅ Updates
<TargetFramework>and<TargetFrameworks> - ✅ Updates conditional package references
- ✅ Updates
global.jsonSDK version - ✅ Creates detailed PR with all changes
- ✅ Handles multi-targeting scenarios
File: .github/workflows/reusable-update-dotnet-with-packages.yml
NEW SYSTEM: Intelligently updates .NET framework version(s) AND automatically updates all NuGet packages to latest compatible versions using conditional package management.
name: Update .NET Framework
on:
workflow_dispatch:
inputs:
target-frameworks:
description: 'Target frameworks (e.g., "net9.0" or "net8.0,net9.0" for multi-targeting)'
required: true
default: 'net9.0'
jobs:
update:
uses: Zonit/.github/.github/workflows/reusable-update-dotnet-with-packages.yml@main
permissions:
contents: write
pull-requests: write
with:
target-frameworks: ${{ github.event.inputs.target-frameworks }}- ✅ Smart .NET Detection - Automatically detects if repository contains .NET projects
- ✅ Multi-Targeting Support - Single framework or multiple (e.g., net8.0,net9.0)
- ✅ Conditional Package Management - Creates separate ItemGroups per framework version
- ✅ Latest Compatible Versions - Fetches the latest NuGet version compatible with each framework
- ✅ Central Package Management - Uses Directory.Packages.props with conditions
- ✅ Automatic PR Creation - Creates detailed PR for manual verification
- ✅ Modular Design - Reusable PowerShell modules for future scheduled updates
Input: net9.0
Creates:
<!-- Directory.Packages.props -->
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
</ItemGroup>Input: net8.0,net9.0
Creates:
<!-- Directory.Packages.props -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
</ItemGroup>📖 For complete documentation, see: .NET Update System Guide
These tools are downloaded and executed by the workflows, but can also be run locally.
NEW SYSTEM: Updates .NET framework version(s), ensures Directory.Packages.props exists, and updates all package versions to latest.
# Download and run locally
curl -fsSL https://raw.githubusercontent.com/Zonit/.github/refs/heads/master/tools/update-dotnet-simple.ps1 -o update-dotnet.ps1
# Single framework
pwsh ./update-dotnet.ps1 -TargetFrameworks @("net9.0")
# Multi-targeting
pwsh ./update-dotnet.ps1 -TargetFrameworks @("net8.0", "net9.0")Features:
- ✅ Updates target frameworks in .csproj files
- ✅ Creates Directory.Packages.props if missing (preserves existing)
- ✅ Adds missing packages from projects to Directory.Packages.props
- ✅ NEW: Automatically updates all package versions to latest compatible versions
- ✅ Removes package versions from individual projects (Central Package Management)
- ✅ Framework-aware version selection (e.g., 9.x.x for net9.0, 8.x.x for net8.0)
- ✅ SAFE: Never overwrites existing Directory.Packages.props structure
How it works (8 steps):
- Detect .NET projects
- Scan for project files
- Update target frameworks in .csproj
- Remove package versions from projects (enables CPM)
- Collect all package references
- Fetch latest versions for each framework
- Create or verify Directory.Packages.props (no overwriting!)
- Add missing packages + update all versions to latest
NEW: Standalone tool to update package versions in existing Directory.Packages.props files without changing frameworks.
# Download and run locally
curl -fsSL https://raw.githubusercontent.com/Zonit/.github/refs/heads/master/tools/update-package-versions.ps1 -o update-packages.ps1
# Update packages
pwsh ./update-packages.ps1
# Dry run (preview changes without applying)
pwsh ./update-packages.ps1 -WhatIfUse Cases:
- 🔄 Scheduled package updates without framework changes
- 🔍 Preview what would be updated (WhatIf mode)
- 🎯 Quick security updates
- 📦 Maintenance updates for existing projects
Features:
- ✅ Updates all packages in Directory.Packages.props
- ✅ Framework-aware: updates net8.0 packages to 8.x.x, net9.0 to 9.x.x, etc.
- ✅ Handles conditional and unconditional ItemGroups
- ✅ Rate-limited NuGet API queries
- ✅ Detailed progress and summary reporting
To use these workflows in your repository, simply reference them in your workflow files. See Example Workflows for ready-to-use templates.
Create .github/workflows/maintenance.yml in your repository:
name: Maintenance
on:
schedule:
- cron: '0 2 * * 1' # Weekly updates
workflow_dispatch:
jobs:
update-packages:
uses: Zonit/.github/.github/workflows/reusable-update-nugets.yml@master
permissions:
contents: write
pull-requests: write
update-dotnet:
uses: Zonit/.github/.github/workflows/reusable-update-dotnet-version.yml@master
permissions:
contents: write
pull-requests: write
with:
from-version: '9.0'
to-version: '10.0'
if: github.event_name == 'workflow_dispatch' # Only on manual triggerFor organization-wide updates, see Organization-Wide Update Guide.
- Create workflow file in your repository at
.github/workflows/maintenance.yml:
name: Maintenance
on:
schedule:
- cron: '0 2 * * 1' # Weekly NuGet updates
workflow_dispatch:
jobs:
update-nugets:
uses: Zonit/.github/.github/workflows/reusable-update-nugets.yml@main
permissions:
contents: write
pull-requests: write
update-dotnet:
uses: Zonit/.github/.github/workflows/reusable-update-dotnet-version.yml@main
permissions:
contents: write
pull-requests: write
with:
from-version: '9.0'
to-version: '10.0'
if: github.event_name == 'workflow_dispatch' # Only on manual trigger-
Add secrets to your repository:
NUGET_API_KEY(if publishing packages)
-
Test the workflow:
- Go to Actions tab in your repository
- Find "Maintenance" workflow
- Click "Run workflow"
- README.md - This file, overview of all workflows and tools
- Example Workflows - Copy-paste ready workflow examples
- Organization-Wide Update Guide - Complete guide for updating all repos at once
- Package Update System - NEW: Detailed guide for automated package version updates
- How to update NuGet packages
- How to publish NuGet packages
- How to update .NET version
- How to update package versions only
- Example workflows for your repository
- Quick setup for new repositories
This repository is maintained by Zonit organization.
For issues or questions:
- Open an issue in this repository
- Contact the DevOps team
Track the status of automated workflows across repositories:
| Workflow | Purpose | Frequency |
|---|---|---|
| Update NuGet | Keep packages up to date | Weekly |
| Publish NuGet | Release packages | On version tags |
| Check & Publish | Auto-publish new versions | On main push |
| Update .NET | Upgrade framework versions | Manual/On-demand |
Last Updated: 2024 Maintained by: Zonit DevOps Team