diff --git a/.github/workflows/test-installers.yml b/.github/workflows/test-installers.yml index 4b7ae64..ae5ad71 100644 --- a/.github/workflows/test-installers.yml +++ b/.github/workflows/test-installers.yml @@ -72,3 +72,19 @@ jobs: - uses: actions/checkout@v3 - name: Test Manjaro Gaming Install run: sh test/archlinux/test.sh installers/manjaro_gaming_install_packages.sh + + windows: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + - name: Test Windows Install + run: powershell.exe -executionpolicy bypass test/windows/test.ps1 installers/win_install_packages.ps1 + + windowsgaming: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + - name: Test Windows Gaming Install + run: powershell.exe -executionpolicy bypass test/windows/test.ps1 installers/wingaming_install_packages.ps1 diff --git a/.github/workflows/test-setups.yml b/.github/workflows/test-setups.yml index c8a1ce6..0208292 100644 --- a/.github/workflows/test-setups.yml +++ b/.github/workflows/test-setups.yml @@ -47,3 +47,11 @@ jobs: - uses: actions/checkout@v3 - name: Test Debian Bullseye Setup run: sh test/debian/bullseye/test.sh installers/debian_setup.sh + + windows: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + - name: Test Windows Setup + run: powershell.exe -executionpolicy bypass test/windows/test.ps1 installers/win_setup.ps1 diff --git a/installers/packages/gameranger/win_install.ps1 b/installers/packages/gameranger/win_install.ps1 new file mode 100644 index 0000000..9f3817c --- /dev/null +++ b/installers/packages/gameranger/win_install.ps1 @@ -0,0 +1,20 @@ +#!/usr/bin/env pwsh + +# Variables +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$exe_path = "${env:TEMP}/gameranger.exe" + +# Check if running as an administrator +if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error 'Please run as administrator' + exit 1 +} + +# Download GameRanger +Invoke-WebRequest -Uri "http://www.gameranger.com/download/GameRangerSetup.exe" ` + -OutFile $exe_path + +# Install GameRanger +$exe_path + +exit $LASTEXITCODE diff --git a/installers/packages/surfshark/win_install.ps1 b/installers/packages/surfshark/win_install.ps1 new file mode 100644 index 0000000..0ed5eb6 --- /dev/null +++ b/installers/packages/surfshark/win_install.ps1 @@ -0,0 +1,20 @@ +#!/usr/bin/env pwsh + +# Variables +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$exe_path = "${env:TEMP}/surfshark.exe" + +# Check if running as an administrator +if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error 'Please run as administrator' + exit 1 +} + +# Download Surfshark +Invoke-WebRequest -Uri "https://downloads.surfshark.com/windows/latest/SurfsharkSetup.exe" ` + -OutFile $exe_path + +# Install Surfshark +$exe_path + +exit $LASTEXITCODE diff --git a/installers/packages/wos/win_install.ps1 b/installers/packages/wos/win_install.ps1 new file mode 100644 index 0000000..c06b7a3 --- /dev/null +++ b/installers/packages/wos/win_install.ps1 @@ -0,0 +1,20 @@ +#!/usr/bin/env pwsh + +# Variables +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$exe_path = "${env:TEMP}/wos.exe" + +# Check if running as an administrator +if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error 'Please run as administrator' + exit 1 +} + +# Download Well Of Souls +Invoke-WebRequest -Uri "http://www.synthetic-reality.us/WellOfSouls.exe" ` + -OutFile $exe_path + +# Install Well Of Souls +$exe_path + +exit $LASTEXITCODE diff --git a/installers/packages/xournalpp/win_install.ps1 b/installers/packages/xournalpp/win_install.ps1 new file mode 100644 index 0000000..528c42f --- /dev/null +++ b/installers/packages/xournalpp/win_install.ps1 @@ -0,0 +1,26 @@ +#!/usr/bin/env pwsh + +# Variables +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$tag = (Invoke-WebRequest "https://api.github.com/repos/xournalpp/xournalpp/releases/latest" | ConvertFrom-Json)[0].tag_name +$version = $version.substring(1) +$unzip_path = "${env:TEMP}/xournalpp" +$zip_path = "$unzip_path.zip" + +# Check if running as an administrator +if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error 'Please run as administrator' + exit 1 +} + +# Download Xournalpp +Invoke-WebRequest -Uri "https://github.com/xournalpp/xournalpp/releases/download/$tag/xournalpp-$version-windows.zip" ` + -OutFile $zip_path + +# Extract Installer +Expand-Archive $zip_path -DestinationPath $unzip_path + +# Install Xournalpp +"$unzip_path/xournalpp-$version-windows.exe" + +exit $LASTEXITCODE diff --git a/installers/win_install_packages.ps1 b/installers/win_install_packages.ps1 new file mode 100644 index 0000000..a1c258d --- /dev/null +++ b/installers/win_install_packages.ps1 @@ -0,0 +1,55 @@ +#!/usr/bin/env pwsh + +# Variables +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$base_dir = (Get-Item $MyInvocation.MyCommand.Path).Directory.FullName + +# Check if running as an administrator +if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error 'Please run as administrator' + exit 1 +} + +# Run base setup +powershell.exe -executionpolicy bypass "$base_dir/win_setup.ps1" +if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE +} + +# Update packages +winget upgrade -h --all + +# Install packages +winget install -h 7zip.7zip Waterfox.Waterfox Microsoft.VisualStudioCode Microsoft.VisualStudio.2022.Community ` + Microsoft.WindowsTerminal WinSCP.WinSCP GIMP.GIMP Adobe.Acrobat.Reader.64-bit TheDocumentFoundation.LibreOffice.LTS ` + KDE.Kdenlive OBSProject.OBSStudio calibre.calibre KeePassXCTeam.KeePassXC VideoLAN.VLC DelugeTeam.Deluge Cyanfish.NAPS2 ` + HandBrake.HandBrake Telegram.TelegramDesktop GuinpinSoft.MakeMKV SlackTechnologies.Slack Postman.Postman Microsoft.Skype ` + AnyDeskSoftwareGmbH.AnyDesk Foundry376.Mailspring Zotero.Zotero Balena.Etcher Duplicati.Duplicati OpenVPNTechnologies.OpenVPN ` + GnuPG.Gpg4win --source winget +if ($LASTEXITCODE -ne 0) { + Write-Error 'Failed to install winget packages.' + exit $LASTEXITCODE +} + +# Install WSL +wsl --install -d openSUSE-42 +if ($LASTEXITCODE -ne 0) { + Write-Error 'Failed to install WSL.' + exit $LASTEXITCODE +} + +# Install Xournalpp +powershell.exe -executionpolicy bypass "$base_dir/packages/xournalpp/win_install.ps1" +if ($LASTEXITCODE -ne 0) { + Write-Error 'Xournalpp failed to install.' + exit $LASTEXITCODE +} + +# Install Surfshark +powershell.exe -executionpolicy bypass "$base_dir/packages/surfshark/win_install.ps1" +if ($LASTEXITCODE -ne 0) { + Write-Error 'Surfshark failed to install.' + exit $LASTEXITCODE +} + +# TODO: Add WSL install packages script. diff --git a/installers/win_setup.ps1 b/installers/win_setup.ps1 new file mode 100644 index 0000000..be40940 --- /dev/null +++ b/installers/win_setup.ps1 @@ -0,0 +1,46 @@ +#!/usr/bin/env pwsh + +# Variables +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) + +# Check if running as an administrator +if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error 'Please run as administrator' + exit 1 +} + +# Check if winget is installed +try { + # Install git if winget is installed + winget install Git.Git --source winget +} +catch { + # If not, install winget then git + Write-Output 'winget is not installed, attempting install..' + $winget_version = (Invoke-WebRequest "https://api.github.com/repos/microsoft/winget-cli/releases/latest" | ConvertFrom-Json)[0].tag_name + $winget_package = "${env:TEMP}/winget.msixbundle" + Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/$winget_version/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" ` + -OutFile $winget_package + Add-AppxPackage -Path $winget_package -Confirm + + try { + winget install Git.Git --source + } + catch { + Write-Error 'winget did not install correctly' + exit 2 + } +} + +# Using git, download and install the Windows 10 Debloater scripts to debloat Windows +try { + $windebloater_root = "${env:TEMP}/windows10debloater" + git clone "https://github.com/Sycnex/Windows10Debloater.git" $windebloater_root + Set-ExecutionPolicy Unrestricted -Force + "$windebloater_root\Windows10SysPrepDebloater.ps1 -SysPrep -Debloat -Privacy" + exit $LASTEXITCODE +} +catch { + Write-Error 'git did not install correctly' + exit 3 +} diff --git a/installers/wingaming_install_packages.ps1 b/installers/wingaming_install_packages.ps1 new file mode 100644 index 0000000..926c3d9 --- /dev/null +++ b/installers/wingaming_install_packages.ps1 @@ -0,0 +1,50 @@ +#!/usr/bin/env pwsh + +# Variables +$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) +$base_dir = (Get-Item $MyInvocation.MyCommand.Path).Directory.FullName + +# Check if running as an administrator +if (!$currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error 'Please run as administrator' + exit 1 +} + +# Run base setup +powershell.exe -executionpolicy bypass "$base_dir/win_setup.ps1" +if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE +} + +# Update packages +winget upgrade -h --all + +# Install packages +winget install -h Waterfox.Waterfox Microsoft.WindowsTerminal OBSProject.OBSStudio ` + Discord.Discord Valve.Steam ElectronicArts.EADesktop DolphinEmulator.Dolphin ` + Mupen64.Mupen64 DOSBox.DOSBox Duplicati.Duplicati --source winget +if ($LASTEXITCODE -ne 0) { + Write-Error 'Failed to install winget packages.' + exit $LASTEXITCODE +} + +# Install Surfshark +powershell.exe -executionpolicy bypass "$base_dir/packages/surfshark/win_install.ps1" +if ($LASTEXITCODE -ne 0) { + Write-Error 'Surfshark failed to install.' + exit $LASTEXITCODE +} + +# Install GameRanger +powershell.exe -executionpolicy bypass "$base_dir/packages/gameranger/win_install.ps1" +if ($LASTEXITCODE -ne 0) { + Write-Error 'GameRanger failed to install.' + exit $LASTEXITCODE +} + +# Install Well Of Souls +powershell.exe -executionpolicy bypass "$base_dir/packages/wos/win_install.ps1" +if ($LASTEXITCODE -ne 0) { + Write-Error 'Well Of Souls failed to install.' + exit $LASTEXITCODE +} diff --git a/test/windows/Dockerfile b/test/windows/Dockerfile new file mode 100644 index 0000000..ce05bf9 --- /dev/null +++ b/test/windows/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/windows/server:ltsc2022 + +ARG target +ARG script + +COPY ${target} /target + +WORKDIR /target + +RUN powershell.exe -executionpolicy bypass ${script} + +WORKDIR / + +RUN powershell.exe -Command Remove-Item -Recurse /target diff --git a/test/windows/test.ps1 b/test/windows/test.ps1 new file mode 100644 index 0000000..f976201 --- /dev/null +++ b/test/windows/test.ps1 @@ -0,0 +1,37 @@ +#!/usr/bin/env pwsh + +# Check if script to test if specified +if (!$args[0]) { + Write-Error 'Please specify script to test.' + exit 1 +} + +$script = Resolve-Path -Path $args[0] +$target_dir = (Get-Item $script).Directory.FullName +$build_path = (Get-Item $MyInvocation.MyCommand.Path).Directory.FullName +$img = ([System.Environment]::UserName + "/" + (Get-Item $build_path).BaseName) +$tag = "testing" + +# Copy target script to pwd +Copy-Item -Recurse $target_dir ($build_path + "/" + (Get-Item $target_dir).BaseName) + +# Test build image with target script +$target_wkdir = (Get-Item $target_dir).BaseName +$target_script = (Get-Item $script).Name +docker build --no-cache --force-rm -t ($img + ":" + $tag) ` +--build-arg target=$target_wkdir ` +--build-arg script=$target_script ` +$build_path + +# Set build status code +$status = $LASTEXITCODE + +# Remove testing image +docker rmi ($img + ":" + $tag) + +# Remove target script from pwd +Remove-Item -Recurse ($build_path + "/" + (Get-Item $target_dir).BaseName) + +# Exit with build status code +exit $status +