build_release.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/usr/bin/env bash
  2. set -e
  3. set -x
  4. # git diff --name-status origin/release3-staging | grep "^A" | less
  5. DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
  6. cd $DIR
  7. BUILD_DIR=/data/openpilot
  8. SOURCE_DIR="$(git rev-parse --show-toplevel)"
  9. if [ -z "$RELEASE_BRANCH" ]; then
  10. echo "RELEASE_BRANCH is not set"
  11. exit 1
  12. fi
  13. # set git identity
  14. source $DIR/identity.sh
  15. echo "[-] Setting up repo T=$SECONDS"
  16. rm -rf $BUILD_DIR
  17. mkdir -p $BUILD_DIR
  18. cd $BUILD_DIR
  19. git init
  20. git remote add origin git@github.com:commaai/openpilot.git
  21. git checkout --orphan $RELEASE_BRANCH
  22. # do the files copy
  23. echo "[-] copying files T=$SECONDS"
  24. cd $SOURCE_DIR
  25. cp -pR --parents $(./release/release_files.py) $BUILD_DIR/
  26. # in the directory
  27. cd $BUILD_DIR
  28. rm -f panda/board/obj/panda.bin.signed
  29. rm -f panda/board/obj/panda_h7.bin.signed
  30. VERSION=$(cat common/version.h | awk -F[\"-] '{print $2}')
  31. echo "#define COMMA_VERSION \"$VERSION-release\"" > common/version.h
  32. echo "[-] committing version $VERSION T=$SECONDS"
  33. git add -f .
  34. git commit -a -m "openpilot v$VERSION release"
  35. # Build
  36. export PYTHONPATH="$BUILD_DIR"
  37. scons -j$(nproc) --minimal
  38. # release panda fw
  39. CERT=/data/pandaextra/certs/release RELEASE=1 scons -j$(nproc) panda/
  40. # Ensure no submodules in release
  41. if test "$(git submodule--helper list | wc -l)" -gt "0"; then
  42. echo "submodules found:"
  43. git submodule--helper list
  44. exit 1
  45. fi
  46. git submodule status
  47. # Cleanup
  48. find . -name '*.a' -delete
  49. find . -name '*.o' -delete
  50. find . -name '*.os' -delete
  51. find . -name '*.pyc' -delete
  52. find . -name 'moc_*' -delete
  53. find . -name '__pycache__' -delete
  54. rm -rf .sconsign.dblite Jenkinsfile release/
  55. rm selfdrive/modeld/models/supercombo.onnx
  56. find third_party/ -name '*x86*' -exec rm -r {} +
  57. find third_party/ -name '*Darwin*' -exec rm -r {} +
  58. # Restore third_party
  59. git checkout third_party/
  60. # Mark as prebuilt release
  61. touch prebuilt
  62. # Add built files to git
  63. git add -f .
  64. git commit --amend -m "openpilot v$VERSION"
  65. # Run tests
  66. TEST_FILES="tools/"
  67. cd $SOURCE_DIR
  68. cp -pR -n --parents $TEST_FILES $BUILD_DIR/
  69. cd $BUILD_DIR
  70. RELEASE=1 pytest -n0 -s selfdrive/test/test_onroad.py
  71. #system/manager/test/test_manager.py
  72. pytest selfdrive/car/tests/test_car_interfaces.py
  73. rm -rf $TEST_FILES
  74. if [ ! -z "$RELEASE_BRANCH" ]; then
  75. echo "[-] pushing release T=$SECONDS"
  76. git push -f origin $RELEASE_BRANCH:$RELEASE_BRANCH
  77. fi
  78. echo "[-] done T=$SECONDS"