-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·99 lines (77 loc) · 2.65 KB
/
build.sh
File metadata and controls
executable file
·99 lines (77 loc) · 2.65 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
set -e
# Function to filter logs
filter_logs() {
grep -v "^Downloading: " | grep -v "^Downloaded: "
}
# Start logging with filter
exec > >(filter_logs | tee build-log.txt) 2>&1
echo "=== Starting build script ==="
# Install dependencies
echo "Installing yarn globally..."
npm i -g yarn
curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.sh
chmod +x linux-install.sh
./linux-install.sh
export PATH=/tmp/clojure/bin:$PATH
echo "Installing project dependencies with yarn..."
yarn install
# Build the app
npx shadow-cljs release app
# Copy README.md into public/app directory
cp README.md public/app
# Install Vercel Blob SDK
npm install @vercel/blob
# Save the Node.js script to a file
cat > upload-files.js << 'EOF'
const { readFileSync } = require('fs');
const { join } = require('path');
const { put } = require('@vercel/blob');
// Define the directory where our built files live
const distPath = join(__dirname, 'public', 'app');
// Files to be uploaded
const files = ['README.md', 'extension.js'];
// Retrieve environment variables or defaults
const resolvedBranch = process.env.VERCEL_GIT_COMMIT_REF || process.env.BRANCH || 'main';
const resolvedWorkspace = process.env.VERCEL_GIT_REPO_SLUG || process.env.WORKSPACE || 'myworkspace';
const token = process.env.BLOB_READ_WRITE_TOKEN || 'your_blob_token_here';
(async () => {
for (const file of files) {
const filePath = join(distPath, file);
console.log(`DEBUG: Attempting to read file: ${filePath}`);
let content;
try {
content = readFileSync(filePath);
} catch (error) {
console.error(`ERROR: Failed to read file ${file}:`, error);
process.exit(1);
}
const pathname = resolvedBranch === 'main'
? `releases/${resolvedWorkspace}/${file}`
: `releases/${resolvedWorkspace}/${resolvedBranch}/${file}`;
try {
const blob = await put(pathname, content, {
access: 'public',
allowOverwrite: true,
addRandomSuffix: false,
token,
});
} catch (error) {
console.error(`ERROR: Upload failed for ${file}:`, error);
process.exit(1);
}
}
console.log("=== Deploy completed successfully! ===");
const url = resolvedBranch === 'main'
? `https://discoursegraphs.com/releases/${resolvedWorkspace}`
: `https://discoursegraphs.com/releases/${resolvedWorkspace}/${resolvedBranch}`;
console.log(`✅ DEBUG: Endpoint URL: ${url}`);
})();
EOF
# Run the upload script
node upload-files.js
echo "=== Build script finished ==="
# Optional: Display important build artifacts
echo "=== Build Summary ==="
echo "Files in public/app directory:"
ls -la public/app