-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·155 lines (131 loc) · 4.7 KB
/
release.sh
File metadata and controls
executable file
·155 lines (131 loc) · 4.7 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
# Copyright (c) 2026 Mikhail Matveev <xtreme@rh1.tech>
#
# release.sh - Build FRANK OS release firmware
#
# Usage: ./release.sh [VERSION]
# VERSION - version string (e.g. "1.01"), prompted interactively if omitted
#
# Output: frankos_m2_A_BB_hdmi.uf2 and frankos_m2_A_BB_vga.uf2
# A = Major version
# BB = Minor version (zero-padded)
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Version file
VERSION_FILE="version.txt"
# Read last version or initialize
if [[ -f "$VERSION_FILE" ]]; then
read -r LAST_MAJOR LAST_MINOR < "$VERSION_FILE"
else
LAST_MAJOR=1
LAST_MINOR=0
fi
# Calculate next version (for default suggestion)
NEXT_MINOR=$((LAST_MINOR + 1))
NEXT_MAJOR=$LAST_MAJOR
if [[ $NEXT_MINOR -ge 100 ]]; then
NEXT_MAJOR=$((NEXT_MAJOR + 1))
NEXT_MINOR=0
fi
# Version input: from command line or interactive prompt
echo ""
echo -e "${CYAN}┌─────────────────────────────────────────────────────────────────┐${NC}"
echo -e "${CYAN}│ FRANK OS Release Builder │${NC}"
echo -e "${CYAN}└─────────────────────────────────────────────────────────────────┘${NC}"
echo ""
echo -e "Last version: ${YELLOW}${LAST_MAJOR}.$(printf '%02d' $LAST_MINOR)${NC}"
echo ""
DEFAULT_VERSION="${NEXT_MAJOR}.$(printf '%02d' $NEXT_MINOR)"
# Accept version from command line or prompt interactively
if [[ -n "$1" ]]; then
INPUT_VERSION="$1"
echo -e "Version (from command line): ${CYAN}${INPUT_VERSION}${NC}"
else
read -p "Enter version [default: $DEFAULT_VERSION]: " INPUT_VERSION
INPUT_VERSION=${INPUT_VERSION:-$DEFAULT_VERSION}
fi
# Parse version (handle both "1.00" and "1 00" formats)
if [[ "$INPUT_VERSION" == *"."* ]]; then
MAJOR="${INPUT_VERSION%%.*}"
MINOR="${INPUT_VERSION##*.}"
else
read -r MAJOR MINOR <<< "$INPUT_VERSION"
fi
# Remove leading zeros for arithmetic, then re-pad
MINOR=$((10#$MINOR))
MAJOR=$((10#$MAJOR))
# Validate
if [[ $MAJOR -lt 1 ]]; then
echo -e "${RED}Error: Major version must be >= 1${NC}"
exit 1
fi
if [[ $MINOR -lt 0 || $MINOR -ge 100 ]]; then
echo -e "${RED}Error: Minor version must be 0-99${NC}"
exit 1
fi
# Format version strings
VERSION="${MAJOR}_$(printf '%02d' $MINOR)"
VERSION_DOT="${MAJOR}.$(printf '%02d' $MINOR)"
echo ""
echo -e "${GREEN}Building release version: ${VERSION_DOT}${NC}"
# Save new version
echo "$MAJOR $MINOR" > "$VERSION_FILE"
# Create release directory
RELEASE_DIR="$SCRIPT_DIR/release"
mkdir -p "$RELEASE_DIR"
# Build both HDMI and VGA variants
VARIANTS=("DVI:hdmi" "VGA:vga")
for variant in "${VARIANTS[@]}"; do
CMAKE_VAL="${variant%%:*}"
SUFFIX="${variant##*:}"
OUTPUT_NAME="frankos_m2_${VERSION}_${SUFFIX}.uf2"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "${CYAN}Building: $OUTPUT_NAME (${CMAKE_VAL})${NC}"
echo ""
# Clean and create build directory
rm -rf build
mkdir build
cd build
# Configure with CMake
cmake .. -DFRANK_DISPLAY="$CMAKE_VAL" -DUSB_HID_ENABLED=1 > /dev/null 2>&1
# Build
if make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4) > /dev/null 2>&1; then
# Copy UF2 to release directory
if [[ -f "frankos.uf2" ]]; then
cp "frankos.uf2" "$RELEASE_DIR/$OUTPUT_NAME"
echo -e " ${GREEN}✓ Success${NC} → release/$OUTPUT_NAME"
else
echo -e " ${RED}✗ UF2 not found${NC}"
cd "$SCRIPT_DIR"
exit 1
fi
else
echo -e " ${RED}✗ Build failed${NC}"
cd "$SCRIPT_DIR"
exit 1
fi
cd "$SCRIPT_DIR"
done
# Clean up build directory
rm -rf build
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "${GREEN}Release build complete!${NC}"
echo ""
echo "Release files:"
for variant in "${VARIANTS[@]}"; do
SUFFIX="${variant##*:}"
OUTPUT_NAME="frankos_m2_${VERSION}_${SUFFIX}.uf2"
ls -la "$RELEASE_DIR/$OUTPUT_NAME" 2>/dev/null | awk '{print " " $9 " (" $5 " bytes)"}'
done
echo ""
echo -e "Version: ${CYAN}${VERSION_DOT}${NC}"