Skip to content

Commit a0a2986

Browse files
authored
Merge branch 'develop' into main
2 parents 4e6f167 + 1ab1976 commit a0a2986

37 files changed

+1153
-888
lines changed

.github/workflows/GA_Close-Inactive-Issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
issues: write
1414
pull-requests: write
1515
steps:
16-
- uses: actions/stale@v9
16+
- uses: actions/stale@v10
1717
with:
1818
days-before-issue-stale: 30
1919
days-before-issue-close: 14

.github/workflows/GA_Mega-linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
id: ml
4444
# You can override MegaLinter flavor used to have faster performances
4545
# More info at https://megalinter.github.io/flavors/
46-
uses: oxsecurity/megalinter@e08c2b05e3dbc40af4c23f41172ef1e068a7d651 # v8.8.0
46+
uses: oxsecurity/megalinter@62c799d895af9bcbca5eacfebca29d527f125a57 # v9.1.0
4747
env:
4848
# All available variables are described in documentation
4949
# https://megalinter.github.io/configuration/
@@ -90,7 +90,7 @@ jobs:
9090
run: sudo chown -Rc $UID .git/
9191
- name: Commit and push applied linter fixes
9292
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
93-
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
93+
uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3 # v7.0.0
9494
with:
9595
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
9696
commit_message: "[MegaLinter] Apply linters fixes"

.github/workflows/GitFlow_Check-pull-request-source-branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
# Step 2: If the branch pattern is invalid, add a label and comment to the PR
6060
- name: Handle invalid branch (label + comment)
6161
if: failure()
62-
uses: actions/github-script@v7
62+
uses: actions/github-script@v8
6363
with:
6464
github-token: ${{ secrets.GITHUB_TOKEN }}
6565
script: |
@@ -122,7 +122,7 @@ jobs:
122122
# Step 3: If the branch pattern is corrected, remove label and comment
123123
- name: Clean up if branch is corrected
124124
if: success()
125-
uses: actions/github-script@v7
125+
uses: actions/github-script@v8
126126
with:
127127
github-token: ${{ secrets.GITHUB_TOKEN }}
128128
script: |

.github/workflows/GitFlow_Make-Release-and-Sync-to-Dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
122122
# Step 4: Create stable GitHub release with all artifacts
123123
- name: Create release
124-
uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0
124+
uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0
125125
with:
126126
tag: v${{ steps.release_version.outputs.NextSemVer }}
127127
prerelease: false # This is a stable release

.github/workflows/GitFlow_Nightly-builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ jobs:
180180
181181
# Step 6: Create GitHub release with all artifacts
182182
- name: Create release
183-
uses: ncipollo/release-action@bcfe5470707e8832e12347755757cec0eb3c22af # v1.18.0
183+
uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0
184184
if: steps.check_prs.outputs.BUILD_NEEDED == 'true'
185185
with:
186186
tag: v${{ steps.format_version.outputs.NextSemVer }}
Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,84 @@
11
<#
22
.SYNOPSIS
3-
Handle user interaction from shortcuts and show a Toast notification
3+
Handles user-initiated WAU update checks via shortcut.
44
55
.DESCRIPTION
6-
Act on shortcut run
6+
Provides a user-facing interface to manually trigger WAU update checks.
7+
Displays toast notifications for status updates (starting, running,
8+
completed, or error). Waits for the scheduled task to complete and
9+
shows the result.
710
811
.EXAMPLE
9-
.\user-run.ps1
12+
.\User-Run.ps1
1013
14+
.NOTES
15+
Triggered by desktop shortcut or Start menu entry.
16+
Uses the Winget-AutoUpdate scheduled task.
17+
Shows error details from logs\error.txt if update check fails.
1118
#>
1219

20+
# Check if WAU is currently running
1321
function Test-WAUisRunning {
14-
If (((Get-ScheduledTask -TaskName 'Winget-AutoUpdate').State -eq 'Running') -or ((Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext').State -eq 'Running')) {
15-
Return $True
16-
}
22+
If (((Get-ScheduledTask -TaskName 'Winget-AutoUpdate').State -eq 'Running') -or ((Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext').State -eq 'Running')) {
23+
Return $True
24+
}
1725
}
1826

1927
<# MAIN #>
2028

21-
#Get Working Dir
29+
# Set working directory
2230
$Script:WorkingDir = $PSScriptRoot
2331

24-
#Load external functions
32+
# Load required functions
2533
. $WorkingDir\functions\Get-NotifLocale.ps1
2634
. $WorkingDir\functions\Start-NotifTask.ps1
2735

28-
#Get Toast Locale function
36+
# Load notification locale
2937
Get-NotifLocale
3038

31-
#Set common variables
39+
# Set common notification parameters
3240
$OnClickAction = "$WorkingDir\logs\updates.log"
3341
$Button1Text = $NotifLocale.local.outputs.output[11].message
3442

3543
try {
36-
#Check if WAU is currently running
37-
if (Test-WAUisRunning) {
38-
$Message = $NotifLocale.local.outputs.output[8].message
39-
$MessageType = "warning"
40-
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
41-
break
42-
}
43-
#Run scheduled task
44-
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop
45-
#Starting check - Send notification
46-
$Message = $NotifLocale.local.outputs.output[6].message
47-
$MessageType = "info"
48-
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
49-
#Sleep until the task is done
50-
While (Test-WAUisRunning) {
51-
Start-Sleep 3
52-
}
44+
# Check if WAU is already running
45+
if (Test-WAUisRunning) {
46+
$Message = $NotifLocale.local.outputs.output[8].message
47+
$MessageType = "warning"
48+
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
49+
break
50+
}
5351

54-
#Test if there was a list_/winget_error
55-
if (Test-Path "$WorkingDir\logs\error.txt") {
56-
$MessageType = "error"
57-
$Critical = Get-Content "$WorkingDir\logs\error.txt" -Raw
58-
$Critical = $Critical.Trim()
59-
$Critical = $Critical.Substring(0, [Math]::Min($Critical.Length, 50))
60-
$Message = "Critical:`n$Critical..."
61-
}
62-
else {
63-
$MessageType = "success"
64-
$Message = $NotifLocale.local.outputs.output[9].message
65-
}
66-
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
52+
# Start the WAU scheduled task
53+
Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop
54+
55+
# Send "starting" notification
56+
$Message = $NotifLocale.local.outputs.output[6].message
57+
$MessageType = "info"
58+
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
59+
60+
# Wait for task completion
61+
While (Test-WAUisRunning) {
62+
Start-Sleep 3
63+
}
64+
65+
# Check for errors in the update process
66+
if (Test-Path "$WorkingDir\logs\error.txt") {
67+
$MessageType = "error"
68+
$Critical = Get-Content "$WorkingDir\logs\error.txt" -Raw
69+
$Critical = $Critical.Trim()
70+
$Critical = $Critical.Substring(0, [Math]::Min($Critical.Length, 50))
71+
$Message = "Critical:`n$Critical..."
72+
}
73+
else {
74+
$MessageType = "success"
75+
$Message = $NotifLocale.local.outputs.output[9].message
76+
}
77+
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
6778
}
6879
catch {
69-
#Check failed - Just send notification
70-
$Message = $NotifLocale.local.outputs.output[7].message
71-
$MessageType = "error"
72-
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
80+
# Handle task start failure
81+
$Message = $NotifLocale.local.outputs.output[7].message
82+
$MessageType = "error"
83+
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
7384
}
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1-
#Send Notify Script
1+
<#
2+
.SYNOPSIS
3+
Displays a toast notification to the logged-in user.
24
3-
#get xml notif config
5+
.DESCRIPTION
6+
Reads notification configuration from an XML file and displays
7+
a Windows toast notification using the ToastNotificationManager API.
8+
This script is called by a scheduled task when WAU runs in system context.
9+
10+
.NOTES
11+
Configuration file: config\notif.xml
12+
Launcher ID: Windows.SystemToast.WAU.Notification
13+
#>
14+
15+
# Get WAU installation path from registry
416
$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation
17+
18+
# Load notification XML configuration
519
[xml]$NotifConf = Get-Content "$WAUinstalledPath\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
620
if (!($NotifConf)) {
721
break
822
}
923

10-
#Load Assemblies
24+
# Load Windows notification assemblies
1125
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
1226
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
1327

14-
#Prepare XML
28+
# Parse notification XML
1529
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
1630
$ToastXml.LoadXml($NotifConf.OuterXml)
1731

18-
#Specify Launcher App ID
32+
# Specify toast launcher ID
1933
$LauncherID = "Windows.SystemToast.WAU.Notification"
2034

21-
#Prepare and Create Toast
35+
# Create and display the notification
2236
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
2337
$ToastMessage.Tag = $NotifConf.toast.tag
2438
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($LauncherID).Show($ToastMessage)

Sources/Winget-AutoUpdate/WAU-Policies.ps1

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
11
<#
22
.SYNOPSIS
3-
Handle GPO/Polices
3+
Applies Group Policy settings to WAU scheduled tasks.
44
55
.DESCRIPTION
6-
Daily update settings from policies
6+
Reads WAU configuration from GPO registry keys and updates the
7+
Winget-AutoUpdate scheduled task triggers accordingly.
8+
Handles daily, bi-daily, weekly, bi-weekly, and monthly schedules,
9+
as well as logon triggers and time delays.
10+
11+
.NOTES
12+
This script is executed by the WAU-Policies scheduled task.
13+
GPO registry path: HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate
14+
Logs applied settings to: logs\LatestAppliedSettings.txt
715
#>
816

9-
#Import functions
17+
# Import configuration function
1018
. "$PSScriptRoot\functions\Get-WAUConfig.ps1"
1119

12-
#Check if GPO Management is detected
20+
# Check if GPO management is enabled
1321
$GPOManagementDetected = Get-ItemProperty "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue
1422

1523
if ($GPOManagementDetected) {
1624

17-
#Get WAU settings
25+
# Load WAU configuration (with GPO overrides)
1826
$WAUConfig = Get-WAUConfig
1927

20-
#Log init
28+
# Initialize logging
2129
$GPOLogDirectory = Join-Path -Path $WAUConfig.InstallLocation -ChildPath "logs"
2230
if (!(Test-Path -Path $GPOLogDirectory)) {
2331
New-Item -ItemType Directory -Path $GPOLogDirectory -Force | Out-Null
2432
}
2533
$GPOLogFile = Join-Path -Path $GPOLogDirectory -ChildPath "LatestAppliedSettings.txt"
2634
Set-Content -Path $GPOLogFile -Value "### POLICY CYCLE - $(Get-Date) ###`n"
2735

28-
#Get Winget-AutoUpdate scheduled task
36+
# Get current scheduled task configuration
2937
$WAUTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate' -ErrorAction SilentlyContinue
30-
31-
#Update 'Winget-AutoUpdate' scheduled task settings
3238
$currentTriggers = $WAUTask.Triggers
3339
$configChanged = $false
3440

35-
#Check if LogOn trigger setting has changed
41+
# === Check if LogOn trigger setting has changed ===
3642
$hasLogonTrigger = $currentTriggers | Where-Object { $_.CimClass.CimClassName -eq "MSFT_TaskLogonTrigger" }
3743
if (($WAUConfig.WAU_UpdatesAtLogon -eq 1 -and -not $hasLogonTrigger) -or
3844
($WAUConfig.WAU_UpdatesAtLogon -ne 1 -and $hasLogonTrigger)) {
3945
$configChanged = $true
4046
}
4147

42-
#Check if schedule type has changed
48+
# === Detect current schedule type ===
4349
$currentIntervalType = "None"
4450
foreach ($trigger in $currentTriggers) {
4551
if ($trigger.CimClass.CimClassName -eq "MSFT_TaskDailyTrigger" -and $trigger.DaysInterval -eq 1) {
@@ -72,7 +78,7 @@ if ($GPOManagementDetected) {
7278
$configChanged = $true
7379
}
7480

75-
#Check if delay has changed
81+
# === Check if delay has changed ===
7682
$randomDelay = [TimeSpan]::ParseExact($WAUConfig.WAU_UpdatesTimeDelay, "hh\:mm", $null)
7783
$timeTrigger = $currentTriggers | Where-Object { $_.CimClass.CimClassName -ne "MSFT_TaskLogonTrigger" } | Select-Object -First 1
7884
if ($timeTrigger.RandomDelay -match '^PT(?:(\d+)H)?(?:(\d+)M)?$') {
@@ -84,7 +90,7 @@ if ($GPOManagementDetected) {
8490
$configChanged = $true
8591
}
8692

87-
#Check if schedule time has changed
93+
# === Check if schedule time has changed ===
8894
if ($currentIntervalType -ne "None" -and $currentIntervalType -ne "Never") {
8995
if ($timeTrigger) {
9096
$currentTime = [DateTime]::Parse($timeTrigger.StartBoundary).ToString("HH:mm:ss")
@@ -94,12 +100,16 @@ if ($GPOManagementDetected) {
94100
}
95101
}
96102

97-
#Only update triggers if configuration has changed
103+
# === Update triggers if configuration changed ===
98104
if ($configChanged) {
99105
$taskTriggers = @()
106+
107+
# Add logon trigger if enabled
100108
if ($WAUConfig.WAU_UpdatesAtLogon -eq 1) {
101109
$tasktriggers += New-ScheduledTaskTrigger -AtLogOn
102110
}
111+
112+
# Add time-based trigger based on interval type
103113
if ($WAUConfig.WAU_UpdatesInterval -eq "Daily") {
104114
$tasktriggers += New-ScheduledTaskTrigger -Daily -At $WAUConfig.WAU_UpdatesAtTime -RandomDelay $randomDelay
105115
}
@@ -116,20 +126,18 @@ if ($GPOManagementDetected) {
116126
$tasktriggers += New-ScheduledTaskTrigger -Weekly -At $WAUConfig.WAU_UpdatesAtTime -DaysOfWeek 2 -WeeksInterval 4 -RandomDelay $randomDelay
117127
}
118128

119-
#If trigger(s) set
129+
# Apply new triggers or disable task
120130
if ($taskTriggers) {
121-
#Edit scheduled task
122131
Set-ScheduledTask -TaskPath $WAUTask.TaskPath -TaskName $WAUTask.TaskName -Trigger $taskTriggers | Out-Null
123132
}
124-
#If not, remove trigger(s)
125133
else {
126-
#Remove by setting past due date
134+
# Disable by setting a past due date
127135
$tasktriggers = New-ScheduledTaskTrigger -Once -At "01/01/1970"
128136
Set-ScheduledTask -TaskPath $WAUTask.TaskPath -TaskName $WAUTask.TaskName -Trigger $tasktriggers | Out-Null
129137
}
130138
}
131139

132-
#Log latest applied config
140+
# Log applied configuration
133141
Add-Content -Path $GPOLogFile -Value "`nLatest applied settings:"
134142
$WAUConfig.PSObject.Properties | Where-Object { $_.Name -like "WAU_*" } | Select-Object Name, Value | Out-File -Encoding default -FilePath $GPOLogFile -Append
135143

0 commit comments

Comments
 (0)