Created
November 29, 2023 22:55
-
-
Save JanisErdmanis/2bc80af573feb264ade230d0dd754b85 to your computer and use it in GitHub Desktop.
Remote bundling scripts for Windows using AppBundler produced archive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$Archive, | |
[string]$MSIX, | |
[string]$Password | |
) | |
New-Alias -Name makeappx -Value "C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x64\makeappx.exe" | |
New-Alias -Name signtool -Value "C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x64\signtool.exe" | |
New-Alias -Name editbin -Value "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\editbin.exe" | |
$APPDIR = [System.IO.Path]::GetFileNameWithoutExtension($Archive) | |
Write-Host "INFO: Removing appdir if present" | |
Remove-Item -Path $APPDIR -Recurse -Force -ErrorAction SilentlyContinue | |
Write-Host "INFO: Extracting archive" | |
Expand-Archive -LiteralPath "$Archive" -DestinationPath "$APPDIR" | |
# Waiting on julia 1.11 cache relocatability fix | |
# Write-Host "INFO: Precompiling" | |
# & "$APPDIR\precompile.ps1" | |
Write-Host "INFO: Changing subsystem for executables" | |
editbin /SUBSYSTEM:WINDOWS "$APPDIR\julia\bin\lld.exe" | |
### This is ridiculous!!! ### | |
# A plain editbin does not work on julia.exe | |
# however it works after julia.exe is coppied | |
# Moving julia.exe is allowed but not removing it. | |
# So in order to delete we move it to tempdir with unique name | |
mv "$APPDIR\julia\bin\julia.exe" julia.exe | |
cp julia.exe julia-windows.exe | |
editbin /SUBSYSTEM:WINDOWS "julia-windows.exe" | |
mv "julia-windows.exe" "$APPDIR\julia\bin\julia.exe" | |
$DATE = Get-Date -Format "yyyy-MM-dd_HH-mm-ss" | |
$TEMPFILE = "$env:TEMP\julia-$DATE.exe" | |
mv julia.exe "$TEMPFILE" | |
# editbin /SUBSYSTEM:WINDOWS "$APPDIR\julia\bin\julia.exe" | |
Write-Host "INFO: Forming MSIX archive" | |
makeappx pack /d "$APPDIR" /p "$MSIX" > $null | |
Write-Host "INFO: Signing MSIX archive" | |
signtool sign /fd SHA256 /a /f "JanisErdmanis.pfx" /p "$Password" "$MSIX" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# It is expected that the host is configured passworldess. | |
# For Windows 10 it is important to comment out administrator_authorization_hosts | |
# from sshd_config so the passwordless ssh to work. | |
# The host is expected to have installed makeapx, signtool and editbin. | |
info() { | |
local GREEN="\033[0;32m" | |
local NO_COLOR="\033[0m" # No color (reset to default) | |
echo -e "${GREEN}INFO: $*${NO_COLOR}" | |
} | |
isdef() { | |
if [ -z "${!1}" ]; then | |
echo "Error: $1 is not set." | |
exit 1 | |
fi | |
} | |
isdef WINDOWS_HOST | |
isdef WINDOWS_PORT | |
isdef WINDOWS_CERTIFICATE_PASSWORD | |
SOURCE=$1 | |
if [ -z "$2" ]; then | |
DESTINATION="$(basename ${SOURCE%.*}).msix" | |
else | |
DESTINATION="$2" | |
fi | |
DIR=$(dirname ${BASH_SOURCE[0]}) | |
SSH="ssh -p $WINDOWS_PORT $WINDOWS_HOST powershell" | |
info "Sending build setup" | |
$SSH "Remove-Item -Path Desktop\BuildDir -Recurse -Force -ErrorAction SilentlyContinue; New-Item -ItemType Directory -Path Desktop\BuildDir" | |
scp -P $WINDOWS_PORT "$DIR/build.ps1" "$DIR/JanisErdmanis.pfx" $SOURCE $WINDOWS_HOST:Desktop/BuildDir | |
#scp -P $WINDOWS_PORT "$DIR/build.ps1" $WINDOWS_HOST:Desktop/BuildDir # For debugging | |
ARCHIVE=$(basename $SOURCE) | |
MSIX=$(basename $DESTINATION) | |
$SSH "cd Desktop\BuildDir; .\build.ps1 -Archive $ARCHIVE -MSIX $MSIX -Password $WINDOWS_CERTIFICATE_PASSWORD" | |
info "Retrieving the built MSIX archive" | |
scp -P $WINDOWS_PORT $WINDOWS_HOST:Desktop/BuildDir/$MSIX "$DESTINATION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment