-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
59 lines (49 loc) · 2.48 KB
/
Copy pathbuild.sh
File metadata and controls
59 lines (49 loc) · 2.48 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
#!/usr/bin/env bash
set -euo pipefail
# Ensure script is run from repository root
cd "$(dirname "$0")"
# Define directories
BUILD_DIR="build"
PACKAGE_SRC="Packages/com.pereviader.unityclirunner"
echo "=== Starting UnityCliRunner build ==="
# 1. Clean and recreate the build directory
if [ -d "$BUILD_DIR" ]; then
echo "Cleaning existing build directory: $BUILD_DIR..."
rm -rf "$BUILD_DIR"
fi
mkdir -p "$BUILD_DIR"
# 2. Copy the contents of the package source into the build folder
echo "Copying package contents..."
# cp -R with trailing '/.' copies all contents of source, including hidden files/directories
cp -R "$PACKAGE_SRC/." "$BUILD_DIR/"
# 2.5. Update version in package.json from .env.shared
if [ -f ".env.shared" ]; then
VERSION_VAL=$(source .env.shared && echo "$VERSION")
echo "Updating version in build/package.json to $VERSION_VAL..."
if jq --version &> /dev/null; then
jq --arg ver "$VERSION_VAL" '.version = $ver' "$BUILD_DIR/package.json" > "$BUILD_DIR/package.json.tmp" && mv "$BUILD_DIR/package.json.tmp" "$BUILD_DIR/package.json"
elif node --version &> /dev/null; then
node -e "const fs = require('fs'); const p = '$BUILD_DIR/package.json'; const d = JSON.parse(fs.readFileSync(p, 'utf8')); d.version = '$VERSION_VAL'; fs.writeFileSync(p, JSON.stringify(d, null, 2) + '\n', 'utf8');"
elif python3 --version &> /dev/null; then
python3 -c "import json; p='$BUILD_DIR/package.json'; d=json.load(open(p)); d['version']='$VERSION_VAL'; json.dump(d, open(p, 'w'), indent=2)"
elif python --version &> /dev/null; then
python -c "import json; p='$BUILD_DIR/package.json'; d=json.load(open(p)); d['version']='$VERSION_VAL'; json.dump(d, open(p, 'w'), indent=2)"
else
echo "Error: No jq, node, python3, or python found to update package.json version"
exit 1
fi
else
echo "Error: .env.shared not found!"
exit 1
fi
# 3. Copy unitycli.sh into the Templates~ folder, overwriting the dummy placeholder
echo "Copying actual unitycli.sh to build templates..."
cp "unitycli.sh" "$BUILD_DIR/Templates~/unitycli.sh"
chmod +x "$BUILD_DIR/Templates~/unitycli.sh"
# 4. Copy unity-cli agent skill into the Templates~ folder, replacing the dummy placeholder
echo "Copying actual unity-cli agent skill to build templates..."
# Remove the dummy placeholder directory
rm -rf "$BUILD_DIR/Templates~/.agents/skills/unity-cli"
# Copy the actual skill directory recursively
cp -R ".agents/skills/unity-cli" "$BUILD_DIR/Templates~/.agents/skills/"
echo "=== Build completed successfully! ==="