-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild_release.sh
More file actions
executable file
·90 lines (75 loc) · 2.23 KB
/
build_release.sh
File metadata and controls
executable file
·90 lines (75 loc) · 2.23 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
#!/bin/bash
# Build script for creating release binaries locally
# This mimics what the GitHub Actions workflow does
set -euo pipefail
VERSION=${1:-"dev"}
OUTPUT_DIR="dist"
echo "🔨 Building Amber CLI v${VERSION}"
# Clean previous builds
rm -rf "${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}"
# Get current platform
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "${OS}" in
"darwin")
TARGET="darwin-arm64"
BUILD_CLI="crystal build src/amber_cli.cr -o amber --release"
BUILD_LSP="crystal build src/amber_lsp.cr -o amber-lsp --release"
CHECKSUM_CMD="shasum -a 256"
if [ "${ARCH}" != "arm64" ]; then
echo "⚠️ Warning: Building for ARM64 on ${ARCH} architecture"
echo " This will create a native build for your current architecture"
fi
;;
"linux")
TARGET="linux-x86_64"
BUILD_CLI="crystal build src/amber_cli.cr -o amber --release --static"
BUILD_LSP="crystal build src/amber_lsp.cr -o amber-lsp --release --static"
CHECKSUM_CMD="sha256sum"
;;
*)
echo "❌ Unsupported OS: ${OS}"
exit 1
;;
esac
echo "🎯 Building for target: ${TARGET}"
# Install dependencies
echo "📦 Installing dependencies..."
if [ -f shard.lock ]; then
shards install --production
else
shards install
fi
# Build binaries
echo "🔨 Compiling amber CLI..."
eval "${BUILD_CLI}"
echo "🔨 Compiling amber-lsp..."
eval "${BUILD_LSP}"
# Verify binaries
echo "✅ Verifying binaries..."
file amber
./amber --version
file amber-lsp
test -x amber-lsp
# Create archive
echo "📦 Creating archive..."
tar -czf "${OUTPUT_DIR}/amber_cli-${TARGET}.tar.gz" amber amber-lsp
# Calculate checksum
echo "🔢 Calculating checksum..."
cd "${OUTPUT_DIR}"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "amber_cli-${TARGET}.tar.gz" > "amber_cli-${TARGET}.tar.gz.sha256"
else
${CHECKSUM_CMD} "amber_cli-${TARGET}.tar.gz" > "amber_cli-${TARGET}.tar.gz.sha256"
fi
SHA256=$(cut -d' ' -f1 < "amber_cli-${TARGET}.tar.gz.sha256")
echo ""
echo "🎉 Build complete!"
echo "📁 Output: ${OUTPUT_DIR}/amber_cli-${TARGET}.tar.gz"
echo "🔑 SHA256: ${SHA256}"
echo ""
echo "To test the archive:"
echo " tar -xzf ${OUTPUT_DIR}/amber_cli-${TARGET}.tar.gz"
echo " ./amber --version"
echo " test -x ./amber-lsp"