Skip to content

Commit 81f6ef8

Browse files
EdgarTwiggEdgarTwigg
authored andcommitted
Another attempt.
1 parent bbbe23b commit 81f6ef8

3 files changed

Lines changed: 58 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ jobs:
9595
standalone/src-tauri/target/${{ matrix.target }}/release/bundle/**/*.nsis.zip.sig
9696
standalone/src-tauri/target/${{ matrix.target }}/release/bundle/nsis/**
9797
standalone/src-tauri/target/${{ matrix.target }}/release/nsis/**
98+
standalone/sidecar/**
99+
standalone/src-tauri/binaries/**
98100
99101
build-vscode:
100102
name: Build VSCode Extension

scripts/patch-nsis-paths.pl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env perl
2+
# Patches absolute Windows paths in a Tauri-generated .nsi script so it can
3+
# be rebuilt on macOS/Linux with makensis.
4+
#
5+
# Usage: perl patch-nsis-paths.pl <installer.nsi> <local-artifact-root>
6+
#
7+
# The script extracts the CI checkout root from MAINBINARYSRCPATH, then
8+
# replaces all occurrences with the local artifact root, converting
9+
# backslashes to forward slashes.
10+
11+
use strict;
12+
use warnings;
13+
14+
my $nsi_file = $ARGV[0] or die "Usage: $0 <installer.nsi> <local-artifact-root>\n";
15+
my $local_root = $ARGV[1] or die "Usage: $0 <installer.nsi> <local-artifact-root>\n";
16+
17+
open my $fh, '<', $nsi_file or die "Cannot open $nsi_file: $!";
18+
my $content = do { local $/; <$fh> };
19+
close $fh;
20+
21+
# Extract CI checkout root from MAINBINARYSRCPATH.
22+
# The path looks like: "D:\a\mouseterm\mouseterm\standalone\src-tauri\target\...\mouseterm.exe"
23+
# We want everything before \standalone\src-tauri\
24+
my $ci_root;
25+
if ($content =~ /MAINBINARYSRCPATH\s+"(.+?)\\standalone\\src-tauri\\/) {
26+
$ci_root = $1;
27+
} else {
28+
die "Could not extract CI checkout root from MAINBINARYSRCPATH in $nsi_file\n";
29+
}
30+
print "CI checkout root: $ci_root\n";
31+
print "Local artifact root: $local_root\n";
32+
33+
# Count occurrences before replacement
34+
my $count = 0;
35+
while ($content =~ /\Q$ci_root\E/g) { $count++ }
36+
print "Found $count path(s) to replace\n";
37+
38+
# Replace all occurrences of ci_root...<rest-of-path> with local_root/<rest>,
39+
# converting backslashes to forward slashes in the <rest> portion.
40+
$content =~ s/\Q$ci_root\E([^"]*)/
41+
my $rest = $1;
42+
$rest =~ s{\\}{\/}g;
43+
"$local_root$rest"
44+
/ge;
45+
46+
open my $out, '>', $nsi_file or die "Cannot write $nsi_file: $!";
47+
print $out $content;
48+
close $out;
49+
50+
print "Done. Patched $count path(s).\n";

scripts/sign-and-deploy.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ rebuild_windows_installer() {
145145
local script_dir
146146
script_dir="$(cd "$(dirname "$script_path")" && pwd)"
147147

148-
# The .nsi contains absolute Windows paths that don't exist on macOS.
149-
# Patch MAINBINARYSRCPATH to point to the signed exe.
150-
local abs_signed_exe
151-
abs_signed_exe="$(cd "$(dirname "$signed_exe")" && pwd)/$(basename "$signed_exe")"
152-
sed -i '' "s|^!define MAINBINARYSRCPATH .*|!define MAINBINARYSRCPATH \"$abs_signed_exe\"|" "$script_path"
148+
# The .nsi contains ~60 absolute Windows paths from the CI runner.
149+
# Replace them all with local artifact paths using the helper script.
150+
local artifact_dir
151+
artifact_dir="$(cd "$WORK_DIR/standalone-win-x64" && pwd)"
152+
perl "$SCRIPT_DIR/patch-nsis-paths.pl" "$script_path" "$artifact_dir"
153153

154-
# Patch ADDITIONALPLUGINSPATH to point to the plugin bundled in artifacts.
154+
# Patch ADDITIONALPLUGINSPATH separately — it is outside the checkout tree.
155155
local plugin_dir
156156
plugin_dir=$(find "$WORK_DIR/standalone-win-x64" -name "nsis_tauri_utils.dll" -exec dirname {} \; | head -1)
157157
if [[ -n "$plugin_dir" ]]; then

0 commit comments

Comments
 (0)