Browse Source

Update SFX.ps1

pull/686/head
Dmitry Nefedov 4 months ago
parent
commit
f6e229bf2d
  1. 45
      .github/workflows/Chocolatey.yml
  2. 21
      .github/workflows/Sophia.yml
  3. 2
      .github/workflows/winget.yml
  4. 13
      SHA256SUM.json
  5. 21
      Scripts/SFX.ps1
  6. 6
      Scripts/SFX_config.txt
  7. 4
      chocolatey/tools/chocolateyinstall.ps1

45
.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

21
.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 }}

2
.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

13
SHA256SUM.json

@ -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"
}

21
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)\*"

6
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

4
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

Loading…
Cancel
Save