-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
74 lines (60 loc) · 1.84 KB
/
build.sh
File metadata and controls
74 lines (60 loc) · 1.84 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
#!/bin/bash
# SPDX-FileCopyrightText: 2025 Ethersecurity Inc.
#
# SPDX-License-Identifier: MPL-2.0
# Author: Shohei KAMON <cameong@stir.network>
# Build script for fireblocks-cli using PyInstaller + bump-my-version + upx
# Usage: ./build.sh [major|minor|patch]
set -e
APP_NAME="fireblocks-cli"
ENTRYPOINT="fireblocks_cli/main.py"
DIST_DIR="dist"
BUILD_DIR="build"
# Handle version bump
BUMP_PART="$1"
if [[ "$BUMP_PART" =~ ^(major|minor|patch)$ ]]; then
echo "🔧 Bumping version: $BUMP_PART"
case "$BUMP_PART" in
major)
if [[ -n "$(git status --porcelain)" ]]; then
echo "🚫 Cannot bump major version in a dirty working directory."
echo "💡 Please commit or stash your changes first."
exit 1
fi
;;
minor|patch)
echo "⚠️ Allowing dirty working tree for $BUMP_PART bump"
;;
esac
bump-my-version bump $BUMP_PART --allow-dirty
else
echo "⚠️ No valid bump type provided. Skipping version bump."
fi
# Read version from fireblocks_cli/__init__.py
VERSION=$(grep -oE '__version__ = "[^"]+"' fireblocks_cli/__init__.py | cut -d '"' -f2)
echo "🔖 Using version: $VERSION"
# Cleanup old builds
echo "🔄 Cleaning previous builds..."
rm -rf $DIST_DIR $BUILD_DIR __pycache__
# Build with PyInstaller
echo "🔧 Building $APP_NAME for $(uname)..."
pyinstaller \
--onefile \
--name $APP_NAME \
--hidden-import=fireblocks_cli.commands.configure \
--clean \
$ENTRYPOINT
# Rename output binary
PLATFORM=$(uname | tr '[:upper:]' '[:lower:]')
OUTPUT="$DIST_DIR/${APP_NAME}-${PLATFORM}-v${VERSION}"
mv $DIST_DIR/$APP_NAME $OUTPUT
# Optional UPX compression
if command -v upx &> /dev/null; then
echo "📦 Compressing binary with UPX..."
upx --best --lzma $OUTPUT
else
echo "⚠️ UPX not found. Skipping compression."
fi
# Show result
echo "✅ Built binary: $OUTPUT"
ls -lh $OUTPUT