From 27a71564bab9569b912d80f322cc189738bb56d7 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Mon, 27 Sep 2021 22:36:51 +0300 Subject: [PATCH] Update Sophia.yml --- .github/workflows/Sophia.yml | 221 +++++++++++++++++++++-------------- 1 file changed, 134 insertions(+), 87 deletions(-) diff --git a/.github/workflows/Sophia.yml b/.github/workflows/Sophia.yml index 75d48ac0..6071d966 100644 --- a/.github/workflows/Sophia.yml +++ b/.github/workflows/Sophia.yml @@ -12,171 +12,218 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@master - - name: PowerShell 5.1 + - name: Sophia Script for Windows 10 run: | - $BUILD_DIR = "Sophia Script v" - if ($env:GITHUB_REF -eq "refs/heads/master") - { - $BUILD_DIR += "master" - } - else - { - $BUILD_DIR += ${env:GITHUB_REF} -replace "refs/tags/", "" + # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } + $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_5_1 - $ZIP = "$BUILD_DIR.zip" + New-Item -Path "Sophia Script for Windows 10 v$LatestRelease" -ItemType Directory - New-Item -Path $BUILD_DIR -ItemType Directory -Force + Write-Verbose -Message "Sophia Script for Windows 10 v$LatestRelease" -Verbose + Write-Verbose -Message "Sophia.Script.for.Windows.10.v$LatestRelease.zip" -Verbose - Write-Host $BUILD_DIR - Write-Host $ZIP + Get-ChildItem -Path "Sophia Script for Windows 10" -Recurse | Copy-Item -Destination "Sophia Script for Windows 10 v$LatestRelease" -Recurse - Get-ChildItem -Path "Sophia\PowerShell 5.1" | Copy-Item -Destination $BUILD_DIR -Recurse -Force - Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force + $Parameters = @{ + Path = "Sophia Script for Windows 10 v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.10.v$LatestRelease.zip" + CompressionLevel = "Fastest" + } + Compress-Archive @Parameters # Calculate hash - Get-Item -Path $ZIP -Force | ForEach-Object -Process { + Get-Item -Path "Sophia.Script.for.Windows.10.v$LatestRelease.zip" -Force | ForEach-Object -Process { "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding Default -Force - - name: PowerShell 7 + - name: Sophia Script for Windows 10 PowerShell 7 run: | - $BUILD_DIR = "Sophia Script v" - if ($env:GITHUB_REF -eq "refs/heads/master") - { - $BUILD_DIR += "master" - } - else - { - $BUILD_DIR += ${env:GITHUB_REF} -replace "refs/tags/", "" + # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" } - $BUILD_DIR += " PowerShell 7" - - $ZIP = "$BUILD_DIR.zip" + $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_PowerShell_7 - New-Item -Path $BUILD_DIR -ItemType Directory -Force + New-Item -Path "Sophia Script for Windows 10 v$LatestRelease PowerShell 7" -ItemType Directory - Write-Host $BUILD_DIR - Write-Host $ZIP + Write-Verbose -Message "Sophia Script for Windows 10 v$LatestRelease PowerShell 7" -Verbose + Write-Verbose -Message "Sophia.Script.for.Windows.10.v$LatestRelease.PowerShell.7zip" -Verbose - Get-ChildItem -Path "Sophia\PowerShell 7" | Copy-Item -Destination $BUILD_DIR -Recurse -Force + Get-ChildItem -Path "Sophia Script for Windows 10 PowerShell 7" -Recurse | Copy-Item -Destination "Sophia Script for Windows 10 v$LatestRelease PowerShell 7" -Recurse # Download Microsoft.Windows.SDK.NET.Ref $Parameters = @{ - Uri = "https://www.nuget.org/api/v2/package/Microsoft.Windows.SDK.NET.Ref" + Uri = "https://www.nuget.org/api/v2/package/Microsoft.Windows.SDK.NET.Ref" OutFile = "$PSScriptRoot\microsoft.windows.sdk.net.ref.nupkg" - Verbose = [switch]::Present + Verbose = $true } Invoke-WebRequest @Parameters Rename-Item -Path "$PSScriptRoot\Microsoft.Windows.SDK.NET.Ref.nupkg" -NewName "Microsoft.Windows.SDK.NET.Ref.zip" $Parameters = @{ - Path = "$PSScriptRoot\Microsoft.Windows.SDK.NET.Ref.zip" + Path = "$PSScriptRoot\Microsoft.Windows.SDK.NET.Ref.zip" DestinationPath = "$PSScriptRoot\SDK" - Force = [switch]::Present - Verbose = [switch]::Present + Force = $true + Verbose = $true } Expand-Archive @Parameters # Download CsWinRT - $LatestRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/CsWinRT/releases").tag_name | Select-Object -First 1 - $Download = ((Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/CsWinRT/releases") | Where-Object -FilterScript {$_.tag_name -eq $LatestRelease}).assets | Where-Object -FilterScript {$_.browser_download_url -match "nupkg"} - $URL = $Download.browser_download_url + $Parameters = @{ + Uri = "https://api.github.com/repos/microsoft/CsWinRT/releases/latest" + } + $URL = (Invoke-RestMethod @Parameters).assets | Where-Object -FilterScript {$_.browser_download_url -match "nupkg"}).browser_download_url $Parameters = @{ - Uri = $URL + Uri = $URL OutFile = "$PSScriptRoot\Microsoft.Windows.CsWinRT.nupkg" - Verbose = [switch]::Present + Verbose = $true } Invoke-WebRequest @Parameters Rename-Item -Path "$PSScriptRoot\Microsoft.Windows.CsWinRT.nupkg" -NewName "Microsoft.Windows.CsWinRT.zip" -Force $Parameters = @{ - Path = "$PSScriptRoot\Microsoft.Windows.CsWinRT.zip" + Path = "$PSScriptRoot\Microsoft.Windows.CsWinRT.zip" DestinationPath = "$PSScriptRoot\CsWinRT" - Force = [switch]::Present - Verbose = [switch]::Present + Force = $true + Verbose = $true } Expand-Archive @Parameters - New-Item -Path $BUILD_DIR\Libraries -ItemType Directory -Force + New-Item -Path "Sophia Script for Windows 10 v$LatestRelease PowerShell 7\Libraries" -ItemType Directory -Force + + $Parameters = @{ + Path = "$PSScriptRoot\sdk\lib\Microsoft.Windows.SDK.NET.dll", "$PSScriptRoot\CsWinRT\lib\net5.0\WinRT.Runtime.dll" + DestinationPath = "Sophia Script for Windows 10 v$LatestRelease PowerShell 7\Libraries" + Recurse = $true + } + Copy-Item @Parameters + + $Parameters = @{ + Path = "Sophia Script for Windows 10 v$LatestRelease PowerShell 7" + DestinationPath = "Sophia.Script.for.Windows.10.v$LatestRelease.PowerShell.7.zip" + } + Compress-Archive @Parameters + + $Items = @( + "$PSScriptRoot\CsWinRT", + "$PSScriptRoot\SDK", + "$PSScriptRoot\Microsoft.Windows.CsWinRT.zip", + "$PSScriptRoot\Microsoft.Windows.SDK.NET.Ref.zip" + ) + Remove-Item -Path $Items -Recurse -Force + + # Calculate hash + Get-Item -Path "Sophia.Script.for.Windows.10.v$LatestRelease.PowerShell.7.zip" -Force | ForEach-Object -Process { + "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" + } | Add-Content -Path SHA256SUM -Encoding Default -Force + + - name: Sophia Script for Windows 10 LTSC + run: | + # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + } + $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_10_LTSC + + New-Item -Path "Sophia Script for Windows 10 LTSC v$LatestRelease" -ItemType Directory -Force - Copy-Item -Path "$PSScriptRoot\sdk\lib\Microsoft.Windows.SDK.NET.dll" -Destination $BUILD_DIR\Libraries -Recurse -Force - Copy-Item -Path "$PSScriptRoot\CsWinRT\lib\net5.0\WinRT.Runtime.dll" -Destination $BUILD_DIR\Libraries -Recurse -Force + Write-Verbose -Message "Sophia Script for Windows 10 LTSC v$LatestRelease" -Verbose + Write-Verbose -Message "Sophia.Script.for.Windows.10.LTSC.v$LatestRelease.zip" -Verbose - Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force + Get-ChildItem -Path "Sophia Script for Windows 10 LTSC" -Recurse | Copy-Item -Destination "Sophia Script for Windows 10 LTSC v$LatestRelease" -Recurse - Remove-Item -Path "$PSScriptRoot\CsWinRT", "$PSScriptRoot\SDK" -Recurse -Force - Remove-Item -Path "$PSScriptRoot\Microsoft.Windows.CsWinRT.zip", "$PSScriptRoot\Microsoft.Windows.SDK.NET.Ref.zip" -Force + $Parameters = @{ + Path = "Sophia Script for Windows 10 LTSC v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.10.LTSC.v$LatestRelease.zip" + } + Compress-Archive @Parameters # Calculate hash - Get-Item -Path $ZIP -Force | ForEach-Object -Process { + Get-Item -Path "Sophia.Script.for.Windows.10.LTSC.v$LatestRelease.zip" -Force | ForEach-Object -Process { "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding Default -Force - - name: Build LTSC + - name: Sophia Script for Windows 11 run: | - $ModuleVersion = (Import-PowerShellDataFile -Path "Sophia\LTSC\Manifest\Sophia.psd1").ModuleVersion - Write-Host $ModuleVersion - $BUILD_DIR = "Sophia Script LTSC v$ModuleVersion" - $ZIP = "$BUILD_DIR.zip" + # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + } + $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1 - New-Item -Path $BUILD_DIR -ItemType Directory -Force + New-Item -Path "Sophia Script for Windows 11 v$LatestRelease" -ItemType Directory -Force - Write-Host $BUILD_DIR - Write-Host $ZIP + Write-Verbose -Message "Sophia Script for Windows 11 v$LatestRelease" -Verbose + Write-Verbose -Message "Sophia.Script.for.Windows.11.v$LatestRelease.zip" -Verbose - Get-ChildItem -Path Sophia\LTSC | Copy-Item -Destination $BUILD_DIR -Recurse -Force + Get-ChildItem -Path "Sophia Script for Windows 11" -Recurse | Copy-Item -Destination "Sophia Script for Windows 11 v$LatestRelease" -Recurse - Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force + $Parameters = @{ + Path = "Sophia Script for Windows 11 v$LatestRelease" + DestinationPath = "Sophia.Script.for.Windows.11.v$LatestRelease.zip" + } + Compress-Archive @Parameters # Calculate hash - Get-Item -Path $ZIP -Force | ForEach-Object -Process { + Get-Item -Path "Sophia.Script.for.Windows.11.v$LatestRelease.zip" -Force | ForEach-Object -Process { "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding Default -Force - - name: Build Windows 11 + - name: Sophia Script for Windows 11 PowerShell 7 run: | - $ModuleVersion = (Import-PowerShellDataFile -Path "Sophia\Windows 11\Manifest\Sophia.psd1").ModuleVersion - Write-Host $ModuleVersion - $BUILD_DIR = "Sophia Script Windows 11 v$ModuleVersion" - $ZIP = "$BUILD_DIR.zip" + # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + } + $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_7 - New-Item -Path $BUILD_DIR -ItemType Directory -Force + New-Item -Path "Sophia Script for Windows 11 v$LatestRelease PowerShell 7" -ItemType Directory -Force - Write-Host $BUILD_DIR - Write-Host $ZIP + Write-Verbose -Message "Sophia Script for Windows 11 v$LatestRelease PowerShell 7" -Verbose + Write-Verbose -Message "Sophia.Script.for.Windows.11.v$LatestRelease.PowerShell.7.zip" -Verbose - Get-ChildItem -Path "Sophia\Windows 11" | Copy-Item -Destination $BUILD_DIR -Recurse -Force + Get-ChildItem -Path "Sophia Script for Windows 11 PowerShell 7" -Recurse | Copy-Item -Destination "Sophia Script for Windows 11 v$LatestRelease PowerShell 7" -Recurse - Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force + $Parameters = @{ + Path = "Sophia Script for Windows 11 v$LatestRelease PowerShell 7" + DestinationPath = "Sophia.Script.for.Windows.11.v$LatestRelease.PowerShell.7.zip" + } + Compress-Archive @Parameters # Calculate hash - Get-Item -Path $ZIP -Force | ForEach-Object -Process { + Get-Item -Path "Sophia.Script.for.Windows.11.v$LatestRelease.PowerShell.7.zip" -Force | ForEach-Object -Process { "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding Default -Force - - name: Wrapper + - name: Sophia Script Wrapper run: | - # The Trim.() is needed to trim the downloaded text version string - $WrapperVersion = (Invoke-RestMethod -Uri "https://raw.githubusercontent.com/farag2/Windows-10-Sophia-Script/master/Wrapper/latest.txt").ToString().Trim() - Write-Host $WrapperVersion - $BUILD_DIR = "Sophia Script Wrapper v$WrapperVersion" - - $ZIP = "$BUILD_DIR.zip" + # https://github.com/farag2/Sophia-Script-for-Windows/blob/master/sophia_script_versions.json + $Parameters = @{ + Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/master/sophia_script_versions.json" + } + $LatestRelease = (Invoke-RestMethod @Parameters).Sophia_Script_Wrapper + + New-Item -Path "Sophia Script Wrapper v$LatestRelease" -ItemType Directory -Force - New-Item -Path $BUILD_DIR -ItemType Directory -Force + Write-Verbose -Message "Sophia Script Wrapper v$LatestRelease" -Verbose + Write-Verbose -Message "Sophia.Script.Wrapper.v$LatestRelease.zip" -Verbose - Write-Host $BUILD_DIR - Write-Host $ZIP + Get-ChildItem -Path Wrapper -Exclude README.md -Recurse | Copy-Item -Destination "Sophia Script Wrapper v$LatestRelease" -Recurse -Force - Get-ChildItem -Path Wrapper -Exclude latest.txt, README.md | Copy-Item -Destination $BUILD_DIR -Recurse -Force - Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force + $Parameters = @{ + Path = "Sophia Script Wrapper v$LatestRelease" + DestinationPath = "Sophia.Script.Wrapper.v$LatestRelease.zip" + } + Compress-Archive @Parameters # Calculate hash - Get-ChildItem -Path $ZIP -Force | ForEach-Object -Process { + Get-ChildItem -Path "Sophia.Script.Wrapper.v$LatestRelease.zip" -Force | ForEach-Object -Process { "$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)" } | Add-Content -Path SHA256SUM -Encoding Default -Force