-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·55 lines (48 loc) · 1.67 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·55 lines (48 loc) · 1.67 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
#!/usr/bin/env bash
set -e # Exit on any error
# Inspired by https://github.com/evanw/esbuild/issues/1921#issuecomment-1623640043
# Also a good solution: https://github.com/evanw/esbuild/issues/1921#issuecomment-1898197331
pnpm esbuild src/main.cli.ts \
--bundle \
--platform=node \
--target=esnext \
--format=esm \
--outfile=dist/jrm.js \
--minify \
--banner:js="const require = globalThis.require ?? (await import('node:module')).createRequire(import.meta.url);"
mkdir -p assets
declare -A platforms=(
["x86_64-apple-darwin"]="jrm-Darwin-x86_64"
["aarch64-apple-darwin"]="jrm-Darwin-arm64"
["x86_64-unknown-linux-gnu"]="jrm-Linux-x86_64"
["aarch64-unknown-linux-gnu"]="jrm-Linux-aarch64"
)
if [ -n "$CI" ]; then
# In CI: install deno as before
curl -fsSL https://deno.land/install.sh | sh -s v2.7.14
DENO_CMD="$HOME/.deno/bin/deno"
else
# Not in CI: check if deno command exists
if ! command -v deno &> /dev/null; then
echo "Error: deno command not found! You should install deno first!"
exit 1
fi
DENO_CMD="deno"
fi
for target in "${!platforms[@]}"; do
output_name="${platforms[$target]}"
echo "Building for $target -> assets/$output_name"
# Downloading from github.com will redirect to release-assets.githubusercontent.com
$DENO_CMD compile \
--allow-net="nodejs.org,dl.deno.land,api.github.com,github.com,release-assets.githubusercontent.com,registry.npmjs.org,registry.npmmirror.com,cdn.npmmirror.com" \
--allow-write \
--allow-read \
--allow-env \
--allow-sys \
--no-npm \
--target="$target" \
--output="assets/$output_name" \
dist/jrm.js
done
echo "Build completed! Generated binaries:"
ls -lah assets/