Skip to content

Commit 668c028

Browse files
committed
ci: create electron bins in pipeline scripts
1 parent 5640d87 commit 668c028

4 files changed

Lines changed: 63 additions & 15 deletions

File tree

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"tauri": "tauri",
88
"tauriBuildDemoApp": "node src-build/createDemoReleaseConfig.js && tauri build --config ./src-tauri/tauri-local.conf.json",
9-
"_ci-createDistReleaseConfig": "node src-build/ci-createDistReleaseConfig.js",
9+
"_ci-setupDistFolders": "node src-build/ci-setupDistFolders.js",
1010
"_ci-env-warn": "echo !!!This script is supposed to executed in github actions only. Ignore if you are seeing this message in a github actions log.",
1111
"releaseSrc": "node src-build/createSrcRelease.js",
1212
"releaseSrcDebug": "node src-build/createSrcRelease.js --debug",
@@ -19,9 +19,10 @@
1919
"_ci_make_src-node": "node ./src-build/makeSrcNode.js phoenix/src-node",
2020
"_ci-clonePhoenixForTests": "npm run _ci-env-warn && node ./src-build/clonePhoenixForTests.js",
2121
"_ci-cloneAndBuildPhoenix": "npm run _ci-env-warn && node ./src-build/clonePhoenix.js && cd phoenix && npm ci && npm run build && cd ..",
22-
"_ci-release:dev": "npm run _ci-env-warn && npm run _ci-cloneAndBuildPhoenix && cd phoenix && npm run release:dev && cd .. && npm run _ci-createDistReleaseConfig && npm run _ci_make_src-node",
23-
"_ci-release:staging": "npm run _ci-env-warn && npm run _ci-cloneAndBuildPhoenix && cd phoenix && npm run release:staging && cd .. && npm run _ci-createDistReleaseConfig && npm run _ci_make_src-node",
24-
"_ci-release:prod": "npm run _ci-env-warn && npm run _ci-cloneAndBuildPhoenix && cd phoenix && npm run release:prod && cd .. && npm run _ci-createDistReleaseConfig && npm run _ci_make_src-node",
22+
"_ci-release:dev": "npm run _ci-env-warn && npm run _ci-cloneAndBuildPhoenix && cd phoenix && npm run release:dev && cd .. && npm run _ci-setupDistFolders && npm run _ci_make_src-node",
23+
"_ci-release:staging": "npm run _ci-env-warn && npm run _ci-cloneAndBuildPhoenix && cd phoenix && npm run release:staging && cd .. && npm run _ci-setupDistFolders && npm run _ci_make_src-node",
24+
"_ci-release:prod": "npm run _ci-env-warn && npm run _ci-cloneAndBuildPhoenix && cd phoenix && npm run release:prod && cd .. && npm run _ci-setupDistFolders && npm run _ci_make_src-node",
25+
"_ci-releaseElectronApp": "cd src-electron && npm run build:appimage && cd ..",
2526
"_ci-update-phcode-build": "node src-build/update-phcode-build.js",
2627
"serve": "node src-build/serveForPlatform.js",
2728
"serve:tauri": "node src-build/serveForPlatform.js tauri",
@@ -48,4 +49,4 @@
4849
"branch": "tauri",
4950
"commit": "a6a2bcaaeadb8ad2a8320492640672dcdc1981f3"
5051
}
51-
}
52+
}
Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function replaceBundleIdentifierString(sourceStr, newIdentifier) {
4949
return sourceStr.replace(IDENTIFIER_PLACEHOLDER, newIdentifier);
5050
}
5151

52-
async function ciCreateDistReleaseConfig() {
52+
function ciCreateTauriDistReleaseConfig() {
5353
const phoenixConfigPath = join(__dirname, '..', 'phoenix', 'dist', 'config.json');
5454
const packageJSONPath = join(__dirname, '..', 'package.json');
5555
const tauriTOMLPath = join(__dirname, '..', 'src-tauri', 'Cargo.toml');
@@ -133,4 +133,50 @@ async function ciCreateDistReleaseConfig() {
133133
return phoenixVersion;
134134
}
135135

136-
await ciCreateDistReleaseConfig();
136+
function createElectronReleaseAssets() {
137+
console.log("=== Setting up Electron release assets ===");
138+
const projectRoot = join(__dirname, '..');
139+
const electronDir = join(projectRoot, 'src-electron');
140+
141+
// 1. Copy phoenix/dist/ to src-electron/phoenix-dist/
142+
const phoenixDistSrc = join(projectRoot, 'phoenix', 'dist');
143+
const phoenixDistDest = join(electronDir, 'phoenix-dist');
144+
console.log('Copying phoenix dist to:', phoenixDistDest);
145+
// Remove existing and copy fresh
146+
if (fs.existsSync(phoenixDistDest)) {
147+
fs.rmSync(phoenixDistDest, { recursive: true });
148+
}
149+
fs.cpSync(phoenixDistSrc, phoenixDistDest, { recursive: true });
150+
151+
// 2. Create config-effective.json based on environment
152+
const configPath = join(electronDir, 'config.json');
153+
const configEffectivePath = join(electronDir, 'config-effective.json');
154+
155+
// Read phoenix/dist/config.json for environment
156+
const phoenixDistConfigPath = join(projectRoot, 'phoenix', 'dist', 'config.json');
157+
const phoenixDistConfig = JSON.parse(fs.readFileSync(phoenixDistConfigPath));
158+
const environment = phoenixDistConfig.config.environment; // "dev", "stage", or "production"
159+
160+
// Map environment to config file
161+
const envConfigMap = {
162+
'dev': 'config-dev.json',
163+
'stage': 'config-staging.json',
164+
'production': 'config-prod.json'
165+
};
166+
const envConfigFile = envConfigMap[environment] || 'config-dev.json';
167+
const envConfigPath = join(electronDir, envConfigFile);
168+
169+
console.log(`Environment: ${environment} -> using ${envConfigFile}`);
170+
171+
// Merge config.json + env-specific config
172+
const baseConfig = JSON.parse(fs.readFileSync(configPath));
173+
const envConfig = JSON.parse(fs.readFileSync(envConfigPath));
174+
const effectiveConfig = { ...baseConfig, ...envConfig };
175+
176+
console.log('phoenixLoadURL:', effectiveConfig.phoenixLoadURL);
177+
console.log('gaMetricsURL:', effectiveConfig.gaMetricsURL);
178+
fs.writeFileSync(configEffectivePath, JSON.stringify(effectiveConfig, null, 2));
179+
}
180+
181+
ciCreateTauriDistReleaseConfig();
182+
createElectronReleaseAssets();

src-tauri/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,12 @@ fn main() {
542542
std::process::exit(0);
543543
}
544544
#[cfg(target_os = "macos")]{
545-
tauri_plugin_deep_link::prepare("io.phcode");
545+
tauri_plugin_deep_link::prepare("io.phcode.dev");
546546
}
547547

548548
// warning: any string that resembles the following strings will be rewritten in source in prod by build scripts.
549549
// This is so that app bundle IDs are correct. IF they are app bundle IDs use the strings. else dont.
550-
// do not use strings: "io.phcode.dev" "io.phcode.staging" "io.phcode" for anything other than bundle identifiers
550+
// do not use strings: "TAURI_BUNDLE_IDENTIFIER_PLACE_HOLDER" "TAURI_BUNDLE_IDENTIFIER_PLACE_HOLDER" "io.phcode" for anything other than bundle identifiers
551551
// in this file!!!
552552

553553
// GUI apps on macOS and Linux do not inherit the $PATH from your shell dotfiles (.bashrc, .bash_profile, .zshrc, etc).

src-tauri/tauri.conf.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"build": {
44
"beforeBuildCommand": "",
55
"devPath": "http://localhost:8000/src/",
6-
"distDir": "../src/",
6+
"distDir": "../phoenix/dist/",
77
"withGlobalTauri": true
88
},
99
"package": {
@@ -434,8 +434,8 @@
434434
]
435435
},
436436
{
437-
"scheme": "http",
438-
"domain": "localhost:8000",
437+
"scheme": "https",
438+
"domain": "dev.phcode.dev",
439439
"enableTauriAPI": true,
440440
"windows": [
441441
"healthData"
@@ -464,19 +464,20 @@
464464
"width": 1366,
465465
"minWidth": 800,
466466
"acceptFirstMouse": true,
467-
"fileDropEnabled": false
467+
"fileDropEnabled": false,
468+
"url": "phtauri://localhost/v5.1.0/"
468469
},
469470
{
470471
"label": "healthData",
471472
"title": "Health data window",
472-
"url": "http://localhost:8000/src/desktop-metrics.html",
473+
"url": "https://dev.phcode.dev/desktop-metrics.html",
473474
"visible": false,
474475
"fileDropEnabled": false
475476
},
476477
{
477478
"label": "fileDrop",
478479
"title": "Drop To Open Files",
479-
"url": "http://localhost:8000/src/drop-files.html",
480+
"url": "phtauri://localhost/v5.1.0/drop-files.html",
480481
"visible": false,
481482
"fileDropEnabled": true,
482483
"decorations": false

0 commit comments

Comments
 (0)