Skip to content

Commit 89e6be7

Browse files
AlexMikhalevclaude
andcommitted
fix(packaging): complete build-all-formats.sh with all format scripts
- Fix duplicate regex dependency in terraphim_automata/Cargo.toml - Add individual build scripts for deb, rpm, arch, appimage, flatpak, snap - Fix scope bug in build-all-formats.sh where format variable was out of scope - Add proper artifact collection from multiple directories - Add build result tracking and summary reporting - Make scripts cross-platform compatible Co-Authored-By: Terraphim AI <noreply@anthropic.com>
1 parent cf1ffcc commit 89e6be7

10 files changed

Lines changed: 646 additions & 82 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/terraphim_automata/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ahash = { version = "0.8.6", features = ["serde"] }
1919
aho-corasick = "1.0.2"
2020
regex = "1.10"
2121
fst = "0.4"
22-
regex = "1.10.0"
2322
bincode = "1.3"
2423
reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false, optional = true }
2524
serde = { version = "1.0.163", features = ["derive"] }

packaging/scripts/build-all-formats.sh

100644100755
Lines changed: 155 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,200 @@
11
#!/bin/bash
22
# packaging/scripts/build-all-formats.sh
33
# Universal build script for all Linux package formats
4-
# Usage: ./build-all-formats.sh [version]
4+
# Usage: ./build-all-formats.sh [version] [formats...]
5+
#
6+
# Examples:
7+
# ./build-all-formats.sh # Build all formats
8+
# ./build-all-formats.sh 1.4.10 # Build all formats with specific version
9+
# ./build-all-formats.sh 1.4.10 deb rpm # Build only deb and rpm
10+
#
11+
# Supported formats: deb, rpm, arch, appimage, flatpak, snap
512

613
set -euo pipefail
714

8-
VERSION="${1:-1.0.0}"
15+
VERSION="${1:-}"
16+
shift || true
17+
18+
# Get version from Cargo.toml if not provided
19+
if [[ -z "$VERSION" ]]; then
20+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
21+
VERSION=$(grep '^version' "$ROOT/crates/terraphim_agent/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
22+
fi
23+
924
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
1025
PACKAGING_ROOT="$ROOT/packaging"
26+
RELEASE_DIR="$ROOT/release-artifacts"
1127

1228
echo "====================================================================="
13-
echo "🚀 Building all Linux package formats for Terraphim AI v$VERSION"
29+
echo "Building all Linux package formats for Terraphim AI v$VERSION"
1430
echo "====================================================================="
1531
echo ""
1632

1733
# Create release directory
18-
mkdir -p "$ROOT/release-artifacts"
34+
mkdir -p "$RELEASE_DIR"
1935

2036
# Setup Tauri signing if available
2137
if [[ -f "$HOME/.tauri/tauriconfig" ]]; then
38+
# shellcheck source=/dev/null
2239
source "$HOME/.tauri/tauriconfig"
23-
echo "🔐 Using configured Tauri signing keys"
40+
echo "Using configured Tauri signing keys"
41+
else
42+
echo "Note: Tauri signing not configured, building unsigned packages"
43+
fi
44+
45+
# Determine which formats to build
46+
if [[ $# -gt 0 ]]; then
47+
FORMATS=("$@")
2448
else
25-
echo "⚠️ Tauri signing not configured, building unsigned packages"
49+
FORMATS=("deb" "rpm" "arch" "appimage" "flatpak" "snap")
2650
fi
2751

52+
# Track build results
53+
declare -A BUILD_RESULTS
54+
2855
# Function to build specific format
2956
build_format() {
3057
local format="$1"
31-
echo "🔧 Building $format packages..."
32-
33-
case "$format" in
34-
"deb")
35-
"$PACKAGING_ROOT/scripts/build-deb.sh"
36-
;;
37-
"rpm")
38-
"$PACKAGING_ROOT/scripts/build-rpm.sh"
39-
;;
40-
"arch")
41-
"$PACKAGING_ROOT/scripts/build-arch.sh"
42-
;;
43-
"appimage")
44-
"$PACKAGING_ROOT/scripts/build-appimage.sh"
45-
;;
46-
"flatpak")
47-
"$PACKAGING_ROOT/scripts/build-flatpak.sh"
48-
;;
49-
"snap")
50-
"$PACKAGING_ROOT/scripts/build-snap.sh"
51-
;;
52-
*)
53-
echo "❌ Unknown format: $format"
54-
return 1
55-
;;
56-
esac
57-
58-
echo "$format build complete"
58+
local script="$PACKAGING_ROOT/scripts/build-$format.sh"
59+
60+
echo "---------------------------------------------------------------------"
61+
echo "Building $format packages..."
62+
echo "---------------------------------------------------------------------"
63+
64+
if [[ ! -x "$script" ]]; then
65+
if [[ -f "$script" ]]; then
66+
chmod +x "$script"
67+
else
68+
echo "Warning: Build script not found: $script"
69+
BUILD_RESULTS[$format]="skipped"
70+
return 0
71+
fi
72+
fi
73+
74+
if "$script"; then
75+
BUILD_RESULTS[$format]="success"
76+
echo "$format build complete"
77+
else
78+
BUILD_RESULTS[$format]="failed"
79+
echo "Warning: $format build failed"
80+
fi
5981
echo ""
6082
}
6183

62-
# Build all formats
63-
FORMATS=("deb" "rpm" "arch" "appimage" "flatpak" "snap")
84+
# Build release binaries first (shared by multiple formats)
85+
echo "Building release binaries..."
86+
cargo build --release -p terraphim_agent 2>&1 || {
87+
echo "Error: Failed to build release binaries"
88+
exit 1
89+
}
90+
echo ""
6491

92+
# Build each format
6593
for format in "${FORMATS[@]}"; do
66-
build_format "$format"
94+
build_format "$format" || true
6795
done
6896

69-
# Move all artifacts to release directory
70-
echo "📦 Collecting artifacts..."
71-
find "$PACKAGING_ROOT" -name "*.$format" -o -name "*.AppImage" -o -name "*.flatpak" -o -name "*.snap" | while read -r artifact; do
72-
cp "$artifact" "$ROOT/release-artifacts/"
73-
done
97+
# Collect all artifacts to release directory
98+
echo "====================================================================="
99+
echo "Collecting artifacts..."
100+
echo "====================================================================="
101+
102+
# Collect from various output directories
103+
collect_artifacts() {
104+
local src_dir="$1"
105+
local pattern="$2"
106+
107+
if [[ -d "$src_dir" ]]; then
108+
find "$src_dir" -maxdepth 2 -name "$pattern" -type f 2>/dev/null | while read -r artifact; do
109+
cp -v "$artifact" "$RELEASE_DIR/" 2>/dev/null || true
110+
done
111+
fi
112+
}
113+
114+
# Collect all package types
115+
collect_artifacts "$ROOT/target/debian" "*.deb"
116+
collect_artifacts "$ROOT/target/rpm" "*.rpm"
117+
collect_artifacts "$ROOT/target/arch" "*.pkg.tar*"
118+
collect_artifacts "$ROOT/target/appimage" "*.AppImage"
119+
collect_artifacts "$ROOT/target/flatpak" "*.flatpak"
120+
collect_artifacts "$ROOT/target/snap" "*.snap"
121+
122+
# Also collect from Tauri bundle directory
123+
if [[ -d "$ROOT/desktop/src-tauri/target/release/bundle" ]]; then
124+
collect_artifacts "$ROOT/desktop/src-tauri/target/release/bundle/deb" "*.deb"
125+
collect_artifacts "$ROOT/desktop/src-tauri/target/release/bundle/rpm" "*.rpm"
126+
collect_artifacts "$ROOT/desktop/src-tauri/target/release/bundle/appimage" "*.AppImage"
127+
fi
74128

75129
# Generate checksums
76-
echo "🔐 Generating checksums..."
77-
cd "$ROOT/release-artifacts"
78-
sha256sum * > checksums.txt
130+
if [[ -n "$(ls -A "$RELEASE_DIR" 2>/dev/null)" ]]; then
131+
echo ""
132+
echo "Generating checksums..."
133+
(cd "$RELEASE_DIR" && sha256sum ./* > checksums.txt 2>/dev/null) || true
134+
fi
79135

80136
# Display results
81137
echo ""
82138
echo "====================================================================="
83-
echo "📋 Build Summary"
139+
echo "Build Summary"
84140
echo "====================================================================="
85-
echo "Release artifacts created:"
86-
ls -la
87141

88142
echo ""
89-
echo "🔐 Checksums available in: checksums.txt"
143+
echo "Build results:"
144+
for format in "${!BUILD_RESULTS[@]}"; do
145+
status="${BUILD_RESULTS[$format]}"
146+
case "$status" in
147+
"success") marker="[OK]" ;;
148+
"failed") marker="[FAIL]" ;;
149+
"skipped") marker="[SKIP]" ;;
150+
*) marker="[?]" ;;
151+
esac
152+
printf " %-10s %s\n" "$format:" "$marker"
153+
done
90154

91-
# Verify package sizes
92155
echo ""
93-
echo "📊 Package sizes:"
94-
for file in *.deb *.rpm *.pkg.tar* *.AppImage *.flatpak *.snap; do
95-
if [[ -f "$file" ]]; then
96-
size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null || echo "unknown")
97-
echo " $file: $(numfmt --to=iec-i --suffix=B "$size")"
98-
fi
156+
echo "Release artifacts:"
157+
if [[ -d "$RELEASE_DIR" ]] && [[ -n "$(ls -A "$RELEASE_DIR" 2>/dev/null)" ]]; then
158+
ls -lh "$RELEASE_DIR"
159+
else
160+
echo " (no artifacts found)"
161+
fi
162+
163+
echo ""
164+
echo "Checksums available in: $RELEASE_DIR/checksums.txt"
165+
166+
# Package sizes
167+
echo ""
168+
echo "Package sizes:"
169+
shopt -s nullglob
170+
for ext in deb rpm pkg.tar.zst pkg.tar.xz AppImage flatpak snap; do
171+
for file in "$RELEASE_DIR"/*."$ext"; do
172+
if [[ -f "$file" ]]; then
173+
size=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null || echo "0")
174+
if command -v numfmt &> /dev/null; then
175+
size_human=$(numfmt --to=iec-i --suffix=B "$size" 2>/dev/null || echo "${size}B")
176+
else
177+
size_human="${size}B"
178+
fi
179+
printf " %-40s %s\n" "$(basename "$file"):" "$size_human"
180+
fi
181+
done
99182
done
183+
shopt -u nullglob
100184

185+
# Final status
101186
echo ""
102-
echo "🎉 All package formats built successfully!"
103-
echo "====================================================================="
187+
echo "====================================================================="
188+
failed_count=0
189+
for status in "${BUILD_RESULTS[@]}"; do
190+
[[ "$status" == "failed" ]] && ((failed_count++)) || true
191+
done
192+
193+
if [[ $failed_count -eq 0 ]]; then
194+
echo "All requested package formats built successfully!"
195+
else
196+
echo "Warning: $failed_count format(s) failed to build."
197+
fi
198+
echo "====================================================================="
199+
200+
exit 0
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
# packaging/scripts/build-appimage.sh
3+
# Build AppImage using appimagetool or Tauri
4+
# Usage: ./build-appimage.sh [--cli|--desktop]
5+
6+
set -euo pipefail
7+
8+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
9+
OUTPUT_DIR="$ROOT/target/appimage"
10+
TARGET="${1:---desktop}"
11+
12+
echo "Building AppImage packages..."
13+
14+
# Create output directory
15+
mkdir -p "$OUTPUT_DIR"
16+
17+
case "$TARGET" in
18+
"--cli")
19+
# Build CLI AppImage using appimagetool
20+
if ! command -v appimagetool &> /dev/null; then
21+
echo "Downloading appimagetool..."
22+
ARCH=$(uname -m)
23+
wget -q "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$ARCH.AppImage" \
24+
-O /tmp/appimagetool
25+
chmod +x /tmp/appimagetool
26+
APPIMAGETOOL="/tmp/appimagetool"
27+
else
28+
APPIMAGETOOL="appimagetool"
29+
fi
30+
31+
# Build release binary
32+
echo "Building release binary..."
33+
cargo build --release -p terraphim_agent
34+
35+
# Create AppDir structure
36+
APPDIR="$OUTPUT_DIR/terraphim-agent.AppDir"
37+
mkdir -p "$APPDIR/usr/bin"
38+
mkdir -p "$APPDIR/usr/share/applications"
39+
mkdir -p "$APPDIR/usr/share/icons/hicolor/256x256/apps"
40+
41+
# Copy binary
42+
cp "$ROOT/target/release/terraphim-agent" "$APPDIR/usr/bin/"
43+
44+
# Create desktop file
45+
cat > "$APPDIR/terraphim-agent.desktop" << EOF
46+
[Desktop Entry]
47+
Type=Application
48+
Name=Terraphim Agent
49+
Exec=terraphim-agent
50+
Icon=terraphim-agent
51+
Categories=Utility;Development;
52+
Terminal=true
53+
EOF
54+
cp "$APPDIR/terraphim-agent.desktop" "$APPDIR/usr/share/applications/"
55+
56+
# Create AppRun
57+
cat > "$APPDIR/AppRun" << 'EOF'
58+
#!/bin/bash
59+
SELF=$(readlink -f "$0")
60+
HERE=${SELF%/*}
61+
export PATH="${HERE}/usr/bin:${PATH}"
62+
exec "${HERE}/usr/bin/terraphim-agent" "$@"
63+
EOF
64+
chmod +x "$APPDIR/AppRun"
65+
66+
# Create placeholder icon if not exists
67+
if [[ ! -f "$APPDIR/terraphim-agent.png" ]]; then
68+
# Create simple placeholder - in production use actual icon
69+
echo "Note: Using placeholder icon. Replace with actual icon."
70+
convert -size 256x256 xc:navy -fill white -gravity center \
71+
-pointsize 48 -annotate 0 "T" \
72+
"$APPDIR/terraphim-agent.png" 2>/dev/null || \
73+
touch "$APPDIR/terraphim-agent.png"
74+
fi
75+
76+
# Build AppImage
77+
VERSION=$(grep '^version' "$ROOT/crates/terraphim_agent/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
78+
ARCH=$(uname -m)
79+
"$APPIMAGETOOL" "$APPDIR" "$OUTPUT_DIR/terraphim-agent-$VERSION-$ARCH.AppImage"
80+
;;
81+
82+
"--desktop"|*)
83+
# Build desktop AppImage using Tauri
84+
echo "Building desktop AppImage using Tauri..."
85+
if [[ ! -d "$ROOT/desktop/src-tauri" ]]; then
86+
echo "Error: Tauri project not found at desktop/src-tauri"
87+
exit 1
88+
fi
89+
90+
(cd "$ROOT/desktop" && yarn tauri build --bundles appimage) || {
91+
echo "Tauri build failed. Ensure yarn and tauri-cli are installed."
92+
exit 1
93+
}
94+
95+
# Copy AppImage to output
96+
find "$ROOT/desktop/src-tauri/target/release/bundle" -name "*.AppImage" \
97+
-exec cp {} "$OUTPUT_DIR/" \;
98+
;;
99+
esac
100+
101+
echo ""
102+
echo "Generated AppImage packages:"
103+
find "$OUTPUT_DIR" -maxdepth 1 -name "*.AppImage" -type f 2>/dev/null | while read -r img; do
104+
echo " $(basename "$img")"
105+
done
106+
107+
echo ""
108+
echo "AppImage packages built successfully!"

0 commit comments

Comments
 (0)