-
Notifications
You must be signed in to change notification settings - Fork 77
/
Justfile
80 lines (68 loc) · 2.69 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
build-all-platforms:
#!/bin/bash -eux
export AXOASSET_XZ_LEVEL=1
cargo build
./target/debug/dist init --yes
./target/debug/dist build --artifacts all --target aarch64-apple-darwinx,x86_64-apple-darwin,x86_64-pc-windows-msvc,x86_64-unknown-linux-musl
patch-sh-installer:
#!/usr/bin/env node
const fs = require('fs');
const installerUrl = process.env.INSTALLER_DOWNLOAD_URL || 'https://dl.bearcove.cloud/dump/dist-cross';
const installerPath = './target/distrib/cargo-dist-installer.sh';
const content = fs.readFileSync(installerPath, 'utf8');
const lines = content.split('\n');
let modified = false;
const newLines = [];
for (const line of lines) {
if (line.includes('export INSTALLER_DOWNLOAD_URL')) {
continue;
}
if (line.includes('set -u') && !modified) {
modified = true;
newLines.push(line);
newLines.push(`export INSTALLER_DOWNLOAD_URL=${installerUrl} # patched by Justfile in dist repo, using dist_url_override feature`);
continue;
}
newLines.push(line);
}
fs.writeFileSync(installerPath, newLines.join('\n'));
if (modified) {
console.log('\x1b[32m%s\x1b[0m', `✅ ${installerPath} patched successfully!`);
console.log('\x1b[36m%s\x1b[0m', `🔗 Pointing to: ${installerUrl}`);
} else {
console.log('\x1b[31m%s\x1b[0m', '❌ Error: Could not find line with "set -u" in installer script');
}
patch-ps1-installer:
#!/usr/bin/env node
const fs = require('fs');
const installerUrl = process.env.INSTALLER_DOWNLOAD_URL || 'https://dl.bearcove.cloud/dump/dist-cross';
const installerPath = './target/distrib/cargo-dist-installer.ps1';
const content = fs.readFileSync(installerPath, 'utf8');
const lines = content.split('\n');
let modified = false;
const newLines = [];
for (const line of lines) {
if (line.includes('$env:INSTALLER_DOWNLOAD_URL = ')) {
continue;
}
if (line.includes('$app_name = ') && !modified) {
modified = true;
newLines.push(`$env:INSTALLER_DOWNLOAD_URL = "${installerUrl}" # patched by Justfile in dist repo, using dist_url_override feature`);
newLines.push(line);
continue;
}
newLines.push(line);
}
fs.writeFileSync(installerPath, newLines.join('\n'));
if (modified) {
console.log('\x1b[32m%s\x1b[0m', `✅ ${installerPath} patched successfully!`);
console.log('\x1b[36m%s\x1b[0m', `🔗 Pointing to: ${installerUrl}`);
} else {
console.log('\x1b[31m%s\x1b[0m', '❌ Error: Could not find line with "cargo-dist = " in installer script');
}
dump:
#!/bin/bash -eux
just build-all-platforms
just patch-sh-installer
just patch-ps1-installer
mc mirror --overwrite ./target/distrib ${DIST_TARGET:-bearcove/dump/dist-cross}