Files
sunnypilot/tools/release/build_release.sh
T
Jason Wen 2149006ec7 Merge commit '35e78a9d9518855ec0dacec919e719624a28131f' into sync-20261016
# Conflicts:
#	.gitattributes
#	.gitignore
#	.gitmodules
#	opendbc_repo
#	openpilot/common/params_keys.h
#	openpilot/common/version.py
#	openpilot/selfdrive/car/card.py
#	openpilot/selfdrive/controls/lib/longitudinal_planner.py
#	openpilot/selfdrive/controls/plannerd.py
#	openpilot/selfdrive/controls/tests/test_latcontrol.py
#	openpilot/selfdrive/modeld/modeld.py
#	openpilot/selfdrive/pandad/pandad.py
#	openpilot/selfdrive/selfdrived/alerts_offroad.json
#	openpilot/selfdrive/selfdrived/selfdrived.py
#	openpilot/selfdrive/test/longitudinal_maneuvers/plant.py
#	openpilot/selfdrive/ui/layouts/settings/developer.py
#	openpilot/selfdrive/ui/layouts/settings/toggles.py
#	openpilot/selfdrive/ui/mici/layouts/home.py
#	openpilot/selfdrive/ui/mici/layouts/onboarding.py
#	openpilot/selfdrive/ui/mici/onroad/model_renderer.py
#	openpilot/selfdrive/ui/onroad/model_renderer.py
#	openpilot/selfdrive/ui/soundd.py
#	openpilot/selfdrive/ui/translations/app.pot
#	openpilot/selfdrive/ui/translations/app_de.po
#	openpilot/selfdrive/ui/translations/app_en.po
#	openpilot/selfdrive/ui/translations/app_es.po
#	openpilot/selfdrive/ui/translations/app_fr.po
#	openpilot/selfdrive/ui/translations/app_ja.po
#	openpilot/selfdrive/ui/translations/app_ko.po
#	openpilot/selfdrive/ui/translations/app_pt-BR.po
#	openpilot/selfdrive/ui/translations/app_th.po
#	openpilot/selfdrive/ui/translations/app_tr.po
#	openpilot/selfdrive/ui/translations/app_uk.po
#	openpilot/selfdrive/ui/translations/app_zh-CHS.po
#	openpilot/selfdrive/ui/translations/app_zh-CHT.po
#	openpilot/selfdrive/ui/ui_state.py
#	openpilot/system/hardware/chestnut/status.py
#	openpilot/system/manager/process_config.py
#	openpilot/system/ui/README.md
#	panda
#	tinygrad_repo
2026-10-18 15:25:44 -04:00

118 lines
3.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
set -x
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$DIR"
BUILD_DIR=/data/openpilot
SOURCE_DIR="$(git rev-parse --show-toplevel)"
export PYTHONPATH="$BUILD_DIR:$BUILD_DIR/msgq_repo:$BUILD_DIR/opendbc_repo:$BUILD_DIR/rednose_repo:$BUILD_DIR/teleoprtc_repo:$BUILD_DIR/tinygrad_repo"
if [ -z "$RELEASE_BRANCH" ]; then
echo "RELEASE_BRANCH is not set"
exit 1
fi
BUILD_BRANCH=release-mici-staging
# set git identity
source "$DIR/identity.sh"
echo "[-] Setting up repo T=$SECONDS"
if ! git -C "$SOURCE_DIR" worktree remove --force "$BUILD_DIR" 2>/dev/null; then
rm -rf "$BUILD_DIR"
fi
git -C "$SOURCE_DIR" worktree prune
git -C "$SOURCE_DIR" worktree add --detach --no-checkout "$BUILD_DIR"
cd "$BUILD_DIR"
git update-ref -d "refs/heads/$BUILD_BRANCH"
git symbolic-ref HEAD "refs/heads/$BUILD_BRANCH"
git read-tree --empty
# do the files copy
echo "[-] copying files T=$SECONDS"
cd "$SOURCE_DIR"
./tools/release/release_files.py | xargs -0 cp -pR --parents -t "$BUILD_DIR" --
# in the directory
cd "$BUILD_DIR"
source "$SOURCE_DIR/tools/release/setup_lfs.sh"
# use the full CPU available for speeding up the build.
# openpilot resets the CPU frequencies when test_onroad.py runs below.
for policy in /sys/devices/system/cpu/cpufreq/policy*; do
[ -d "$policy" ] || continue
hardware_max="$(cat "$policy/cpuinfo_max_freq")"
echo "$hardware_max" | sudo tee "$policy/scaling_max_freq" >/dev/null
done
scons
if [ -z "$PANDA_DEBUG_BUILD" ]; then
# release panda fw
CERT=/data/pandaextra/certs/release RELEASE=1 scons panda/
else
# build with ALLOW_DEBUG=1 to enable features like experimental longitudinal
scons panda/
fi
if [ -n "$INCLUDE_BIG_MODEL" ]; then
test -f openpilot/selfdrive/modeld/models/big_driving_tinygrad.pkl
test -f openpilot/selfdrive/modeld/models/big_driving_warp_1344x760_tinygrad.pkl
test -f openpilot/selfdrive/modeld/models/big_driving_warp_1928x1208_tinygrad.pkl
fi
# Ensure no submodules in release
if test "$(git submodule--helper list | wc -l)" -gt "0"; then
echo "submodules found:"
git submodule--helper list
exit 1
fi
git submodule status
# Cleanup
find . -name '*.a' -delete
find . -name '*.o' -delete
find . -name '*.os' -delete
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
rm -rf .sconsign.dblite Jenkinsfile tools/release/
rm -f openpilot/selfdrive/modeld/models/*.onnx*
rm -f openpilot/sunnypilot/modeld*/models/*.onnx*
find openpilot/third_party/ -name '*x86*' -exec rm -r {} +
find openpilot/third_party/ -name '*Darwin*' -exec rm -r {} +
# Restore third_party
git checkout openpilot/third_party/
# Mark as prebuilt release
touch prebuilt
VERSION=$(cat openpilot/sunnypilot/common/version.h | awk -F[\"-] '{print $2}')
# Add built files to git
# writing larger objects is faster than compressing them on-device
git -c core.compression=0 add -f .
git -c core.compression=0 -c gc.auto=0 commit -m "openpilot v$VERSION"
source "$SOURCE_DIR/tools/release/check_file_sizes.sh"
# Run tests
cd "$BUILD_DIR"
RELEASE=1 ./openpilot/selfdrive/test/test_onroad.py "$@"
#tools/test_runner.py openpilot/selfdrive/car/tests/test_car_interfaces.py
echo "[-] pushing release T=$SECONDS"
REFS=()
for branch in ${RELEASE_BRANCH//,/ }; do
REFS+=("$BUILD_BRANCH:$branch")
done
# uploading the larger pack is faster than spending CPU to optimize it
# The big model is already published to LFS by the source branch.
GIT_LFS_SKIP_PUSH=1 git -c pack.window=0 -c pack.depth=0 -c pack.compression=0 push -f origin "${REFS[@]}"
echo "[-] done T=$SECONDS"