Skip to content

Commit 62eed8e

Browse files
committed
build: releaseDistBundle command to build bundles
1 parent 82f177e commit 62eed8e

File tree

7 files changed

+65
-31
lines changed

7 files changed

+65
-31
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ If you want to generate the release builds locally directly while you are editin
7070
```bash
7171
cd phoenix-desktop
7272
# To generate debug builds:
73-
npm run releaseSrcDebug
74-
# OR to generate release builds, just run `npm run releaseSrc`
73+
npm run releaseSrc
74+
# OR to generate debug builds, just run `npm run releaseSrcDebug`
7575
```
7676
This is the easiest way to quickly debug issues directly from the phoenix source folder.
7777

@@ -86,12 +86,29 @@ npm run build
8686
npm run release:prod
8787
# Other release options are `npm run release:dev` and `npm run release:staging`
8888

89-
# Now generate the tauri debug builds:
89+
# Now generate the tauri release builds:
9090
cd ../phoenix-desktop
91-
npm run releaseDistDebug
92-
# OR to generate release builds, just run `npm run releaseDist`
91+
npm run releaseDist
92+
# OR to debug, just run `npm run releaseDistDebug`
9393
```
9494

95+
#### Generating installers/AppImage and DMGs locally from `phoenix/dist` folder
96+
To generate the installers, use the commands
97+
```bash
98+
# You should first build the appropriate release build in `phoenix`.
99+
cd phoenix
100+
npm install
101+
npm run build
102+
npm run release:prod
103+
# Other release options are `npm run release:dev` and `npm run release:staging`
104+
105+
# Now generate the bundles
106+
cd ../phoenix-desktop
107+
npm run releaseDistBundle
108+
# will generate appimages/DMGs or nsix windows installers in target/release/bundle
109+
```
110+
111+
95112
## Building release binaries and installers in GitHub actions
96113
The npm commands that begin with `_ci-*` are exclusively designed to execute in a GitHub Actions environment.
97114
These commands are not typically executed on your local machine unless you're actively working on the GitHub

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
"tauriBuildDemoApp": "node src-build/createDemoReleaseConfig.js && tauri build --config ./src-tauri/tauri-local.conf.json",
99
"_createSrcReleaseConfig": "node src-build/createSrcReleaseConfig.js",
1010
"_createDistReleaseConfig": "node src-build/createDistReleaseConfig.js",
11+
"_createDistBundleReleaseConfig": "node src-build/createDistBundleReleaseConfig.js",
1112
"_createDistTestReleaseConfig": "node src-build/createDistTestReleaseConfig.js",
1213
"_ci-createDistReleaseConfig": "node src-build/ci-createDistReleaseConfig.js",
1314
"_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.",
1415
"releaseSrc": "npm run _make_src-node && npm run _createSrcReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json",
15-
"releaseSrcDebug": "npm run _make_src-node && npm run _createSrcReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json --debug",
16+
"releaseSrcDebug": "npm run _make_src-node && npm run _createSrcReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json --debug --verbose",
1617
"releaseDist": "npm run _make_src-node && npm run _createDistReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json",
17-
"releaseDistDebug": "npm run _make_src-node && npm run _createDistReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json --debug",
18+
"releaseDistBundle": "npm run _make_src-node && npm run _createDistBundleReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json --verbose",
19+
"releaseDistDebug": "npm run _make_src-node && npm run _createDistReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json --debug --verbose",
1820
"releaseDistTest": "npm run _make_src-node && npm run _createDistTestReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json",
1921
"releaseDistTestDebug": "npm run _make_src-node && npm run _createDistTestReleaseConfig && tauri build --config ./src-tauri/tauri-local.conf.json --debug",
2022
"_src-node_npm_install": "cd src-tauri/src-node && npm ci --production && cd ../../ && npm run _src-node_remove_unsupported_bin",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {fileURLToPath} from "url";
2+
import {dirname} from "path";
3+
import fs from 'fs';
4+
import chalk from 'chalk';
5+
6+
import {getPlatformDetails, patchTauriConfigWithMetricsHTML} from "./utils.js";
7+
import os from "os";
8+
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = dirname(__filename);
11+
12+
async function createDistReleaseConfig() {
13+
const platform = getPlatformDetails().platform;
14+
const tauriConfigPath = (platform === "win") ? `${__dirname}\\..\\src-tauri\\tauri.conf.json`
15+
: `${__dirname}/../src-tauri/tauri.conf.json`;
16+
const tauriLocalConfigPath = (platform === "win") ? `${__dirname}\\..\\src-tauri\\tauri-local.conf.json`
17+
: `${__dirname}/../src-tauri/tauri-local.conf.json`;
18+
console.log("Reading Tauri config file: ", tauriConfigPath);
19+
let configJson = JSON.parse(fs.readFileSync(tauriConfigPath));
20+
console.log(chalk.cyan("\n!Updates and signing is disabled while creating msi, appimage and dmg installers. If you want to sign, use tauri build commands directly.\n"));
21+
configJson.tauri.bundle.active = true;
22+
configJson.tauri.updater.active = false;
23+
configJson.build.distDir = '../../phoenix/dist/';
24+
const phoenixVersion = configJson.package.version;
25+
if(os.platform() === 'win32'){
26+
configJson.tauri.windows[0].url = `https://phtauri.localhost/v${phoenixVersion}/`;
27+
} else {
28+
configJson.tauri.windows[0].url = `phtauri://localhost/v${phoenixVersion}/`;
29+
}
30+
patchTauriConfigWithMetricsHTML(configJson);
31+
console.log("Window Boot url is: ", configJson.tauri.windows[0].url);
32+
console.log("Writing new local config json ", tauriLocalConfigPath);
33+
fs.writeFileSync(tauriLocalConfigPath, JSON.stringify(configJson, null, 4));
34+
}
35+
36+
await createDistReleaseConfig();

src-build/createDistReleaseConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function createDistReleaseConfig() {
1717
: `${__dirname}/../src-tauri/tauri-local.conf.json`;
1818
console.log("Reading Tauri config file: ", tauriConfigPath);
1919
let configJson = JSON.parse(fs.readFileSync(tauriConfigPath));
20-
console.log(chalk.cyan("\n!Only creating executables. Creating msi, appimage and dmg installers are disabled in this build. If you want to create an installer, use: npm run tauri build manually after setting distDir in tauri conf!\n"));
20+
console.log(chalk.cyan("\n!Only creating executables. Creating msi, appimage and dmg installers are disabled in this build. If you want to create an installer, use: npm run releaseDistBundle\n"));
2121
configJson.tauri.bundle.active = false;
2222
configJson.build.distDir = '../../phoenix/dist/';
2323
const phoenixVersion = configJson.package.version;

src-build/createSrcReleaseConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function createSrcReleaseConfig() {
1717
: `${__dirname}/../src-tauri/tauri-local.conf.json`;
1818
console.log("Reading config file: ", tauriConfigPath);
1919
let configJson = JSON.parse(fs.readFileSync(tauriConfigPath));
20-
console.log(chalk.cyan("\n!Only creating executables. Creating msi, appimage and dmg installers are disabled in this build. If you want to create an installer, use: npm run tauri build manually after setting distDir in tauri conf!\n"));
20+
console.log(chalk.cyan("\n!Only creating executables. Creating msi, appimage and dmg installers are disabled in this build. If you want to create an installer, use: npm run releaseDistBundle\n"));
2121
configJson.tauri.bundle.active = false;
2222
configJson.build.distDir = '../../phoenix/src/'
2323
const phoenixVersion = configJson.package.version;

src-tauri/Cargo.lock

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ regex = "1.10.3"
2121
clipboard-files = "0.1.1"
2222
webbrowser = "0.8.12"
2323
serde = { version = "1.0", features = ["derive"] }
24-
tauri = { version = "1.5.4", features = [ "cli", "api-all", "updater", "devtools", "linux-protocol-headers"] }
24+
tauri = { version = "1.5.4", features = [ "cli", "api-all", "devtools", "linux-protocol-headers"] }
2525
winapi = { version = "0.3", features = ["fileapi"] }
2626
tauri-plugin-fs-extra = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
2727
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }

0 commit comments

Comments
 (0)