Script to setup Windows 10 1903
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

201 lines
7.5 KiB

name: Build
on:
push:
tags:
- '*.*.*'
- '*.*'
jobs:
patch:
runs-on: windows-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@master
- name: PowerShell 5.1
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/", ""
}
$ZIP = "$BUILD_DIR.zip"
New-Item -Path $BUILD_DIR -ItemType Directory -Force
Write-Host $BUILD_DIR
Write-Host $ZIP
Get-ChildItem -Path "Sophia\PowerShell 5.1" | Copy-Item -Destination $BUILD_DIR -Recurse -Force
Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force
# Calculate hash
Get-Item -Path $ZIP -Force | ForEach-Object -Process {
"$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)"
} | Add-Content -Path SHA256SUM -Encoding Default -Force
- name: 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/", ""
}
$BUILD_DIR += " PowerShell 7"
$ZIP = "$BUILD_DIR.zip"
New-Item -Path $BUILD_DIR -ItemType Directory -Force
Write-Host $BUILD_DIR
Write-Host $ZIP
Get-ChildItem -Path "Sophia\PowerShell 7" | Copy-Item -Destination $BUILD_DIR -Recurse -Force
# Download Microsoft.Windows.SDK.NET.Ref
$Parameters = @{
Uri = "https://www.nuget.org/api/v2/package/Microsoft.Windows.SDK.NET.Ref"
OutFile = "$PSScriptRoot\microsoft.windows.sdk.net.ref.nupkg"
Verbose = [switch]::Present
}
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"
DestinationPath = "$PSScriptRoot\SDK"
Force = [switch]::Present
Verbose = [switch]::Present
}
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 = $URL
OutFile = "$PSScriptRoot\Microsoft.Windows.CsWinRT.nupkg"
Verbose = [switch]::Present
}
Invoke-WebRequest @Parameters
Rename-Item -Path "$PSScriptRoot\Microsoft.Windows.CsWinRT.nupkg" -NewName "Microsoft.Windows.CsWinRT.zip" -Force
$Parameters = @{
Path = "$PSScriptRoot\Microsoft.Windows.CsWinRT.zip"
DestinationPath = "$PSScriptRoot\CsWinRT"
Force = [switch]::Present
Verbose = [switch]::Present
}
Expand-Archive @Parameters
New-Item -Path $BUILD_DIR\Libraries -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
Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force
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
# Calculate hash
Get-Item -Path $ZIP -Force | ForEach-Object -Process {
"$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)"
} | Add-Content -Path SHA256SUM -Encoding Default -Force
- name: Build LTSC
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"
New-Item -Path $BUILD_DIR -ItemType Directory -Force
Write-Host $BUILD_DIR
Write-Host $ZIP
Get-ChildItem -Path Sophia\LTSC | Copy-Item -Destination $BUILD_DIR -Recurse -Force
Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force
# Calculate hash
Get-Item -Path $ZIP -Force | ForEach-Object -Process {
"$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)"
} | Add-Content -Path SHA256SUM -Encoding Default -Force
- name: Build Windows 11
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"
New-Item -Path $BUILD_DIR -ItemType Directory -Force
Write-Host $BUILD_DIR
Write-Host $ZIP
Get-ChildItem -Path "Sophia\Windows 11" | Copy-Item -Destination $BUILD_DIR -Recurse -Force
Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force
# Calculate hash
Get-Item -Path $ZIP -Force | ForEach-Object -Process {
"$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)"
} | Add-Content -Path SHA256SUM -Encoding Default -Force
- name: 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"
New-Item -Path $BUILD_DIR -ItemType Directory -Force
Write-Host $BUILD_DIR
Write-Host $ZIP
Get-ChildItem -Path Wrapper -Exclude latest.txt | Copy-Item -Destination $BUILD_DIR -Recurse -Force
Compress-Archive -Path $BUILD_DIR -DestinationPath $ZIP -Force
# Calculate hash
Get-ChildItem -Path $ZIP -Force | ForEach-Object -Process {
"$($_.Name) $((Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash)"
} | Add-Content -Path SHA256SUM -Encoding Default -Force
- name: Upload archives to release
uses: svenstaro/upload-release-action@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: Sophia*.zip
tag: ${{ github.ref }}
overwrite: true
file_glob: true
prerelease: true
- name: Upload archives to release
uses: svenstaro/upload-release-action@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: SHA256SUM
tag: ${{ github.ref }}
overwrite: true
file_glob: true
prerelease: true