From f6e229bf2db1bce82718d61fefeb19578c9b2b0c Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Wed, 3 Dec 2025 21:17:40 +0300 Subject: [PATCH] Update SFX.ps1 --- .github/workflows/Chocolatey.yml | 45 ++++++++++++++++---------- .github/workflows/Sophia.yml | 21 +----------- .github/workflows/winget.yml | 8 ++--- SHA256SUM.json | 13 -------- Scripts/SFX.ps1 | 21 ++---------- Scripts/SFX_config.txt | 6 ++-- chocolatey/tools/chocolateyinstall.ps1 | 4 +-- 7 files changed, 41 insertions(+), 77 deletions(-) delete mode 100644 SHA256SUM.json diff --git a/.github/workflows/Chocolatey.yml b/.github/workflows/Chocolatey.yml index 72c7cef0..b73eb748 100644 --- a/.github/workflows/Chocolatey.yml +++ b/.github/workflows/Chocolatey.yml @@ -13,31 +13,42 @@ jobs: - name: Preparation run: | - # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/SHA256SUM.json $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/refs/heads/master/SHA256SUM.json" - UseBasicParsing = $true - Verbose = $true + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } - $SHA256SUM = Invoke-RestMethod @Parameters + $Latest_Release = Invoke-RestMethod @Parameters $Parameters = @{ - Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + Uri = "https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest" + UseBasicParsing = $true + Verbose = $true } - $Latest_Release = Invoke-RestMethod @Parameters + $assets = (Invoke-RestMethod @Parameters).assets + + # Get SHA256 hash sum of each asset + $Sophia_Script_Windows_10_PowerShell_5_1 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.10.v$($Latest_Release.Sophia_Script_Windows_10_PowerShell_5_1).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_10_PowerShell_7 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.10.PowerShell.7.v$($Latest_Release.Sophia_Script_Windows_10_PowerShell_7).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_10_LTSC2019 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.10.LTSC.2019.v$($Latest_Release.Sophia_Script_Windows_10_LTSC2019).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_10_LTSC2021 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.10.LTSC.2021.v$($Latest_Release.Sophia_Script_Windows_10_LTSC2021).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_11_PowerShell_5_1 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.11.v$($Latest_Release.Sophia_Script_Windows_11_PowerShell_5_1).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_11_Arm_PowerShell_5_1 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.11.v$($Latest_Release.Sophia_Script_Windows_11_Arm_PowerShell_5_1).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_11_Arm_PowerShell_7 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.11.v$($Latest_Release.Sophia_Script_Windows_11_Arm_PowerShell_7).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_11_PowerShell_7 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.11.PowerShell.7.v$($Latest_Release.Sophia_Script_Windows_11_PowerShell_7).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Windows_11_LTSC2024 = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.for.Windows.11.LTSC.2024.v$($Latest_Release.Sophia_Script_Windows_11_LTSC2024).zip"}).digest.Replace("sha256:", "") + $Sophia_Script_Wrapper = ($assets | Where-Object -FilterScript {$_.name -eq "Sophia.Script.Wrapper.v$($Latest_Release.Sophia_Script_Wrapper).zip"}).digest.Replace("sha256:", "") # Replace variables with script latest versions (Get-Content -Path "chocolatey\tools\chocolateyinstall.ps1" -Encoding utf8 -Raw) | Foreach-Object -Process { - $_ -replace "Hash_Sophia_Script_Windows_10_PowerShell_5_1", $SHA256SUM."Sophia.Script.for.Windows.10.v$($Latest_Release.Sophia_Script_Windows_10_PowerShell_5_1).zip" ` - -replace "Hash_Sophia_Script_Windows_10_PowerShell_7", $SHA256SUM."Sophia.Script.for.Windows.10.PowerShell.7.v$($Latest_Release.Sophia_Script_Windows_10_PowerShell_7).zip" ` - -replace "Hash_Sophia_Script_Windows_10_LTSC2019", $SHA256SUM."Sophia.Script.for.Windows.10.LTSC.2019.v$($Latest_Release.Sophia_Script_Windows_10_LTSC2019).zip" ` - -replace "Hash_Sophia_Script_Windows_10_LTSC2021", $SHA256SUM."Sophia.Script.for.Windows.10.LTSC.2021.v$($Latest_Release.Sophia_Script_Windows_10_LTSC2021).zip" ` - -replace "Hash_Sophia_Script_Windows_11_PowerShell_5_1", $SHA256SUM."Sophia.Script.for.Windows.11.v$($Latest_Release.Sophia_Script_Windows_11_PowerShell_5_1).zip" ` - -replace "Hash_Sophia_Script_Windows_11_Arm_PowerShell_5_1", $SHA256SUM."Sophia.Script.for.Windows.11.v$($Latest_Release.Sophia_Script_Windows_11_Arm_PowerShell_5_1).zip" ` - -replace "Hash_Sophia_Script_Windows_11_Arm_PowerShell_7", $SHA256SUM."Sophia.Script.for.Windows.11.v$($Latest_Release.Sophia_Script_Windows_11_Arm_PowerShell_7).zip" ` - -replace "Hash_Sophia_Script_Windows_11_PowerShell_7", $SHA256SUM."Sophia.Script.for.Windows.11.PowerShell.7.v$($Latest_Release.Sophia_Script_Windows_11_PowerShell_7).zip" ` - -replace "Hash_Sophia_Script_Windows_11_LTSC2024", $SHA256SUM."Sophia.Script.for.Windows.11.LTSC.2024.v$($Latest_Release.Sophia_Script_Windows_11_LTSC2024).zip" ` - -replace "Hash_Sophia_Script_Wrapper", $SHA256SUM."Sophia.Script.Wrapper.v$($Latest_Release.Sophia_Script_Wrapper).zip" + $_ -replace "Hash_Sophia_Script_Windows_10_PowerShell_5_1", $Sophia_Script_Windows_10_PowerShell_5_1 ` + -replace "Hash_Sophia_Script_Windows_10_PowerShell_7", $Sophia_Script_Windows_10_PowerShell_7 ` + -replace "Hash_Sophia_Script_Windows_10_LTSC2019", $Sophia_Script_Windows_10_LTSC2019 ` + -replace "Hash_Sophia_Script_Windows_10_LTSC2021", $Sophia_Script_Windows_10_LTSC2021 ` + -replace "Hash_Sophia_Script_Windows_11_PowerShell_5_1", $Sophia_Script_Windows_11_PowerShell_5_1 ` + -replace "Hash_Sophia_Script_Windows_11_Arm_PowerShell_5_1", $Sophia_Script_Windows_11_Arm_PowerShell_5_1 ` + -replace "Hash_Sophia_Script_Windows_11_Arm_PowerShell_7", $Sophia_Script_Windows_11_Arm_PowerShell_7 ` + -replace "Hash_Sophia_Script_Windows_11_PowerShell_7", $Sophia_Script_Windows_11_PowerShell_7 ` + -replace "Hash_Sophia_Script_Windows_11_LTSC2024", $Sophia_Script_Windows_11_LTSC2024 ` + -replace "Hash_Sophia_Script_Wrapper", $Sophia_Script_Wrapper } | Set-Content -Path "chocolatey\tools\chocolateyinstall.ps1" -Encoding utf8 -Force # Save latest release tag for sophia.nuspec diff --git a/.github/workflows/Sophia.yml b/.github/workflows/Sophia.yml index 606803e3..4e1cac67 100644 --- a/.github/workflows/Sophia.yml +++ b/.github/workflows/Sophia.yml @@ -76,25 +76,6 @@ jobs: run: | . "Scripts\ReleaseNotesTemplate.ps1" - - name: Adding SHA256SUM.json - run: | - $JSON = @{} - Get-ChildItem -Path . -File | Where-Object -FilterScript {$_.Name -match "zip|exe"} | ForEach-Object -Process { - Write-Verbose -Message "$($_.Name) has $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash) hashsum" -Verbose - - $JSON += @{ - "$($_.Name)" = "$((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" - } - } - $JSON | ConvertTo-Json | Set-Content -Path SHA256SUM.json -Encoding utf8 -Force - - git config --global user.name "GitHub Actions" - git config --global user.email "actions@github.com" - git add SHA256SUM.json - git commit -m "Update from ${{ github.ref_name }} for adding SHA256SUM.json" - # repository and branch to push to - git push origin HEAD:refs/heads/master - - name: Uploading uses: softprops/action-gh-release@master with: @@ -103,5 +84,5 @@ jobs: # Use "/" in path to files files: | Sophia*.zip - SophiaScriptWinGet_*.exe + Sophia.Script.for.Windows*WinGet.exe body_path: ${{ steps.read_release.outputs.ReleaseBody }} diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml index 3b1c5023..5463b73b 100644 --- a/.github/workflows/winget.yml +++ b/.github/workflows/winget.yml @@ -41,7 +41,7 @@ jobs: # Get archive hash $Parameters = @{ - Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$($Version)/Sophia.Script.for.Windows.11.v$($Version).zip" + Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$($Version)/Sophia.Script.for.Windows.11.v$($Version)_WinGet.exe" UseBasicParsing = $true } $Request = (Invoke-WebRequest @Parameters).RawContentStream @@ -50,9 +50,9 @@ jobs: # Update the metadata for the files Get-ChildItem -Path Scripts\WinGet_Manifests | ForEach-Object -Process { (Get-Content -Path $_.FullName -Encoding UTF8 -Raw) | Foreach-Object -Process { - $_ -replace "SophiaScriptVersion", $Version ` - -replace "SophiaScriptHash", $Hash ` - -replace "SophiaScriptDate", $(Get-Date -Format "yyyy-MM-dd") + $_ -replace "SophiaScriptVersion", $Version ` + -replace "SophiaScriptHash", $Hash ` + -replace "SophiaScriptDate", $(Get-Date -Format "yyyy-MM-dd") } | Set-Content -Path $_.FullName -Encoding utf8 -Force } diff --git a/SHA256SUM.json b/SHA256SUM.json deleted file mode 100644 index e2b046be..00000000 --- a/SHA256SUM.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Sophia.Script.for.Windows.11.LTSC.2024.v6.9.2.zip": "4195879F42B52F989A4B4B2827CB6F642A4E509EDBD2277AEE70B090772A23C9", - "Sophia.Script.for.Windows.11.PowerShell.7.v6.9.2.zip": "F6A697BFFD43662E7AA93E91C55956E30EF75C45413E52603EC9B5EEE198965C", - "Sophia.Script.for.Windows.10.LTSC.2021.v5.21.2.zip": "8E17FB1B9C3E291A0FFD7A4A1D7FFF138B29C321176CE115B04C0799BF87AA01", - "Sophia.Script.for.Windows.11.Arm.v6.9.2.zip": "CAE2AD9890096D004E2A07194CB3A826169E612B55804C4AC52C626587FFAB71", - "SophiaScriptWinGet_SophiaScriptVersion.exe": "0EB1FD5CA5BEE330E2A70CF4804F62FB57D791C80135A33931A93F844A676F31", - "Sophia.Script.Wrapper.v2.8.7.zip": "AF8E92E197AA0DD4F5A1A8E9A2F012AC50D1F9139C5A85351C329E7556DC12F2", - "Sophia.Script.for.Windows.11.Arm.PowerShell.7.v6.9.2.zip": "F00033A0D9D279EC906A97159ED984B87F4EA0CC002BE15C6CC86A5EFEFE8A0B", - "Sophia.Script.for.Windows.10.PowerShell.7.v5.21.2.zip": "709E7EEE92677B1E97933BB56359EC2CA41CABF60EDA95E4732CA9F9B508147D", - "Sophia.Script.for.Windows.11.v6.9.2.zip": "1F912F728EE3ED2DC16D53004E722AE0BDC18470A7A29FE5EA14B0C0815287E3", - "Sophia.Script.for.Windows.10.LTSC.2019.v5.11.2.zip": "736C74F2107EF419307CDCE6C51CD1CEF6EEB20CD18C5907B60B59286D07A9A0", - "Sophia.Script.for.Windows.10.v5.21.2.zip": "EA0903FFC0700611E47C20208B3C344F234AB077A5FF232D2320D7482C41EA78" -} diff --git a/Scripts/SFX.ps1 b/Scripts/SFX.ps1 index f351e25d..fc67949f 100644 --- a/Scripts/SFX.ps1 +++ b/Scripts/SFX.ps1 @@ -1,18 +1,7 @@ Write-Verbose -Message SFX -Verbose -# Download WinRAR -# https://www.rarlab.com -New-Item -Path WinRAR -ItemType Directory -Force - -$Parameters = @{ - Uri = "https://www.rarlab.com/rar/winrar-x64-713.exe" - OutFile = "WinRAR\winrar-x64-713.exe" - UseBasicParsing = $true -} -Invoke-WebRequest @Parameters - -# Install WinRAR silently -& "WinRAR\winrar-x64-713.exe" -s +# Install WinRAR +winget install --id RARLab.WinRAR --accept-source-agreements --force # Get latest version tag for Windows 11 $Parameters = @{ @@ -23,9 +12,5 @@ $Latest_Release_Windows_11_PowerShell_5_1 = (Invoke-RestMethod @Parameters).Soph (Get-Content -Path Scripts\SFX_config.txt -Encoding utf8NoBOM -Raw) | Foreach-Object -Process {$_ -replace "SophiaScriptVersion", $Latest_Release_Windows_11_PowerShell_5_1} | Set-Content -Path Scripts\SFX_config.txt -Encoding utf8NoBOM -Force -Get-Content -Path Scripts\SFX_config.txt - -get-childitem "Sophia_Script_for_Windows_11_v$($Latest_Release_Windows_11_PowerShell_5_1)" - # Create SFX archive -& "C:\Program Files\WinRAR\Rar.exe" a -sfx -z"Scripts\SFX_config.txt" -ep1 -r "SophiaScriptWinGet_$($Latest_Release_Windows_11_PowerShell_5_1).exe" "Sophia_Script_for_Windows_11_v$($Latest_Release_Windows_11_PowerShell_5_1)\*" +& "$env:ProgramFiles\WinRAR\RAR.exe" a -sfx -z"Scripts\SFX_config.txt" -ep1 -r "Sophia.Script.for.Windows.11.v$($Latest_Release_Windows_11_PowerShell_5_1)_WinGet.exe" "Sophia_Script_for_Windows_11_v$($Latest_Release_Windows_11_PowerShell_5_1)\*" diff --git a/Scripts/SFX_config.txt b/Scripts/SFX_config.txt index 88810bd4..6e84fce8 100644 --- a/Scripts/SFX_config.txt +++ b/Scripts/SFX_config.txt @@ -1,8 +1,8 @@ -; Config for creating a WinRAR SFX archive for WinGet +; Config for creating a WinRAR SFX archive of Sophia Script for Windows 11 for WinGet ; Expand SFX archive -Path=$env:TEMP\Sophia_Script_for_Windows_11_vSophiaScriptVersion +Path=%TEMP%\Sophia_Script_for_Windows_11_vSophiaScriptVersion ; Copy folder recursively to user's Desktop folder -Setup=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -Command & {Copy-Item -Path "$env:TEMP\Sophia_Script_for_Windows_11_vSophiaScriptVersion" -Destination "$(Get-ItemPropertyValue -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' -Name Desktop)\Sophia_Script_for_Windows_11_vSophiaScriptVersion" -Recurse -Force} +Setup=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -Command & {Copy-Item -Path "$env:TEMP\Sophia_Script_for_Windows_11_vSophiaScriptVersion" -Destination (Join-Path -Path "$(Get-ItemPropertyValue -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' -Name Desktop)" -ChildPath "Sophia_Script_for_Windows_11_vSophiaScriptVersion") -Recurse -Force} ; No GUI while expaning SFX archive Silent=1 diff --git a/chocolatey/tools/chocolateyinstall.ps1 b/chocolatey/tools/chocolateyinstall.ps1 index 58c7b1c1..16a95dc9 100644 --- a/chocolatey/tools/chocolateyinstall.ps1 +++ b/chocolatey/tools/chocolateyinstall.ps1 @@ -149,7 +149,7 @@ switch ((Get-CimInstance -ClassName Win32_OperatingSystem).BuildNumber) } $Downloads = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" -$packageArgs = @{ +$Parameters = @{ packageName = $env:ChocolateyPackageName fileType = "ZIP" unzipLocation = $Downloads @@ -157,4 +157,4 @@ $packageArgs = @{ checksum = $Hash checksumType = "sha256" } -Install-ChocolateyZipPackage @packageArgs +Install-ChocolateyZipPackage @Parameters