6 changed files with 264 additions and 27 deletions
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env pwsh |
||||
param( |
||||
[Parameter(Mandatory=$true)] |
||||
[System.Runtime.InteropServices.Architecture]$Architecture, |
||||
$CertificatePath, |
||||
$CertificatePassword, |
||||
$ElectronConfigFile="electron-builder.json", |
||||
[Switch]$Release=$false |
||||
) |
||||
$ErrorActionPreference = "Stop" |
||||
$PSNativeCommandUseErrorActionPreference = $true |
||||
$startTime = Get-Date |
||||
$originalLocation = Get-Location |
||||
try { |
||||
|
||||
cd $PSScriptRoot |
||||
|
||||
$builderConfig = Get-Content $ElectronConfigFile | ConvertFrom-Json |
||||
$packageConfig = Get-Content package.json | ConvertFrom-Json |
||||
$manifestTemplate = Get-Content $builderConfig.appx.customManifestPath |
||||
|
||||
$srcDir = Get-Location |
||||
$assetsDir = Get-Item $builderConfig.directories.buildResources |
||||
$buildDir = Get-Item $builderConfig.directories.app |
||||
$outDir = Join-Path (Get-Location) ($builderConfig.directories.output ?? "dist") |
||||
|
||||
if ($Release) { |
||||
$buildConfiguration = "--release" |
||||
} |
||||
$arch = "$Architecture".ToLower() |
||||
$ext = "appx" |
||||
$version = Get-Date -Format "yyyy.M.d.1HHmm" |
||||
$productName = $builderConfig.productName |
||||
$artifactName = "${productName}-$($packageConfig.version)-${arch}.$ext" |
||||
|
||||
Write-Host "Building native code" |
||||
$rustTarget = switch ($Architecture) { |
||||
X64 { "x86_64-pc-windows-msvc" } |
||||
ARM64 { "aarch64-pc-windows-msvc" } |
||||
default { |
||||
Write-Error "Unsupported architecture: $Architecture. Supported architectures are x64 and arm64" |
||||
Exit(1) |
||||
} |
||||
} |
||||
npm run build-native -- cross-platform $buildConfiguration "--target=$rustTarget" |
||||
|
||||
Write-Host "Building Javascript code" |
||||
if ($target -eq "release") { |
||||
npm run build |
||||
} |
||||
else { |
||||
npm run build:dev |
||||
} |
||||
|
||||
Write-Host "Cleaning output folder" |
||||
Remove-Item -Recurse -Force $outDir -ErrorAction Ignore |
||||
|
||||
Write-Host "Packaging Electron executable" |
||||
& npx electron-builder --config $ElectronConfigFile --publish never --dir --win --$arch |
||||
|
||||
cd $outDir |
||||
New-Item -Type Directory (Join-Path $outDir "appx") |
||||
|
||||
Write-Host "Building Appx directory structure" |
||||
$appxDir = (Join-Path $outDir appx/app) |
||||
if ($arch -eq "x64") { |
||||
Move-Item (Join-Path $outDir "win-unpacked") $appxDir |
||||
} |
||||
else { |
||||
Move-Item (Join-Path $outDir "win-${arch}-unpacked") $appxDir |
||||
} |
||||
|
||||
Write-Host "Copying Assets" |
||||
New-Item -Type Directory (Join-Path $outDir appx/assets) |
||||
Copy-Item $srcDir/resources/appx/* $outDir/appx/assets/ |
||||
|
||||
Write-Host "Building Appx manifest" |
||||
$translationMap = @{ |
||||
'arch' = $arch |
||||
'applicationId' = $builderConfig.appx.applicationId |
||||
'displayName' = $productName |
||||
'executable' = "app\${productName}.exe" |
||||
'publisher' = $builderConfig.appx.publisher |
||||
'publisherDisplayName' = $builderConfig.appx.publisherDisplayName |
||||
'version' = $version |
||||
} |
||||
|
||||
$manifest = $manifestTemplate |
||||
$translationMap.Keys | ForEach-Object { |
||||
$manifest = $manifest.Replace("`${$_}", $translationMap[$_]) |
||||
} |
||||
$manifest | Out-File appx/AppxManifest.xml |
||||
$unsignedArtifactpath = [System.IO.Path]::GetFileNameWithoutExtension($artifactName) + "-unsigned.$ext" |
||||
Write-Host "Creating unsigned Appx" |
||||
makemsix pack -d appx -p $unsignedArtifactpath |
||||
|
||||
$outfile = Join-Path $outDir $unsignedArtifactPath |
||||
if ($null -eq $CertificatePath || $null -eq $CertificatePassword) { |
||||
Write-Warning "No Certificate specified. Not signing Appx." |
||||
} |
||||
else { |
||||
|
||||
$cert = (Get-Item $CertificatePath).FullName |
||||
$pw = $CertificatePassword |
||||
$unsigned = $outfile |
||||
$outfile = (Join-Path $outDir $artifactName) |
||||
Write-Host "Signing $artifactName with $cert" |
||||
osslsigncode sign ` |
||||
-pkcs12 "$cert" ` |
||||
-pass "$pw" ` |
||||
-in $unsigned ` |
||||
-out $outfile |
||||
Remove-Item $unsigned |
||||
} |
||||
|
||||
$endTime = Get-Date |
||||
$elapsed = $endTime - $startTime |
||||
Write-Host "Successfully packaged $(Get-Item $outfile)" |
||||
Write-Host ("Finished at $($endTime.ToString('HH:mm:ss')) in $($elapsed.ToString('mm')) minutes and $($elapsed.ToString('ss')).$($elapsed.ToString('fff')) seconds") |
||||
} |
||||
finally { |
||||
Set-Location -Path $originalLocation |
||||
} |
||||
@ -0,0 +1,111 @@
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!--suppress XmlUnusedNamespaceDeclaration --> |
||||
<!-- <Package |
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" |
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" |
||||
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" |
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"> --> |
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" |
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" |
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" |
||||
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10" |
||||
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10" |
||||
IgnorableNamespaces="uap rescap com uap10 build" |
||||
xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build"> |
||||
<!-- use single quotes to avoid double quotes escaping in the publisher value --> |
||||
<Identity Name="${applicationId}" |
||||
ProcessorArchitecture="${arch}" |
||||
Publisher='${publisher}' |
||||
Version="${version}" /> |
||||
<Properties> |
||||
<DisplayName>${displayName}</DisplayName> |
||||
<PublisherDisplayName>${publisherDisplayName}</PublisherDisplayName> |
||||
<Description>A secure and free password manager for all of your devices.</Description> |
||||
<Logo>assets\StoreLogo.png</Logo> |
||||
</Properties> |
||||
<Resources> |
||||
<Resource Language="en-US" /> |
||||
<Resource Language="af" /> |
||||
<Resource Language="ar" /> |
||||
<Resource Language="az-latn" /> |
||||
<Resource Language="be" /> |
||||
<Resource Language="bg" /> |
||||
<Resource Language="bn" /> |
||||
<Resource Language="bs" /> |
||||
<Resource Language="ca" /> |
||||
<Resource Language="cs" /> |
||||
<Resource Language="cy" /> |
||||
<Resource Language="da" /> |
||||
<Resource Language="de" /> |
||||
<Resource Language="el" /> |
||||
<Resource Language="en-gb" /> |
||||
<Resource Language="en-in" /> |
||||
<Resource Language="es" /> |
||||
<Resource Language="et" /> |
||||
<Resource Language="eu" /> |
||||
<Resource Language="fa" /> |
||||
<Resource Language="fi" /> |
||||
<Resource Language="fil" /> |
||||
<Resource Language="fr" /> |
||||
<Resource Language="gl" /> |
||||
<Resource Language="he" /> |
||||
<Resource Language="hi" /> |
||||
<Resource Language="hr" /> |
||||
<Resource Language="hu" /> |
||||
<Resource Language="id" /> |
||||
<Resource Language="it" /> |
||||
<Resource Language="ja" /> |
||||
<Resource Language="ka" /> |
||||
<Resource Language="km" /> |
||||
<Resource Language="kn" /> |
||||
<Resource Language="ko" /> |
||||
<Resource Language="lt" /> |
||||
<Resource Language="lv" /> |
||||
<Resource Language="ml" /> |
||||
<Resource Language="mr" /> |
||||
<Resource Language="nb" /> |
||||
<Resource Language="ne" /> |
||||
<Resource Language="nl" /> |
||||
<Resource Language="nn" /> |
||||
<Resource Language="or" /> |
||||
<Resource Language="pl" /> |
||||
<Resource Language="pt-br" /> |
||||
<Resource Language="pt-pt" /> |
||||
<Resource Language="ro" /> |
||||
<Resource Language="ru" /> |
||||
<Resource Language="si" /> |
||||
<Resource Language="sk" /> |
||||
<Resource Language="sl" /> |
||||
<Resource Language="sr-cyrl" /> |
||||
<Resource Language="sv" /> |
||||
<Resource Language="te" /> |
||||
<Resource Language="th" /> |
||||
<Resource Language="tr" /> |
||||
<Resource Language="uk" /> |
||||
<Resource Language="vi" /> |
||||
<Resource Language="zh-cn" /> |
||||
<Resource Language="zh-tw" /> |
||||
</Resources> |
||||
<Dependencies> |
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.26200.7019" |
||||
MaxVersionTested="10.0.26200.7171" /> |
||||
</Dependencies> |
||||
<Capabilities> |
||||
<rescap:Capability Name="runFullTrust" /> |
||||
</Capabilities> |
||||
<Applications> |
||||
<Application Id="bitwardendesktop" Executable="${executable}" |
||||
EntryPoint="Windows.FullTrustApplication"> |
||||
<uap:VisualElements |
||||
BackgroundColor="#175DDC" |
||||
DisplayName="${displayName}" |
||||
Square150x150Logo="assets\Square150x150Logo.png" |
||||
Square44x44Logo="assets\Square44x44Logo.png" |
||||
Description="A secure and free password manager for all of your devices."> |
||||
<uap:LockScreen Notification="badgeAndTileText" BadgeLogo="assets\BadgeLogo.png" /> |
||||
<uap:DefaultTile Wide310x150Logo="assets\Wide310x150Logo.png" /> |
||||
<uap:SplashScreen Image="assets\SplashScreen.png" /> |
||||
</uap:VisualElements> |
||||
</Application> |
||||
</Applications> |
||||
</Package> |
||||
Loading…
Reference in new issue