Skip to content

Commit c238aa0

Browse files
committed
Codemanager installer codemg-setup.msi using WiX Toolset v5. ✨🎉
- Generating custom `codemg-setup.msi` installer using `wix toolset`. - Python scripts Error printing into `stderr` stream. - In-activated Tauri bundle creation: `msi, nish`.
1 parent 6f3b184 commit c238aa0

File tree

10 files changed

+193
-94
lines changed

10 files changed

+193
-94
lines changed

.github/workflows/build_and_release.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ on:
44
push:
55
branches:
66
- "main"
7+
- "development"
78
tags:
8-
- "e*"
9+
- "v*"
10+
- "beta-*"
911

1012
permissions: write-all
1113

@@ -72,6 +74,11 @@ jobs:
7274
with:
7375
bun-version: "1.1.13"
7476

77+
- name: Set up MSBuild
78+
uses: microsoft/setup-msbuild@v2
79+
with:
80+
msbuild-architecture: "x64"
81+
7582
- name: Install OpenSSL using vcpkg
7683
if: steps.cache-libraries.outputs.cache-hit != 'true'
7784
shell: pwsh
@@ -88,29 +95,18 @@ jobs:
8895

8996
- name: Install dependencies
9097
run: |
98+
dotnet tool install --global wix
9199
bun pys fullinstall
92100
93-
- name: Build Tauri catch-dependencies
94-
if: startsWith(github.ref, 'refs/heads/')
95-
env:
96-
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
97-
OPENSSL_DIR: ${{ github.workspace }}\vcpkg\installed\x64-windows
98-
VCPKGRS_DYNAMIC: 1
99-
100-
JWT_SECRET: ${{ secrets.JWT_SECRET }}
101-
SQLITE_DB_KEY: ${{ secrets.SQLITE_DB_KEY }}
102-
run: |
103-
bun tauri build
104-
105101
- name: Build Components
106-
if: startsWith(github.ref, 'refs/tags/')
107102
env:
108103
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
109104
OPENSSL_DIR: ${{ github.workspace }}\vcpkg\installed\x64-windows
110105
VCPKGRS_DYNAMIC: 1
111106

112107
JWT_SECRET: ${{ secrets.JWT_SECRET }}
113108
SQLITE_DB_KEY: ${{ secrets.SQLITE_DB_KEY }}
109+
UPGRADE_CODE: ${{ vars.UPGRADE_CODE }}
114110
run: |
115111
./.venv/Scripts/activate
116112
bun pys build
@@ -122,4 +118,4 @@ jobs:
122118
name: Release ${{ needs.get_tag.outputs.tag_name }}
123119
tag_name: ${{ needs.get_tag.outputs.tag_name }}
124120
body_path: CHANGELOG.md
125-
files: dist/codemg-setup.exe
121+
files: dist/codemg-setup.msi

CHANGELOG.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
Rebuilt the codemanager using Tauri ✨🎉
1+
Codemanager installer `codemg-setup.msi` using `WiX Toolset v5`. ✨🎉
22

3-
- Using Rust backend at the app background.
4-
- Completed The app development to an end usable by the end user.
5-
- Automated GitHub Actions to build final `codemg-setup` installer.
6-
- Cached previous GitHub Actions dependencies to reduce Build time.
7-
- Compressed all installation dependencies into `codemg-setup` installer, reducing all the Release assets and size.
8-
- Rewrote project automation scripts in `python`.
3+
- Generating custom `codemg-setup.msi` installer using `wix toolset`.
4+
- Python scripts Error printing into `stderr` stream.
5+
- In-activated Tauri bundle creation: `msi, nish`.

scripts/lib/config/codebase.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22
from . import Path
3-
from .consumer import codemanagerApp_setup_name, codemgCLI_name, codemgCLI_exe_name
43

54

65
CODEBASE_DIR = Path.cwd()
@@ -17,37 +16,42 @@
1716
pip_path = PYTHON_VENV_SCRIPTS_DIR / "pip.exe"
1817
pyinstaller_path = PYTHON_VENV_SCRIPTS_DIR / "pyinstaller.exe"
1918

20-
secrets_path = BUILD_DIR / ".env"
19+
secrets_build_path = BUILD_DIR / ".env"
2120

2221
# Tauri Config
2322
tauri_conf_path = TAURI_DIR / "tauri.conf.json"
24-
tauri_msi_dir = TAURI_DIR / "target/release/bundle/msi"
23+
tauri_release_dir = TAURI_DIR / "target/release"
2524

2625

2726
# Tauri Package Config
2827
with open(tauri_conf_path) as f:
29-
tauri_conf_package = json.load(f)["package"]
28+
tauri_conf_data = json.load(f)
29+
tauri_conf_package = tauri_conf_data["package"]
30+
tauri_conf_bundle = tauri_conf_data["tauri"]["bundle"]
3031

32+
app_manufacturer = "cloutcoders"
3133
app_name = tauri_conf_package["productName"]
3234
app_version = tauri_conf_package["version"]
35+
app_identifier = tauri_conf_bundle["identifier"]
3336

3437

3538
############################# #-#-# CodeManager Build Config #-#-# #############################
3639

3740
# CodeManager-App config
38-
codemanagerApp_setup_init_path = (
39-
tauri_msi_dir / f"{app_name}_{app_version}_x64_en-US.msi"
40-
)
41-
codemanagerApp_setup_path = DIST_DIR / codemanagerApp_setup_name
41+
codemanagerApp_exe_name = "codemanager.exe"
42+
codemanagerApp_exe_path = tauri_release_dir / codemanagerApp_exe_name
4243

4344
# codemg-CLI config
45+
codemgCLI_name = "codemg"
46+
codemgCLI_exe_name = f"{codemgCLI_name}.exe"
4447
codemgCLI_source = SCRIPTS_DIR / "codemg_cli.py"
4548
codemgCLI_exe_path = DIST_DIR / codemgCLI_exe_name
4649

4750
# Config: CodeManager-Setup
4851
codemanagerSetup_name = "codemg-setup"
49-
codemanagerSetup_exe_name = f"{codemanagerSetup_name}.exe"
50-
codemanagerSetup_source = SCRIPTS_DIR / "setup.py"
51-
codemanagerSetup_exe_path = DIST_DIR / codemanagerSetup_exe_name
52+
codemanagerSetup_msi_name = f"{codemanagerSetup_name}.msi"
53+
codemanagerSetup_source = CODEBASE_DIR / "wix/codemg-setup.wsx"
54+
codemanagerSetup_msi_path = DIST_DIR / codemanagerSetup_msi_name
55+
codemanagerSCC_sidecar_path = tauri_release_dir / "scc.exe"
5256

5357
############################# #-#-# CodeManager Build Config #-#-# #############################

scripts/lib/config/consumer.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,3 @@
2222
autoStartup_registryKey_path = r"Software\Microsoft\Windows\CurrentVersion\Run"
2323

2424
############################ #-#-# Windows Config - [End] #-#-# ############################
25-
26-
27-
############################# #-#-# CodeManager Installation Config #-#-# #############################
28-
29-
# CodeManager App config
30-
codemanagerApp_setup_name = "codemanager.msi"
31-
codemanagerApp_setup_path = MEIPASS_PATH / codemanagerApp_setup_name
32-
33-
# codemg CLI config
34-
codemgCLI_name = "codemg"
35-
codemgCLI_exe_name = f"{codemgCLI_name}.exe"
36-
codemgCLI_exe_init_path = MEIPASS_PATH / codemgCLI_exe_name
37-
codemgCLI_exe_path = EXECUTABLES_DIR / codemgCLI_exe_name
38-
39-
############################# #-#-# Codemanager Installation Config - [END] #-#-# #############################

scripts/lib/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import zipfile
2-
import os, shutil, pathlib
2+
import os, sys, shutil, pathlib
33
from .config import consumer as config
44
from typing import TypeAlias, Literal
55

66
StrOrBytesPath: TypeAlias = str | bytes | os.PathLike[str] | os.PathLike[bytes]
77

88

9+
# Console printing
10+
def eprint(*args, **kwargs):
11+
return print(*args, file=sys.stderr, **kwargs)
12+
13+
914
# Process Handeling
1015
def find_process_by_name(process_name: str):
1116
import psutil

scripts/project_scripts.py

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
import os, sys, shutil
1+
from typing import Literal
2+
import os, sys, pathlib
23
import lib.config.codebase as config
34
from lib.config.consumer import signing_key_name
4-
from lib.utils import run_command
5+
from lib.utils import run_command, eprint
6+
7+
8+
def build_component(
9+
name: str,
10+
command: list[str | pathlib.Path],
11+
output: Literal["shell", "none"] = "none",
12+
):
13+
print(f"Generating {name}...", end="", flush=True)
14+
if run_command(command, output):
15+
eprint("\nBuild Abroaded.")
16+
exit(1)
17+
print("done.")
518

619

720
def build_codemg_setup():
@@ -12,11 +25,12 @@ def build_codemg_setup():
1225
os.makedirs(config.BUILD_DIR)
1326

1427
# Writing seperate Secrets file for production
15-
with open(config.secrets_path, "w") as file:
28+
with open(config.secrets_build_path, "w") as file:
1629
file.write(f'{signing_key_name}="{os.environ.get(signing_key_name)}"')
1730

1831
# Making: codemg-CLI
19-
run_command(
32+
build_component(
33+
"codemg cli",
2034
[
2135
config.pyinstaller_path,
2236
config.codemgCLI_source,
@@ -28,36 +42,45 @@ def build_codemg_setup():
2842
#
2943
# Secrets
3044
"--add-data",
31-
f"{config.secrets_path}:./",
45+
f"{config.secrets_build_path}:./",
3246
],
33-
output="none",
3447
)
3548

36-
# Making: CodeManager-App
37-
run_command(["bun", "tauri", "build"])
38-
shutil.copy2(
39-
config.codemanagerApp_setup_init_path,
40-
config.codemanagerApp_setup_path,
41-
)
49+
# Making: CodeManager
50+
build_component("CodeManager", ["bun", "tauri", "build"], "shell")
4251

43-
# Making: CodeManager-Setup
44-
run_command(
52+
# Making: codemg-Setup
53+
upgradeCode = os.environ.get("UPGRADE_CODE")
54+
build_component(
55+
"codemg-setup executable",
4556
[
46-
config.pyinstaller_path,
57+
"wix",
58+
"build",
4759
config.codemanagerSetup_source,
48-
"-n",
49-
config.codemanagerSetup_name,
50-
"--onefile",
51-
"--specpath",
52-
config.BUILD_DIR,
60+
"-o",
61+
config.codemanagerSetup_msi_path,
5362
#
54-
# CLI
55-
"--add-binary",
56-
f"{config.codemgCLI_exe_path}:./",
63+
# App Info
64+
"-d",
65+
f"appName={config.app_name}",
66+
"-d",
67+
f"appVersion={config.app_version}",
68+
"-d",
69+
f"appManufacturer={config.app_manufacturer}",
70+
"-d",
71+
f"appIdentifier={config.app_identifier}",
72+
"-d",
73+
f"upgradeCode={upgradeCode}",
5774
#
58-
# App
59-
"--add-binary",
60-
f"{config.codemanagerApp_setup_path}:./",
75+
# Components Info
76+
"-d",
77+
f"iconPath={config.codemanagerApp_exe_path}",
78+
"-d",
79+
f"codemgCLIPath={config.codemgCLI_exe_path}",
80+
"-d",
81+
f"codemamagerPath={config.codemanagerApp_exe_path}",
82+
"-d",
83+
f"sccSidecarPath={config.codemanagerSCC_sidecar_path}",
6184
],
6285
)
6386

scripts/setup.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

src-tauri/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn write_secrets(env_vars: Vec<&str>, file_path: &str) {
1616

1717
fn main() {
1818
dotenv().ok();
19+
1920
let env_variables: Vec<&str> = vec!["JWT_SECRET", "SQLITE_DB_KEY"];
2021
write_secrets(env_variables, "src/secrets.rs");
2122

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"csp": null
4747
},
4848
"bundle": {
49-
"active": true,
49+
"active": false,
5050
"targets": "all",
5151
"identifier": "com.cloutcoders.codemg",
5252
"icon": [

0 commit comments

Comments
 (0)