From 841cca8c1825cd3139aef048a65612a1c4677d20 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Fri, 19 Jul 2024 19:42:53 +1000 Subject: [PATCH 1/5] Remove conditional AppX build when on Windows... ...The default configuration should build it already --- Makefile | 7 ------- electron-builder-appx.json | 35 ----------------------------------- 2 files changed, 42 deletions(-) delete mode 100644 electron-builder-appx.json diff --git a/Makefile b/Makefile index 77c6f5363..ee7b24cc4 100644 --- a/Makefile +++ b/Makefile @@ -141,14 +141,7 @@ package: build-if-changed .PHONY: package-win32 package-win32: - @echo Packaging .exe... @npx electron-builder --win -p $(PUBLISH) -ifeq ($(IS_WINDOWS),true) - @echo Packaging .appx as well... - @npx electron-builder --win -p $(PUBLISH) --config=./electron-builder-appx.json -else - @echo Skipping packaging .appx because we are not running on a Windows machine. -endif .PHONY: package-osx package-osx: build-if-changed diff --git a/electron-builder-appx.json b/electron-builder-appx.json deleted file mode 100644 index 21178a3cc..000000000 --- a/electron-builder-appx.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "productName": "Simplenote", - "appId": "com.automattic.simplenote", - "directories": { - "output": "release", - "buildResources": "resources" - }, - "files": ["desktop", "dist", "shared"], - "win": { - "icon": "resources/images/simplenote.ico", - "target": [ - { - "target": "appx", - "arch": ["ia32", "x64"] - } - ] - }, - "appx": { - "applicationId": "Simplenote", - "identityName": "22490Automattic.Simplenote", - "publisher": "CN=E2E5A157-746D-4B04-9116-ABE5CB928306", - "publisherDisplayName": "Automattic, Inc.", - "backgroundColor": "transparent", - "showNameOnTiles": true, - "artifactName": "Simplenote-win-store-${version}-${arch}.${ext}" - }, - "protocols": [ - { - "name": "simplenote", - "schemes": ["simplenote"] - } - ], - "afterSign": "./after_sign_hook.js", - "afterAllArtifactBuild": "./after_sign_hook.js" -} From 424339a99cc49fedffeb791fd308939bcf6d08f7 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 25 Jul 2024 16:08:27 +1000 Subject: [PATCH 2/5] Use shared dedicated script to run `npm install` in Windows CI And properly fail if something goes wrong. This will prevent silent failure like the one in https://buildkite.com/automattic/simplenote-electron/builds/174#0190e36e-b92e-4c7d-a6aa-7c26a02197b0/233-243 --- .buildkite/commands/package_windows.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/commands/package_windows.ps1 b/.buildkite/commands/package_windows.ps1 index 406ba2812..3a9010561 100644 --- a/.buildkite/commands/package_windows.ps1 +++ b/.buildkite/commands/package_windows.ps1 @@ -38,8 +38,8 @@ Import-PfxCertificate -FilePath $certPath -CertStoreLocation Cert:\LocalMachine\ Write-Host "--- :windows: Installing make" choco install make -Write-Host "--- :npm: Installing dependencies" -npm ci --legacy-peer-deps +bash ".\.buildkite\commands\install_node_dependencies.sh" +If ($LastExitCode -ne 0) { Exit $LastExitCode } Write-Host "--- :lock_with_ink_pen: Decrypting secrets" make decrypt_conf From e4672ea38f01ecdff868eba486fe1bf49f2fed3c Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 25 Jul 2024 16:11:03 +1000 Subject: [PATCH 3/5] Print path when failing to find Windows certificate in CI --- .buildkite/commands/package_windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/commands/package_windows.ps1 b/.buildkite/commands/package_windows.ps1 index 3a9010561..5000a1d2e 100644 --- a/.buildkite/commands/package_windows.ps1 +++ b/.buildkite/commands/package_windows.ps1 @@ -26,7 +26,7 @@ If (Test-Path $certPath) { [System.Environment]::SetEnvironmentVariable('CSC_LINK', $certPath, [System.EnvironmentVariableTarget]::Machine) Write-Host "Environment variable CSC_LINK set to $certPath" } else { - Write-Host "[!] certificate.pfx file does not exist." + Write-Host "[!] Certificate file does not exist at given path $certPath." Exit 1 } From 0f7e2d854850f37ae2c0f4bcc72c42144a5702cb Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 25 Jul 2024 16:13:00 +1000 Subject: [PATCH 4/5] Reintroduce dedicated config file for AppX build --- Makefile | 3 +++ electron-builder-appx.json | 33 +++++++++++++++++++++++++++++++++ electron-builder.json | 8 -------- 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 electron-builder-appx.json diff --git a/Makefile b/Makefile index ee7b24cc4..5e0841cf0 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,10 @@ package: build-if-changed .PHONY: package-win32 package-win32: + @echo "Packaging exe..." @npx electron-builder --win -p $(PUBLISH) + @echo "Packaging appx with dedicated configuration to work around code signing conflicts..." + @npx electron-builder --win -p $(PUBLISH) --config=./electron-builder-appx.json .PHONY: package-osx package-osx: build-if-changed diff --git a/electron-builder-appx.json b/electron-builder-appx.json new file mode 100644 index 000000000..072743c42 --- /dev/null +++ b/electron-builder-appx.json @@ -0,0 +1,33 @@ +{ + "productName": "Simplenote", + "appId": "com.automattic.simplenote", + "directories": { + "output": "./release", + "buildResources": "./resources" + }, + "files": ["desktop", "dist", "shared"], + "win": { + "icon": "resources/images/simplenote.ico", + "target": [ + { + "target": "appx", + "arch": ["ia32", "x64"] + } + ] + }, + "appx": { + "applicationId": "Simplenote", + "identityName": "22490Automattic.Simplenote", + "publisher": "CN=E2E5A157-746D-4B04-9116-ABE5CB928306", + "publisherDisplayName": "Automattic, Inc.", + "backgroundColor": "transparent", + "showNameOnTiles": true, + "artifactName": "Simplenote-win-store-${version}-${arch}.${ext}" + }, + "protocols": [ + { + "name": "simplenote", + "schemes": ["simplenote"] + } + ] +} diff --git a/electron-builder.json b/electron-builder.json index dfd98c4f3..8a5bdd915 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -54,17 +54,9 @@ { "target": "nsis", "arch": ["ia32", "x64"] - }, - { - "target": "appx", - "arch": ["ia32", "x64"] } ] }, - "appx": { - "backgroundColor": "transparent", - "showNameOnTiles": true - }, "nsis": { "artifactName": "Simplenote-win-${version}-${arch}.${ext}", "deleteAppDataOnUninstall": true, From ce94383b5f250c62fad870c59d512eb3a6345813 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Fri, 9 Aug 2024 07:12:43 +1000 Subject: [PATCH 5/5] Add clarifying comment in `Makefile` Co-authored-by: Olivier Halligon --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5e0841cf0..aec58b57c 100644 --- a/Makefile +++ b/Makefile @@ -143,7 +143,11 @@ package: build-if-changed package-win32: @echo "Packaging exe..." @npx electron-builder --win -p $(PUBLISH) - @echo "Packaging appx with dedicated configuration to work around code signing conflicts..." + # Note: the configuration required to generate a code signed exe via the `nsis` target will conflict with the `appx` configuration. + # In practice, "certificateSubjectName": "Automattic, Inc." is required to sign the exe, but if that setting is present and so are the `appx` settings, there will be a failure. + # Hence the need for a separate configuration here. + # See also in https://github.com/electron-userland/electron-builder/issues/6698 + @echo "Packaging appx — with dedicated configuration to work around code signing conflicts..." @npx electron-builder --win -p $(PUBLISH) --config=./electron-builder-appx.json .PHONY: package-osx