Nightly Workflow
Overview
The Nightly workflow automatically creates and publishes bleeding-edge builds from the alpha branch on a daily schedule. It includes intelligent change detection to skip builds when no changes have occurred, and features kill switch controls for emergency disabling.
Purpose
- Automated Nightly Builds: Provides latest development builds without manual intervention
- Change Detection: Only builds when code has changed in the last 24 hours
- Bleeding-Edge Testing: Enables early testing of new features and fixes
- NuGet Publishing: Automatically publishes packages to nuget.org
- Community Notifications: Announces releases via Discord
Trigger Conditions
Scheduled
- Cron:
0 0 * * *(midnight UTC every day) - Time Zone: UTC
- Frequency: Once per day
Manual
workflow_dispatch: Can be manually triggered from Actions tab- Use Case: Testing workflow changes or forcing a build
Workflow Structure
Job: nightly
Runner: windows-latest
Environment: production (requires approval before publishing)
Concurrency:
- Group:
nightly-alpha - Cancel In-Progress:
true - Prevents multiple nightly builds from running simultaneously
Steps Overview
- Kill Switch Check - Verifies if workflow is disabled
- Security Verification - Validates repository and branch
- Checkout - Checks out
alphabranch - Change Detection - Checks for commits in last 24 hours
- Skip Notification - Notifies if no changes found
- Setup .NET - Installs .NET SDKs
- Setup .NET 11 - Attempts to install .NET 11 (optional)
- Force .NET 10 SDK - Creates
global.json - Setup MSBuild - Configures MSBuild
- Setup NuGet - Configures NuGet
- Cache NuGet - Caches packages
- Restore - Restores dependencies
- Build Nightly - Builds the solution
- Pack Nightly - Creates NuGet packages
- Push NuGet Packages - Publishes to nuget.org
- Get Version - Extracts version information
- Announce on Discord - Sends notification
Detailed Behavior
Kill Switch
Variable: NIGHTLY_DISABLED
Location: Repository Settings → Secrets and variables → Actions → Variables
Values:
true- Disables workflow (all steps skipped after check)falseor unset - Enables workflow
Use Cases:
- Emergency disabling of automated builds
- Maintenance periods
- Preventing duplicate releases
Implementation:
$disabled = '${{ vars.NIGHTLY_DISABLED }}'
if ($disabled -eq 'true') {
echo "enabled=false" >> $env:GITHUB_OUTPUT
}
All subsequent steps check: if: steps.nightly_release_kill_switch.outputs.enabled == 'true'
Security Verification
Repository Check
Validates that workflow only runs on the correct repository:
if ($env:GITHUB_REPOSITORY -ne 'Krypton-Suite/Standard-Toolkit') {
Write-Error "Security: Invalid repository"
exit 1
}
Branch Check
Verifies workflow is running from an authorized branch:
$allowedRefs = @('refs/heads/alpha', 'refs/heads/master', 'refs/heads/main')
if ($env:GITHUB_REF -notin $allowedRefs) {
Write-Error "Security: Unauthorized branch"
exit 1
}
Note: Workflow checks out alpha branch regardless of trigger source.
Change Detection
Purpose: Skips build if no commits in last 24 hours
Implementation:
$yesterday = (Get-Date).AddDays(-1).ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss")
$commitCount = git rev-list --count --since="$yesterday" alpha
Logic:
- Counts commits on
alphabranch since 24 hours ago - If count > 0: proceeds with build
- If count = 0: skips build and logs notice
Benefits:
- Saves CI minutes
- Prevents duplicate packages
- Reduces noise in notifications
.NET SDK Setup
Versions Installed:
- .NET 9.0.x
- .NET 10.0.x
- .NET 11.0.x
global.json Generation:
- Prefers .NET 11 SDK
- Falls back to .NET 10 if .NET 11 unavailable
- Uses
rollForward: latestFeature
Build Process
Project File: Scripts/Build/nightly.proj
Configuration: Nightly
Platform: Any CPU
Targets:
Build- Compiles solutionPack- Creates NuGet packages
Output Location: Bin/Packages/Nightly/
NuGet Publishing
Process:
- Scans for
.nupkgfiles inBin/Packages/Nightly/ - Pushes each package to nuget.org
- Uses
--skip-duplicateflag to handle existing packages - Tracks if any packages were actually published
Package Detection:
$packages = Get-ChildItem "Bin/Packages/Nightly/*.nupkg"
Publishing Logic:
- Checks output for "already exists" or "was not pushed"
- Only marks as published if package was new
- Continues with remaining packages on individual failures
Required Secret: NUGET_API_KEY
Output Variable: packages_published (true/false)
Version Extraction
Methods (in order of preference):
Assembly Version (Primary)
$dllPath = Get-ChildItem "Bin/Nightly/net48/Krypton.Toolkit.dll" $assemblyVersion = [System.Reflection.AssemblyName]::GetAssemblyName($dllPath.FullName).VersionProject File (Fallback)
[xml]$projXml = Get-Content "Source/Krypton Components/Krypton.Toolkit/Krypton.Toolkit.csproj" $versionNode = $projXml.SelectSingleNode("//Version")Hardcoded Fallback
- Version:
100.25.1.1 - Tag:
v100.25.1.1-nightly
- Version:
Output Variables:
version- Version number (e.g.,100.25.1.1)tag- Git tag format (e.g.,v100.25.1.1-nightly)
Discord Notification
Trigger: Only if packages were published (packages_published == 'True')
Required Secret: DISCORD_WEBHOOK_NIGHTLY
Message Content:
- Title: "🚀 Krypton Toolkit Nightly Release"
- Version information
- NuGet package links
- Target frameworks list
- Changelog link
Color: 10181046 (purple/blue)
Packages Listed:
- Krypton.Toolkit.Nightly
- Krypton.Ribbon.Nightly
- Krypton.Navigator.Nightly
- Krypton.Workspace.Nightly
- Krypton.Docking.Nightly
- Krypton.Standard.Toolkit.Nightly
Configuration
Required Secrets
NUGET_API_KEY: API key for nuget.org publishing- Get from: https://www.nuget.org/account/apikeys
- Requires "Push" permission
DISCORD_WEBHOOK_NIGHTLY: Discord webhook URL for notifications- Create in Discord server settings
- Optional (workflow continues if not set)
Required Variables
NIGHTLY_DISABLED: Kill switch variable- Set to
trueto disable workflow - Set to
falseor leave unset to enable
- Set to
Required Environments
production: Protected environment- Requires approval before publishing
- Prevents accidental releases
- Configure in repository settings
Troubleshooting
Workflow Not Running
Possible Causes:
- Kill switch enabled (
NIGHTLY_DISABLED=true) - No changes in last 24 hours (expected behavior)
- Schedule not configured correctly
- Workflow file syntax errors
Solutions:
- Check variable
NIGHTLY_DISABLEDin repository settings - Verify commits exist on
alphabranch - Review workflow schedule syntax
- Check Actions tab for errors
Build Skipped Due to No Changes
Expected Behavior: This is intentional
Reason: Saves resources when no new code exists
Solution: Make a commit to alpha branch or manually trigger workflow
NuGet Publishing Failed
Possible Causes:
- Missing or invalid
NUGET_API_KEY - Package version already exists
- Network issues
- Invalid package format
Solutions:
- Verify API key is set and valid
- Check if package version already exists (this is handled gracefully)
- Review NuGet push logs
- Verify package files are valid
Discord Notification Not Sent
Possible Causes:
- No packages were published (expected if duplicates)
- Missing
DISCORD_WEBHOOK_NIGHTLYsecret - Webhook URL invalid
- Discord API issues
Solutions:
- Check
packages_publishedoutput in logs - Verify webhook secret is set
- Test webhook URL manually
- Check Discord server settings
Version Extraction Failed
Behavior: Uses fallback version 100.25.1.1
Solutions:
- Verify build completed successfully
- Check if DLL exists at expected path
- Review version extraction logs
- Ensure project file has
<Version>element
.NET 11 Setup Failed
Expected Behavior: This is normal if .NET 11 is not yet available
Solution: Workflow continues with .NET 10 (this is intentional)
Related Workflows
- Build Workflow: Similar build process for CI
- Release Workflow: Similar publishing process for stable releases
Code Reference
File: .github/workflows/nightly.yml
Key Components:
- Event:
scheduleandworkflow_dispatch - Environment:
production - Concurrency:
nightly-alphagroup - Kill Switch:
NIGHTLY_DISABLEDvariable
Maintenance Notes
Updating Schedule
To change the build schedule:
schedule:
- cron: '0 0 * * *' # Change cron expression
Common Schedules:
0 0 * * *- Daily at midnight UTC0 */6 * * *- Every 6 hours0 0 * * 1- Weekly on Monday
Modifying Change Detection Window
To change the 24-hour window:
$yesterday = (Get-Date).AddHours(-24).AddDays(-1) # Change hours
Adding New Packages
If new NuGet packages are added:
- Update Discord notification message
- Verify package paths in publishing step
- Test package creation in build step
Kill Switch Management
To Disable:
- Go to Repository Settings → Secrets and variables → Actions
- Add/Edit variable:
NIGHTLY_DISABLED=true - Save
To Re-enable:
- Set
NIGHTLY_DISABLED=false - Or delete the variable
Best Practices
- Monitor Builds: Check Actions tab regularly for failures
- Version Management: Ensure version numbers increment correctly
- Change Detection: Let the workflow skip when appropriate
- Kill Switch: Use for maintenance or emergency stops
- Notifications: Keep Discord webhook updated
- Security: Never commit secrets or API keys
Workflow Flow Diagram
Schedule Trigger (00:00 UTC)
│
├─> Kill Switch Check
│ └─> If disabled: Exit
│
├─> Security Verification
│ ├─> Repository Check
│ └─> Branch Check
│
├─> Checkout alpha Branch
│
├─> Change Detection (24h)
│ └─> If no changes: Skip & Exit
│
├─> Setup .NET SDKs (9, 10, 11)
│
├─> Setup Build Tools (MSBuild, NuGet)
│
├─> Restore & Build
│
├─> Pack NuGet Packages
│
├─> Publish to nuget.org
│ └─> If published: Continue
│ └─> If skipped: Exit (no notification)
│
├─> Extract Version
│
└─> Discord Notification (if published)