Package and Sign Notepad++ from Winget #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package and Sign Notepad++ from Winget | |
on: | |
workflow_dispatch: | |
jobs: | |
download_and_prepare: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install winget | |
uses: Cyberboss/install-winget@v1 | |
- name: Start Package Inspector to Monitor Changes | |
run: | | |
PackageInspector.exe Start C: | |
shell: powershell | |
- name: Download Notepad++ Installer with Winget | |
id: download_installer | |
run: | | |
$downloadDir = "C:\actions\workspace" | |
$wingetOutput = winget download -e --id Notepad++.Notepad++ --disable-interactivity --accept-source-agreements --download-directory $downloadDir | Out-String | |
Write-Output $wingetOutput | |
if ($wingetOutput -match "Installer downloaded: (.+\.exe)") { | |
$installerPath = $matches[1].Trim() | |
Write-Output "Installer path found: $installerPath" | |
echo "installer_path=$installerPath" | Out-File -FilePath $env:GITHUB_ENV -Append | |
} else { | |
Write-Error "Installer file path not found in winget output." | |
} | |
shell: powershell | |
- name: Parse YAML for Silent Switch | |
id: parse_yaml | |
run: | | |
$yamlFile = Get-ChildItem -Path "C:\actions\workspace" -Filter *.yaml | Select-Object -First 1 | |
if ($yamlFile) { | |
$silentSwitch = "" | |
$lines = Get-Content -Path $yamlFile.FullName | |
foreach ($line in $lines) { | |
if ($line -match "Silent:\s*(.+)") { | |
$silentSwitch = $matches[1].Trim() | |
} | |
} | |
echo "silent_switch=$silentSwitch" | Out-File -FilePath $env:GITHUB_ENV -Append | |
} else { | |
Write-Error "YAML manifest file not found." | |
} | |
shell: powershell | |
- name: Install Notepad++ with Logging | |
run: | | |
Write-Output "Installer Path: $env:installer_path" | |
Write-Output "Silent Switch: $env:silent_switch" | |
$installerPath = "$env:installer_path" | |
$silentSwitch = "$env:silent_switch" | |
$logFile = "C:\actions\workspace\install_log.txt" | |
if ($installerPath -and $silentSwitch) { | |
Start-Process -FilePath $installerPath -ArgumentList "$silentSwitch /LOG=$logFile" -Wait | |
} else { | |
Write-Error "Installer path or silent switch is not set." | |
} | |
shell: powershell | |
- name: Stop Package Inspector and Generate CAT/CDF Files | |
run: | | |
$outputPath = "C:\actions\workspace" | |
$catFileName = Join-Path -Path $outputPath -ChildPath "NPP.cat" | |
$cdfFileName = Join-Path -Path $outputPath -ChildPath "NPP.cdf" | |
PackageInspector.exe Stop C: -Name $catFileName -cdfpath $cdfFileName | |
shell: powershell | |
- name: Download IntuneWinAppUtil.exe | |
run: | | |
New-Item "c:\actions\intune" -ItemType Directory -Force | |
$url = "https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool/raw/refs/heads/master/IntuneWinAppUtil.exe" | |
$downloadPath = "C:\actions\intune\IntuneWinAppUtil.exe" | |
Invoke-WebRequest -Uri $url -OutFile $downloadPath | |
shell: powershell | |
- name: Package Notepad++ win32 app | |
run: | | |
$intuneWinAppUtil = 'C:\actions\intune\IntuneWinAppUtil.exe' | |
$installerPath = "$env:installer_path" | |
$installerName = [System.IO.Path]::GetFileName($installerPath) | |
$IntuneName = $installerName.replace('.exe','.intunewin') | |
$installerIntune = join-path -Path 'c:\actions\workspace' -ChildPath $IntuneName | |
$outputPath = "C:\actions\workspace" | |
# Update GITHUB_ENV with the output file path for later reference | |
echo "installerIntune=$installerIntune" | Out-File -FilePath $env:GITHUB_ENV -Append | |
# Run IntuneWinAppUtil to package the application | |
Start-Process -FilePath $intuneWinAppUtil -ArgumentList "-c $outputPath -s $installerName -o $outputPath" -Wait | |
shell: powershell | |
- name: Debug Variables | |
run: | | |
echo "IntuneName: $env:IntuneName" | |
echo "installer_path: $env:installer_path" | |
echo "installerIntune: $env:installerIntune" | |
shell: powershell | |
- name: Upload CAT File, Intunewin, and Installer to GitHub | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: | | |
C:\actions\workspace\NPP.cat | |
C:\actions\workspace\NPP.cdf | |
${{ env.installerIntune }} | |
${{ env.installer_path }} |