-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·303 lines (265 loc) · 9.61 KB
/
build.sh
File metadata and controls
executable file
·303 lines (265 loc) · 9.61 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/bin/bash
# Copyright (c) 2025 Nikolaos Protopapas
# Licensed under the MIT License
#
# Build script for Localization Resource Manager (LRM)
# Creates self-contained executables for Linux and Windows
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Script configuration
PROJECT_NAME="LocalizationManager"
OUTPUT_DIR="publish"
# Get version dynamically from .csproj (single source of truth)
if [ -x "./get-version.sh" ]; then
VERSION=$(./get-version.sh)
else
VERSION="unknown"
fi
# Parse command line arguments
BUILD_MODE="standard"
DEB_ARCH="amd64"
DEB_VARIANT="both"
while [[ $# -gt 0 ]]; do
case $1 in
--deb)
BUILD_MODE="deb"
shift
;;
--source)
BUILD_MODE="source"
shift
;;
--arch)
DEB_ARCH="$2"
shift 2
;;
--variant)
DEB_VARIANT="$2"
shift 2
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " (no options) Build standard Linux/Windows binaries (default)"
echo " --deb Build Debian .deb packages"
echo " --source Build Debian source package for PPA"
echo " --arch ARCH Architecture for --deb (amd64|arm64, default: amd64)"
echo " --variant VARIANT Variant for --deb (lrm|lrm-standalone|both, default: both)"
echo " --help Show this help message"
echo ""
echo "EXAMPLES:"
echo " $0 # Standard build (all platforms)"
echo " $0 --deb # Build .deb packages (amd64, both variants)"
echo " $0 --deb --arch arm64 # Build .deb packages for ARM64"
echo " $0 --deb --variant lrm # Build only framework-dependent .deb"
echo " $0 --source # Build source package for PPA"
exit 0
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
echo "Run '$0 --help' for usage information"
exit 1
;;
esac
done
# Handle build modes
if [ "$BUILD_MODE" = "deb" ]; then
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Building Debian Packages - v${VERSION} ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
exec ./build-deb.sh "$DEB_ARCH" "$DEB_VARIANT"
elif [ "$BUILD_MODE" = "source" ]; then
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Building Source Package - v${VERSION} ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
exec ./build-source-package.sh
fi
# Standard build mode continues below...
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Localization Resource Manager (LRM) - Build Script v${VERSION} ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
# Function to print step
print_step() {
echo -e "${YELLOW}►${NC} $1"
}
# Function to print success
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
# Function to print error
print_error() {
echo -e "${RED}✗${NC} $1"
}
# Function to get file size in human readable format
get_size() {
if [ -f "$1" ]; then
du -h "$1" | cut -f1
else
echo "N/A"
fi
}
# Clean previous builds
print_step "Cleaning previous builds..."
rm -rf "$OUTPUT_DIR"
rm -rf bin/Release
rm -rf obj/Release
print_success "Clean complete"
echo ""
# Run tests first
print_step "Running tests..."
dotnet test --configuration Release --verbosity quiet
if [ $? -eq 0 ]; then
print_success "All tests passed"
else
print_error "Tests failed! Aborting build."
exit 1
fi
echo ""
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Build configurations
declare -a platforms=(
"linux-x64"
"linux-arm64"
"win-x64"
"win-arm64"
"osx-x64"
"osx-arm64"
)
# Build for each platform
for platform in "${platforms[@]}"; do
print_step "Building for ${platform}..."
# Determine executable name
if [[ $platform == win-* ]]; then
exe_name="lrm.exe"
else
exe_name="lrm"
fi
# Publish (specify main project only, not test project)
dotnet publish "$PROJECT_NAME.csproj" \
--configuration Release \
--runtime "$platform" \
--self-contained true \
--output "$OUTPUT_DIR/$platform" \
/p:PublishSingleFile=true \
/p:PublishTrimmed=false \
/p:IncludeNativeLibrariesForSelfExtract=true \
--verbosity quiet
if [ $? -eq 0 ]; then
# Binary is already named 'lrm' or 'lrm.exe' due to AssemblyName in .csproj
# Get file size
size=$(get_size "$OUTPUT_DIR/$platform/$exe_name")
print_success "Built $platform ($size)"
else
print_error "Failed to build $platform"
exit 1
fi
done
echo ""
print_step "Creating distribution archives..."
# Create archives for distribution
for platform in "${platforms[@]}"; do
if [[ $platform == win-* ]]; then
exe_name="lrm.exe"
archive_name="lrm-${platform}.zip"
else
exe_name="lrm"
archive_name="lrm-${platform}.tar.gz"
fi
# Create README for distribution
cat > "$OUTPUT_DIR/$platform/README.txt" << EOF
Localization Resource Manager (LRM) v${VERSION}
================================================
Copyright (c) 2025 Nikolaos Protopapas
Licensed under the MIT License
Platform: ${platform}
Quick Start
-----------
1. Extract this archive to a directory in your PATH
2. Run: lrm --help
3. Navigate to a folder with .resx files
4. Try: lrm validate
Commands
--------
- validate Check for missing/extra/duplicate keys
- stats Show translation statistics
- view Display specific key details
- add Add new localization key
- update Update existing key values
- delete Remove localization key
- export Export to CSV format
- import Import from CSV format
- edit Interactive TUI editor
Examples
--------
lrm validate --path ./Resources
lrm stats
lrm add NewKey --lang en:"English" --lang el:"Ελληνικά"
lrm edit
Documentation
-------------
For full documentation, visit:
https://github.com/nickprotop/LocalizationManager
EOF
# Create archive
cd "$OUTPUT_DIR/$platform"
if [[ $platform == win-* ]]; then
# For Windows, create a zip (if zip is available)
if command -v zip &> /dev/null; then
zip -q "../$archive_name" "$exe_name" README.txt
print_success "Created $archive_name"
else
print_error "zip command not found, skipping archive for $platform"
fi
else
# For Linux, create tar.gz
tar -czf "../$archive_name" "$exe_name" README.txt
print_success "Created $archive_name"
fi
cd ../..
done
echo ""
print_step "Build Summary"
echo "─────────────────────────────────────────────────────────────"
# Print summary table
printf "${GREEN}%-20s${NC} %-15s %s\n" "Platform" "Executable" "Size"
echo "─────────────────────────────────────────────────────────────"
for platform in "${platforms[@]}"; do
if [[ $platform == win-* ]]; then
exe_name="lrm.exe"
else
exe_name="lrm"
fi
size=$(get_size "$OUTPUT_DIR/$platform/$exe_name")
printf "%-20s %-15s %s\n" "$platform" "$exe_name" "$size"
done
echo "─────────────────────────────────────────────────────────────"
echo ""
print_success "Build complete! Outputs in: $OUTPUT_DIR/"
echo ""
# List archives
print_step "Distribution Archives"
ls -lh "$OUTPUT_DIR"/*.tar.gz "$OUTPUT_DIR"/*.zip 2>/dev/null | awk '{printf " %s %s\n", $5, $9}' || true
echo ""
# Installation hint
echo -e "${BLUE}Installation Hint:${NC}"
echo " For system-wide installation on Linux:"
echo " sudo cp $OUTPUT_DIR/linux-x64/lrm /usr/local/bin/"
echo " sudo chmod +x /usr/local/bin/lrm"
echo ""
echo " For user installation:"
echo " mkdir -p ~/.local/bin"
echo " cp $OUTPUT_DIR/linux-x64/lrm ~/.local/bin/"
echo " chmod +x ~/.local/bin/lrm"
echo " # Add ~/.local/bin to PATH in ~/.bashrc or ~/.zshrc"
echo ""
print_success "All done! 🎉"