-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·196 lines (157 loc) · 4.84 KB
/
dev.sh
File metadata and controls
executable file
·196 lines (157 loc) · 4.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
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
#!/bin/bash
# A6Cutter Development Helper Script
# This script helps with local development and testing
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}ℹ️ $1${NC}"
}
print_success() {
echo -e "${GREEN}✅ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}❌ $1${NC}"
}
# Function to show help
show_help() {
echo "A6Cutter Development Helper"
echo ""
echo "Usage: ./dev.sh [command]"
echo ""
echo "Commands:"
echo " build - Build the app with proper version info"
echo " run - Build and run the app"
echo " clean - Clean build artifacts"
echo " version - Show current version info"
echo " dmg - Create DMG for distribution"
echo " release - Create full release build"
echo " help - Show this help"
echo ""
echo "Examples:"
echo " ./dev.sh run"
echo " ./dev.sh build"
echo " ./dev.sh dmg"
}
# Function to check if we're in the right directory
check_directory() {
if [ ! -f "A6Cutter.xcodeproj/project.pbxproj" ]; then
print_error "Not in A6Cutter project directory!"
print_status "Please run this script from the A6Cutter project root."
exit 1
fi
}
# Function to get version info
get_version_info() {
print_status "Getting version information..."
# Try to get version from git tag
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
BUILD_NUMBER=$(git rev-parse --short HEAD 2>/dev/null || echo "dev")
GIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "dev")
print_success "Version: $VERSION"
print_success "Build: $BUILD_NUMBER"
print_success "Git Hash: $GIT_HASH"
}
# Function to update Info.plist
update_info_plist() {
print_status "Updating Info.plist with version information..."
# Update version and build number
plutil -replace CFBundleShortVersionString -string "$VERSION" A6Cutter/Info.plist
plutil -replace CFBundleVersion -string "$BUILD_NUMBER" A6Cutter/Info.plist
# Add git hash to Info.plist
plutil -replace GitHash -string "$GIT_HASH" A6Cutter/Info.plist
print_success "Info.plist updated successfully"
}
# Function to build the app
build_app() {
print_status "Building A6Cutter..."
# Update version info first
update_info_plist
# Build the app
xcodebuild -scheme A6Cutter -configuration Release -destination "platform=macOS" build
print_success "Build completed successfully!"
}
# Function to run the app
run_app() {
print_status "Running A6Cutter..."
# Find the built app
APP_PATH=$(find /Users/$(whoami)/Library/Developer/Xcode/DerivedData -name "A6Cutter.app" -path "*/Build/Products/Release/*" 2>/dev/null | head -1)
if [ -z "$APP_PATH" ]; then
print_error "Could not find built app. Please run './dev.sh build' first."
exit 1
fi
if [ ! -d "$APP_PATH" ]; then
print_error "App found but is not a valid directory: $APP_PATH"
exit 1
fi
print_success "Opening app: $APP_PATH"
open "$APP_PATH"
}
# Function to create DMG
create_dmg() {
print_status "Creating DMG..."
# Find the built app
APP_PATH=$(find /Users/$(whoami)/Library/Developer/Xcode/DerivedData -name "A6Cutter.app" -path "*/Build/Products/Release/*" 2>/dev/null | head -1)
if [ -z "$APP_PATH" ]; then
print_error "Could not find built app. Please run 'make build' first."
exit 1
fi
# Create DMG directory
mkdir -p build/dmg
# Copy app
cp -R "$APP_PATH" build/dmg/
# Create Applications shortcut
ln -s /Applications build/dmg/
# Create README
echo "Drag A6Cutter.app to Applications folder" > build/dmg/README.txt
# Create DMG
hdiutil create -volname "A6Cutter" -srcfolder build/dmg -ov -format UDZO build/A6Cutter.dmg
print_success "DMG created: build/A6Cutter.dmg"
}
# Function to clean build artifacts
clean_build() {
print_status "Cleaning build artifacts..."
rm -rf build/
xcodebuild clean -scheme A6Cutter -configuration Release
print_success "Build artifacts cleaned"
}
# Main script logic
check_directory
case "${1:-help}" in
"build")
get_version_info
build_app
;;
"run")
get_version_info
build_app
run_app
;;
"clean")
clean_build
;;
"version")
get_version_info
;;
"dmg")
create_dmg
;;
"release")
get_version_info
clean_build
build_app
create_dmg
print_success "Release build completed!"
;;
"help"|*)
show_help
;;
esac