Compare commits

..

No commits in common. "508f909fc9d3326bceb7eb5d6ce243b9aa840c0d" and "5d3d47eeb5c667466bcc4ca82d504b6d959c9391" have entirely different histories.

8 changed files with 58 additions and 65 deletions

View File

@ -1,9 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "actions/stale"
versions: '>= 9'

View File

@ -11,7 +11,7 @@ jobs:
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Get all releases and update update.mb file - name: Get all releases and update update.mb file
run: | run: |

View File

@ -10,11 +10,11 @@ jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:
python-version: 3.x python-version: 3.x
- uses: actions/cache@v4 - uses: actions/cache@v2
with: with:
key: ${{ github.ref }} key: ${{ github.ref }}
path: .cache path: .cache

View File

@ -1,12 +1,8 @@
name: Pre-Release WinUtil name: Pre-Release WinUtil
permissions:
contents: write
actions: read
on: on:
workflow_run: workflow_run:
workflows: ["Compile"] workflows: ["Compile"] #Ensure Compile winget.ps1 is done
types: types:
- completed - completed
workflow_dispatch: # Manual trigger added workflow_dispatch: # Manual trigger added
@ -14,6 +10,8 @@ on:
jobs: jobs:
build-runspace: build-runspace:
runs-on: windows-latest runs-on: windows-latest
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -21,19 +19,17 @@ jobs:
- name: Extract Version from winutil.ps1 - name: Extract Version from winutil.ps1
id: extract_version id: extract_version
run: | run: |
$version = (Get-Date -Format "yy.MM.dd") $version = ''
echo "version=$version" >> $env:GITHUB_ENV Get-Content ./winutil.ps1 -TotalCount 30 | ForEach-Object {
shell: pwsh if ($_ -match 'Version\s*:\s*(\d{2}\.\d{2}\.\d{2})') {
$version = "pre"+$matches[1]
- name: Create Tag echo "version=$version" >> $GITHUB_OUTPUT
id: create_tag break
run: | }
$tagExists = git tag -l $env:VERSION }
if ($tagExists -eq "") { if (-not $version) {
git tag $env:VERSION Write-Error "Version not found in winutil.ps1"
git push origin $env:VERSION exit 1
} else {
Write-Host "Tag $env:VERSION already exists, skipping tag creation"
} }
shell: pwsh shell: pwsh
@ -41,9 +37,9 @@ jobs:
id: create_release id: create_release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
tag_name: ${{ env.VERSION }} tag_name: ${{ steps.extract_version.outputs.version }}
name: Pre-Release ${{ env.VERSION }} name: Pre-Release ${{ steps.extract_version.outputs.version }}
body: "![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/winutil/${{ env.VERSION }}/winutil.ps1)" body: "![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/winutil/${{ steps.extract_version.outputs.version }}/winutil.ps1)"
append_body: false append_body: false
files: ./winutil.ps1 files: ./winutil.ps1
prerelease: true prerelease: true

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout 🛎️ - name: Checkout 🛎️
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Generate Sponsors 💖 - name: Generate Sponsors 💖
uses: JamesIves/github-sponsors-readme-action@v1 uses: JamesIves/github-sponsors-readme-action@v1

View File

@ -8,7 +8,7 @@ jobs:
name: PS Script Analyzer name: PS Script Analyzer
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v2
- name: lint - name: lint
uses: devblackops/github-action-psscriptanalyzer@master uses: devblackops/github-action-psscriptanalyzer@master
with: with:
@ -22,7 +22,7 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Install Pester - name: Install Pester
run: | run: |

View File

@ -22,17 +22,18 @@ Function Install-WinUtilProgramWinget {
[Parameter(Position=1)] [Parameter(Position=1)]
[String]$manage = "Installing" [String]$manage = "Installing"
) )
$x = 0
$count = $ProgramsToInstall.Count $count = $ProgramsToInstall.Count
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0 Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Configuring winget packages ---" Write-Host "-- Configuring winget packages ---"
Write-Host "===========================================" Write-Host "==========================================="
Foreach ($Program in $ProgramsToInstall){ for ($i = 0; $i -le $ProgramsToInstall.Count; $i++) {
$Program = $ProgramsToInstall[$i]
$failedPackages = @() $failedPackages = @()
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($x + 1) of $count" -PercentComplete $($x/$count*100) Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($i + 1) of $count" -PercentComplete $(($i/$count) * 100)
if($manage -eq "Installing"){ if($manage -eq "Installing") {
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt. # Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
# Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround. # Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround.
# Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode. # Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode.
@ -40,21 +41,21 @@ Function Install-WinUtilProgramWinget {
Write-Host "Starting install of $($Program.winget) with winget." Write-Host "Starting install of $($Program.winget) with winget."
try { try {
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode $status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
if($status -eq 0){ if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully." Write-Host "$($Program.winget) installed successfully."
continue continue
} }
if ($status -eq -1978335189){ if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found" Write-Host "$($Program.winget) No applicable update found"
continue continue
} }
Write-Host "Attempt with User scope" Write-Host "Attempt with User scope"
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode $status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
if($status -eq 0){ if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully with User scope." Write-Host "$($Program.winget) installed successfully with User scope."
continue continue
} }
if ($status -eq -1978335189){ if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found" Write-Host "$($Program.winget) No applicable update found"
continue continue
} }
@ -68,11 +69,11 @@ Function Install-WinUtilProgramWinget {
} else { } else {
Write-Host "Skipping installation with specific user credentials." Write-Host "Skipping installation with specific user credentials."
} }
if($status -eq 0){ if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully with User prompt." Write-Host "$($Program.winget) installed successfully with User prompt."
continue continue
} }
if ($status -eq -1978335189){ if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found" Write-Host "$($Program.winget) No applicable update found"
continue continue
} }
@ -81,11 +82,11 @@ Function Install-WinUtilProgramWinget {
$failedPackages += $Program $failedPackages += $Program
} }
} }
if($manage -eq "Uninstalling"){ elseif($manage -eq "Uninstalling") {
# Uninstall package via ID using winget directly. # Uninstall package via ID using winget directly.
try { try {
$status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode $status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode
if($status -ne 0){ if($status -ne 0) {
Write-Host "Failed to uninstall $($Program.winget)." Write-Host "Failed to uninstall $($Program.winget)."
} else { } else {
Write-Host "$($Program.winget) uninstalled successfully." Write-Host "$($Program.winget) uninstalled successfully."
@ -96,7 +97,9 @@ Function Install-WinUtilProgramWinget {
$failedPackages += $Program $failedPackages += $Program
} }
} }
$X++ else {
throw "[Install-WinUtilProgramWinget] Invalid Value for Parameter 'manage', Provided Value is: $manage"
}
} }
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
return $failedPackages; return $failedPackages;

View File

@ -8,7 +8,7 @@
Author : Chris Titus @christitustech Author : Chris Titus @christitustech
Runspace Author: @DeveloperDurp Runspace Author: @DeveloperDurp
GitHub : https://github.com/ChrisTitusTech GitHub : https://github.com/ChrisTitusTech
Version : 24.07.17 Version : 24.07.16
#> #>
param ( param (
[switch]$Debug, [switch]$Debug,
@ -45,7 +45,7 @@ Add-Type -AssemblyName System.Windows.Forms
# Variable to sync between runspaces # Variable to sync between runspaces
$sync = [Hashtable]::Synchronized(@{}) $sync = [Hashtable]::Synchronized(@{})
$sync.PSScriptRoot = $PSScriptRoot $sync.PSScriptRoot = $PSScriptRoot
$sync.version = "24.07.17" $sync.version = "24.07.16"
$sync.configs = @{} $sync.configs = @{}
$sync.ProcessRunning = $false $sync.ProcessRunning = $false
@ -1001,17 +1001,18 @@ Function Install-WinUtilProgramWinget {
[Parameter(Position=1)] [Parameter(Position=1)]
[String]$manage = "Installing" [String]$manage = "Installing"
) )
$x = 0
$count = $ProgramsToInstall.Count $count = $ProgramsToInstall.Count
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0 Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
Write-Host "===========================================" Write-Host "==========================================="
Write-Host "-- Configuring winget packages ---" Write-Host "-- Configuring winget packages ---"
Write-Host "===========================================" Write-Host "==========================================="
Foreach ($Program in $ProgramsToInstall){ for ($i = 0; $i -le $ProgramsToInstall.Count; $i++) {
$Program = $ProgramsToInstall[$i]
$failedPackages = @() $failedPackages = @()
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($x + 1) of $count" -PercentComplete $($x/$count*100) Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($i + 1) of $count" -PercentComplete $(($i/$count) * 100)
if($manage -eq "Installing"){ if($manage -eq "Installing") {
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt. # Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
# Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround. # Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround.
# Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode. # Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode.
@ -1019,21 +1020,21 @@ Function Install-WinUtilProgramWinget {
Write-Host "Starting install of $($Program.winget) with winget." Write-Host "Starting install of $($Program.winget) with winget."
try { try {
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode $status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
if($status -eq 0){ if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully." Write-Host "$($Program.winget) installed successfully."
continue continue
} }
if ($status -eq -1978335189){ if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found" Write-Host "$($Program.winget) No applicable update found"
continue continue
} }
Write-Host "Attempt with User scope" Write-Host "Attempt with User scope"
$status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode $status = $(Start-Process -FilePath "winget" -ArgumentList "install --id $($Program.winget) --scope user --silent --accept-source-agreements --accept-package-agreements" -Wait -PassThru -NoNewWindow).ExitCode
if($status -eq 0){ if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully with User scope." Write-Host "$($Program.winget) installed successfully with User scope."
continue continue
} }
if ($status -eq -1978335189){ if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found" Write-Host "$($Program.winget) No applicable update found"
continue continue
} }
@ -1047,11 +1048,11 @@ Function Install-WinUtilProgramWinget {
} else { } else {
Write-Host "Skipping installation with specific user credentials." Write-Host "Skipping installation with specific user credentials."
} }
if($status -eq 0){ if($status -eq 0) {
Write-Host "$($Program.winget) installed successfully with User prompt." Write-Host "$($Program.winget) installed successfully with User prompt."
continue continue
} }
if ($status -eq -1978335189){ if ($status -eq -1978335189) {
Write-Host "$($Program.winget) No applicable update found" Write-Host "$($Program.winget) No applicable update found"
continue continue
} }
@ -1060,11 +1061,11 @@ Function Install-WinUtilProgramWinget {
$failedPackages += $Program $failedPackages += $Program
} }
} }
if($manage -eq "Uninstalling"){ elseif($manage -eq "Uninstalling") {
# Uninstall package via ID using winget directly. # Uninstall package via ID using winget directly.
try { try {
$status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode $status = $(Start-Process -FilePath "winget" -ArgumentList "uninstall --id $($Program.winget) --silent" -Wait -PassThru -NoNewWindow).ExitCode
if($status -ne 0){ if($status -ne 0) {
Write-Host "Failed to uninstall $($Program.winget)." Write-Host "Failed to uninstall $($Program.winget)."
} else { } else {
Write-Host "$($Program.winget) uninstalled successfully." Write-Host "$($Program.winget) uninstalled successfully."
@ -1075,7 +1076,9 @@ Function Install-WinUtilProgramWinget {
$failedPackages += $Program $failedPackages += $Program
} }
} }
$X++ else {
throw "[Install-WinUtilProgramWinget] Invalid Value for Parameter 'manage', Provided Value is: $manage"
}
} }
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
return $failedPackages; return $failedPackages;