Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Simplify Ensu Tauri signing config

Manav Rathi1a43f0b0fd2d
diff --git a/.github/workflows/ensu-build.yml b/.github/workflows/ensu-build.yml
index 9e1cd02def..8c4303be79 100644
--- a/.github/workflows/ensu-build.yml
+++ b/.github/workflows/ensu-build.yml
@@ -179,16 +179,12 @@ jobs:
shell: bash
env:
ENSU_TAURI_UPDATER_PUBKEY: ${{ vars.ENSU_TAURI_UPDATER_PUBKEY }}
- ENSU_TAURI_UPDATER_ENDPOINT: ${{ vars.ENSU_TAURI_UPDATER_ENDPOINT }}
- ENSU_TAURI_REQUIRE_UPDATER_PUBKEY: "1"
run: node rust/apps/ensu/scripts/ci-enable-updater.mjs
- name: Build and release Tauri app
uses: tauri-apps/tauri-action@84b9d35b5fc46c1e45415bdb6144030364f7ebc5 # v0.6.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.ENSU_TAURI_SIGNING_PRIVATE_KEY }}
- TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.ENSU_TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
TAURI_PRIVATE_KEY: ${{ secrets.ENSU_TAURI_SIGNING_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.ENSU_TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
APPLE_CERTIFICATE: ${{ secrets.MAC_OS_CERTIFICATE }}
diff --git a/rust/apps/ensu/scripts/ci-enable-updater.mjs b/rust/apps/ensu/scripts/ci-enable-updater.mjs
index 2b1efcb33e..5b0fdeab65 100644
--- a/rust/apps/ensu/scripts/ci-enable-updater.mjs
+++ b/rust/apps/ensu/scripts/ci-enable-updater.mjs
@@ -1,72 +1,11 @@
import fs from "node:fs";
-const configPath =
- process.env.ENSU_TAURI_CONFIG_PATH ??
- "rust/apps/ensu/src-tauri/tauri.conf.json";
-
const pubkey = process.env.ENSU_TAURI_UPDATER_PUBKEY?.trim();
-const requirePubkey =
- process.env.ENSU_TAURI_REQUIRE_UPDATER_PUBKEY === "1" ||
- process.env.ENSU_TAURI_REQUIRE_UPDATER_PUBKEY === "true";
-const endpoint = (
- process.env.ENSU_TAURI_UPDATER_ENDPOINT ||
- "https://ente.com/release-info/ensu-desktop.json"
-).trim();
+if (!pubkey) throw new Error("ENSU_TAURI_UPDATER_PUBKEY is required");
+const configPath = new URL("../src-tauri/tauri.conf.json", import.meta.url);
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
-if (config.tauri && typeof config.tauri === "object") {
- if (config.bundle && typeof config.bundle === "object") {
- config.tauri.bundle = {
- ...(config.tauri.bundle || {}),
- ...config.bundle,
- };
- delete config.bundle;
- }
-
- if (config.plugins?.updater && typeof config.plugins.updater === "object") {
- config.tauri.updater = {
- ...(config.tauri.updater || {}),
- ...config.plugins.updater,
- };
- delete config.plugins.updater;
- if (Object.keys(config.plugins).length === 0) {
- delete config.plugins;
- }
- }
-}
-
-if (!config.tauri && config.bundle && typeof config.bundle === "object") {
- config.bundle.createUpdaterArtifacts = true;
-}
-
-if (pubkey) {
- if (config.tauri && typeof config.tauri === "object") {
- config.tauri.updater = {
- ...(config.tauri.updater || {}),
- active: true,
- dialog: false,
- pubkey,
- endpoints: [endpoint],
- };
- } else {
- config.plugins = config.plugins || {};
- config.plugins.updater = {
- ...(config.plugins.updater || {}),
- pubkey,
- endpoints: [endpoint],
- };
- }
- console.log(`Enabled updater config in ${configPath}`);
-} else {
- if (requirePubkey) {
- console.error(
- `Missing ENSU_TAURI_UPDATER_PUBKEY for ${configPath}; refusing to continue`,
- );
- process.exit(1);
- }
- console.log(
- `No updater key configured for ${configPath}; leaving updater config unchanged`,
- );
-}
+config.tauri.updater.active = true;
+config.tauri.updater.pubkey = pubkey;
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
diff --git a/rust/apps/ensu/scripts/ci-enable-windows-signing.mjs b/rust/apps/ensu/scripts/ci-enable-windows-signing.mjs
index 8547c11b4a..53666e276c 100644
--- a/rust/apps/ensu/scripts/ci-enable-windows-signing.mjs
+++ b/rust/apps/ensu/scripts/ci-enable-windows-signing.mjs
@@ -1,47 +1,18 @@
import fs from "node:fs";
-const configPath =
- process.env.ENSU_TAURI_CONFIG_PATH ??
- "rust/apps/ensu/src-tauri/tauri.conf.json";
+const { AZURE_ENDPOINT, AZURE_CODE_SIGNING_NAME, AZURE_CERT_PROFILE_NAME } =
+ process.env;
-const endpoint = process.env.AZURE_ENDPOINT;
-const accountName = process.env.AZURE_CODE_SIGNING_NAME;
-const profileName = process.env.AZURE_CERT_PROFILE_NAME;
-
-if (!endpoint || !accountName || !profileName) {
+if (!AZURE_ENDPOINT || !AZURE_CODE_SIGNING_NAME || !AZURE_CERT_PROFILE_NAME) {
throw new Error(
"AZURE_ENDPOINT, AZURE_CODE_SIGNING_NAME, and AZURE_CERT_PROFILE_NAME are required",
);
}
+const configPath = new URL("../src-tauri/tauri.conf.json", import.meta.url);
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
-if (config.tauri && typeof config.tauri === "object" && config.bundle && typeof config.bundle === "object") {
- config.tauri.bundle = {
- ...(config.tauri.bundle || {}),
- ...config.bundle,
- };
- delete config.bundle;
-}
-
-const bundleConfig = config.bundle ?? config.tauri?.bundle;
-if (!bundleConfig || typeof bundleConfig !== "object") {
- throw new Error(`Unable to locate bundle config in ${configPath}`);
-}
-
-bundleConfig.windows = bundleConfig.windows || {};
-
-bundleConfig.windows.signCommand = [
- "artifact-signing-cli",
- "-e",
- endpoint,
- "-a",
- accountName,
- "-c",
- profileName,
- "-d",
- "Ensu",
- "%1",
-].join(" ");
+config.tauri.bundle.windows = {
+ signCommand: `artifact-signing-cli -e ${AZURE_ENDPOINT} -a ${AZURE_CODE_SIGNING_NAME} -c ${AZURE_CERT_PROFILE_NAME} -d Ensu %1`,
+};
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
-console.log(`Updated windows signCommand in ${configPath}`);