Skip to content

Commit

Permalink
feat: prettified dev scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Aug 9, 2024
1 parent 0447787 commit 28d3e3a
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# debugging
*.log

# bazel
/bazel-*
/user.bazelrc
Expand Down
25 changes: 18 additions & 7 deletions CopyDist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

$ErrorActionPreference = 'Stop'

git clean dist -fdx
bazel build //:copy_dist_include //:copy_dist_bin //:copy_dist_codegen_plugins //:copy_dist_images -c opt
bazel run --ui_event_filters=-info --noshow_progress //:copy_dist_include -c opt
bazel run --ui_event_filters=-info --noshow_progress //:copy_dist_images -c opt
bazel run --ui_event_filters=-info --noshow_progress //:copy_dist_bin -c opt
bazel run --ui_event_filters=-info --noshow_progress //:copy_dist_codegen_plugins -c opt
bazel run --ui_event_filters=-info --noshow_progress //:copy_dist_recipe_bundles -c opt
$RunCopyTargets = @(
'//:copy_dist_include',
'//:copy_dist_bin',
'//:copy_dist_codegen_plugins',
'//:copy_dist_images',
'//:copy_dist_recipe_bundles'
);

git clean dist -fdx *> CopyDist.log

Write-Progress -Status "Building copy targets..." -Activity "Copying distribution files"
bazel build $RunCopyTargets *>> CopyDist.log

foreach($Target in $RunCopyTargets)
{
Write-Progress -Status "$Target" -Activity "Copying distribution files"
bazel run --ui_event_filters=-info --noshow_progress $Target *>> CopyDist.log
}
70 changes: 47 additions & 23 deletions CreateMsix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,80 @@ $MakePriPath = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22621.0\x64\ma

$CertPasswordPlain = ConvertFrom-SecureString -SecureString $CertPassword -AsPlainText

try {
try
{
((Get-Content -path .\dist\AppxManifest.xml -Raw) -replace '0.0.0.0-placeholder',"$($Version).0") | Set-Content -Path .\dist\AppxManifest.xml
$MsixPath = "ecsact_sdk_$($Version)_windows_x64.msix"

Write-Output "Creating $MsixPath" *> CreateMsix.log

Copy-Item ".\dist\images\ecsact-color44.png" ".\dist\images\ecsact-color44.targetsize-44_altform-unplated.png" -Force
Copy-Item ".\dist\images\ecsact-color150.png" ".\dist\images\ecsact-color150.targetsize-150_altform-unplated.png" -Force

& $MakePriPath createconfig /cf .\dist\priconfig.xml /dq en-US /o
if(-not $?) {
if(-not $?)
{
throw "$MakePriPath createconfig failed with exit code ${LastExitCode}"
}

& $MakePriPath new /pr .\dist /cf .\dist\priconfig.xml /dq en-US /o /OutputFile ".\dist\resources.pri"
if(-not $?) {
& $MakePriPath new /pr .\dist /cf .\dist\priconfig.xml /dq en-US /o /OutputFile ".\dist\resources.pri" *>> CopyMsix.log
if(-not $?)
{
throw "$MakePriPath new failed with exit code ${LastExitCode}"
}

Set-ItemProperty -Path .\dist\bin\ecsact.exe -Name IsReadOnly -Value $false
Set-ItemProperty -Path .\dist\bin\ecsact_lsp_server.exe -Name IsReadOnly -Value $false
$ExecutablesToSign = @(
'.\dist\bin\ecsact.exe',
'.\dist\bin\ecsact_lsp_server.exe'
)

& $SignToolPath sign `
/debug /fd SHA384 `
/f $CertPath `
/p $CertPasswordPlain `
/tr http://timestamp.sectigo.com /td SHA256 `
.\dist\bin\ecsact.exe `
.\dist\bin\ecsact_lsp_server.exe
foreach($Executable in $ExecutablesToSign)
{
Set-ItemProperty -Path $Executable -Name IsReadOnly -Value $false
}

foreach($Executable in $ExecutablesToSign)
{
Write-Progress -Status "Signing distribution files" -Activity "$Executable"

& $SignToolPath sign `
/debug /fd SHA384 `
/f $CertPath `
/p $CertPasswordPlain `
/tr http://timestamp.sectigo.com /td SHA256 `
$Executable *>> CopyMsix.log

if(-not $?) {
throw "Signing dist binaries failed with exit code ${LastExitCode}"
if(-not $?)
{
throw "Signing dist binaries failed with exit code ${LastExitCode}"
}
}

Set-ItemProperty -Path .\dist\bin\ecsact.exe -Name IsReadOnly -Value $true
Set-ItemProperty -Path .\dist\bin\ecsact_lsp_server.exe -Name IsReadOnly -Value $true
foreach($Executable in $ExecutablesToSign)
{
Set-ItemProperty -Path $Executable -Name IsReadOnly -Value $true
}

& $MakeAppxPath pack /v /o /h SHA384 /d .\dist\ /p $MsixPath
& $MakeAppxPath pack /v /o /h SHA384 /d .\dist\ /p $MsixPath *>> CopyMsix.log

if(-not $?) {
if(-not $?)
{
throw "$MakeAppxPath exited with ${LastExitCode}"
}

Write-Progress -Status "Signing distribution files" -Activity "$MsixPath"

& $SignToolPath sign `
/debug /fd SHA384 `
/f $CertPath `
/p $CertPasswordPlain `
/tr http://timestamp.sectigo.com /td SHA256 `
$MsixPath
if(-not $?) {
$MsixPath *>> CopyMsix.log
if(-not $?)
{
throw "Signing ${MsixPath} failed with exit code ${LastExitCode}"
}
} finally {
git checkout .\dist\AppxManifest.xml
} finally
{
git checkout .\dist\AppxManifest.xml *>> CopyMsix.log
}
18 changes: 13 additions & 5 deletions DevInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,29 @@ $IncrementedVersion = $GitTagSplit[0] + "." + $GitTagSplit[1] + "." + (([int]$Gi
# Simulate a release to set the correct version
$Env:GITHUB_REF=$IncrementedVersion

Write-Output 'Starting DevInstall' *> DevInstall.log

. .\CopyDist.ps1

if ([System.Environment]::OSVersion.Platform -eq 'Unix') {
if ([System.Environment]::OSVersion.Platform -eq 'Unix')
{
# TODO(zaucy): Check if developer machine can install .deb files and give
# a nice error if they can't.
. ./CreateDeb.ps1 -Version $IncrementedVersion
sudo dpkg -i $DebPath
} else {
} else
{
$ExistingPackage = Get-AppPackage EcsactSdk

if ($ExistingPackage) {
Remove-AppPackage -Package $ExistingPackage.PackageFullName
if ($ExistingPackage)
{
Remove-AppPackage -Package $ExistingPackage.PackageFullName *>> DevInstall.log
}

. .\CreateMsix.ps1 -Version $IncrementedVersion -CertPassword $CertPassword -CertPath $CertPath
Add-AppPackage -Path $MsixPath
Add-AppPackage -Path $MsixPath *>> DevInstall.log

Write-Progress -Status "DevInstall Success" -Activity "$MsixPath Installed"
Write-Host "Successfully installed Ecsact SDK $Version" -ForegroundColor Green
}

0 comments on commit 28d3e3a

Please sign in to comment.