Repository navigation
Expand file tree
/
Copy pathBuild-Release.sh
More file actions
executable file
·79 lines (68 loc) · 3.39 KB
/
Copy pathBuild-Release.sh
File metadata and controls
executable file
·79 lines (68 loc) · 3.39 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
#!/usr/bin/env bash
# =============================================================================
# FolkPatch Release Build Script (Linux)
# Mirrors Build-Release.bat functionality for Linux / WSL environment
# =============================================================================
set -euo pipefail
# ── Colors ───────────────────────────────────────────────────────────────────
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$PROJECT_DIR"
# ── Load Environment ─────────────────────────────────────────────────────────
[[ -f "${HOME}/.cargo/env" ]] && source "${HOME}/.cargo/env"
export ANDROID_HOME="${ANDROID_HOME:-$HOME/Android/Sdk}"
export ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-$ANDROID_HOME}"
if [[ -z "${JAVA_HOME:-}" ]]; then
if [[ -d "${HOME}/.local/share/jvm/temurin-21" ]]; then
export JAVA_HOME="${HOME}/.local/share/jvm/temurin-21"
elif [[ -d "${HOME}/.jdks/temurin-21" ]]; then
export JAVA_HOME="${HOME}/.jdks/temurin-21"
fi
fi
if [[ -n "${JAVA_HOME:-}" && -d "${JAVA_HOME}/bin" ]]; then
export PATH="${JAVA_HOME}/bin:${PATH}"
fi
if [[ -d "${HOME}/.cargo/bin" ]]; then
export PATH="${HOME}/.cargo/bin:${PATH}"
fi
if [[ -d "${ANDROID_HOME}/cmdline-tools/latest/bin" ]]; then
export PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}"
fi
if [[ -d "${ANDROID_HOME}/platform-tools" ]]; then
export PATH="${ANDROID_HOME}/platform-tools:${PATH}"
fi
# ── Step 1: Enter apd directory ──────────────────────────────────────────────
echo -e "${BLUE}[1/4]${NC} Entering apd directory..."
if ! cd apd; then
echo -e "${RED}Error: Failed to enter apd directory, please check if the directory exists!${NC}" >&2
exit 1
fi
# ── Step 2: Clean apd (Rust) ─────────────────────────────────────────────────
echo -e "${BLUE}[2/4]${NC} Executing cargo clean..."
if ! cargo clean; then
echo -e "${RED}Error: cargo clean execution failed!${NC}" >&2
exit 1
fi
# ── Step 3: Return to parent directory ───────────────────────────────────────
echo -e "${BLUE}[3/4]${NC} Returning to parent directory..."
if ! cd ..; then
echo -e "${RED}Error: Failed to return to parent directory!${NC}" >&2
exit 1
fi
# ── Step 4: Build Release APK ────────────────────────────────────────────────
echo -e "${BLUE}[4/4]${NC} Executing ./gradlew assembleRelease..."
if ! ./gradlew assembleRelease; then
echo -e "${RED}Error: ./gradlew assembleRelease execution failed!${NC}" >&2
exit 1
fi
echo ""
echo -e "${GREEN}All commands executed successfully!${NC}"
echo -e "${GREEN}Release build complete!${NC}"
APK_PATH=$(find app/build/outputs/apk/release -name "*.apk" -type f 2>/dev/null | head -n 1)
if [[ -n "$APK_PATH" ]]; then
echo " Output: $APK_PATH"
fi