-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-release.sh
More file actions
executable file
·108 lines (90 loc) · 3.57 KB
/
build-release.sh
File metadata and controls
executable file
·108 lines (90 loc) · 3.57 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
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PASSWORD="featherpanel_development_kit_2025_addon_password"
TEMP_DIR=$(mktemp -d)
EXPORT_FILE="${TEMP_DIR}/plugin.fpa"
echo -e "${GREEN}Starting plugin build process...${NC}"
# Step 1: Build frontend
if [ -d "${PLUGIN_DIR}/Frontend/App" ]; then
echo -e "${YELLOW}Building frontend...${NC}"
cd "${PLUGIN_DIR}/Frontend/App"
if [ -f "pnpm-lock.yaml" ]; then
echo -e "${YELLOW}Installing with pnpm...${NC}"
if ! pnpm install --frozen-lockfile 2>&1; then
echo -e "${YELLOW}Lockfile config mismatch detected, updating lockfile...${NC}"
pnpm install --no-frozen-lockfile
fi
BUILD_CMD="pnpm build"
elif [ -f "package-lock.json" ]; then
echo -e "${YELLOW}Installing with npm...${NC}"
npm ci || npm install
BUILD_CMD="npm run build"
else
echo -e "${YELLOW}No lockfile found, using pnpm...${NC}"
pnpm install || npm install
BUILD_CMD="pnpm build || npm run build"
fi
echo -e "${YELLOW}Building frontend...${NC}"
eval "${BUILD_CMD}"
echo -e "${GREEN}Frontend build completed${NC}"
cd "${PLUGIN_DIR}"
else
echo -e "${YELLOW}No Frontend/App directory found, skipping frontend build${NC}"
fi
# Step 2: Parse conf.yml
echo -e "${YELLOW}Reading plugin configuration...${NC}"
CONF_FILE="${PLUGIN_DIR}/conf.yml"
if [ ! -f "${CONF_FILE}" ]; then
echo -e "${RED}Error: conf.yml not found${NC}"
exit 1
fi
PLUGIN_VERSION=$(grep -E "^\s*version:" "${CONF_FILE}" | sed -E 's/.*version:\s*["'"'"']?([^"'"'"']+)["'"'"']?/\1/' | tr -d ' ')
PLUGIN_IDENTIFIER=$(grep -E "^\s*identifier:" "${CONF_FILE}" | sed -E 's/.*identifier:\s*["'"'"']?([^"'"'"']+)["'"'"']?/\1/' | tr -d ' ')
if [ -z "${PLUGIN_VERSION}" ] || [ -z "${PLUGIN_IDENTIFIER}" ]; then
echo -e "${RED}Error: Could not extract version/identifier from conf.yml${NC}"
exit 1
fi
echo -e "${GREEN}Plugin: ${PLUGIN_IDENTIFIER} v${PLUGIN_VERSION}${NC}"
# Step 3: Parse .featherexport exclusions
EXCLUSIONS=()
EXPORT_IGNORE="${PLUGIN_DIR}/.featherexport"
if [ -f "${EXPORT_IGNORE}" ]; then
echo -e "${YELLOW}Reading .featherexport exclusions...${NC}"
while IFS= read -r line || [ -n "$line" ]; do
line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [ -z "$line" ] || [[ "$line" =~ ^# ]]; then continue; fi
line=$(echo "$line" | sed 's/#.*$//' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [ -n "$line" ]; then EXCLUSIONS+=("$line"); fi
done < "${EXPORT_IGNORE}"
fi
EXCLUSIONS+=(".featherexport")
# Step 4: Create .fpa
echo -e "${YELLOW}Creating .fpa archive...${NC}"
cd "${PLUGIN_DIR}"
if [ ${#EXCLUSIONS[@]} -gt 0 ]; then
EXCLUSION_ARGS=()
for pattern in "${EXCLUSIONS[@]}"; do
PATTERN=$(echo "$pattern" | sed 's|^/||')
EXCLUSION_ARGS+=("-x" "$PATTERN")
done
zip -r -P "${PASSWORD}" "${EXPORT_FILE}" * "${EXCLUSION_ARGS[@]}"
else
zip -r -P "${PASSWORD}" "${EXPORT_FILE}" *
fi
FINAL_EXPORT="${PLUGIN_DIR}/${PLUGIN_IDENTIFIER}-${PLUGIN_VERSION}.fpa"
mv "${EXPORT_FILE}" "${FINAL_EXPORT}"
echo -e "${GREEN}Created: ${FINAL_EXPORT}${NC}"
if [ -n "${GITHUB_OUTPUT}" ]; then
echo "export_file=${FINAL_EXPORT}" >> "${GITHUB_OUTPUT}"
echo "plugin_version=${PLUGIN_VERSION}" >> "${GITHUB_OUTPUT}"
echo "plugin_identifier=${PLUGIN_IDENTIFIER}" >> "${GITHUB_OUTPUT}"
fi
rm -rf "${TEMP_DIR}"
echo -e "${GREEN}Build completed successfully!${NC}"