buildall.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/bash
  2. ##############################################################################
  3. #
  4. # HPCC SYSTEMS software Copyright (C) 2020 HPCC Systems®.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ##############################################################################
  18. # Build script to create and publish Docker containers corresponding to a GitHub tag
  19. # This script is normally invoked via GitHub actions, whenever a new tag is pushed
  20. BASE_VER=7.12 # The docker hub label for the platform-build-base image. Changes rarely.
  21. BUILD_TAG=$(git describe --exact-match --tags) # The git tag for the images we are building
  22. BUILD_LABEL=${BUILD_TAG} # The docker hub label for all other components
  23. BUILD_USER=hpcc-systems # The github repo owner
  24. BUILD_TYPE= # Set to Debug for a debug build, leave blank for default (RelWithDebInfo)
  25. USE_CPPUNIT=1
  26. # These values are set in a GitHub workflow build
  27. [[ -n ${INPUT_BUILD_USER} ]] && BUILD_USER=${INPUT_BUILD_USER}
  28. [[ -n ${INPUT_BUILD_VER} ]] && BUILD_TAG=${INPUT_BUILD_VER}
  29. [[ -n ${GITHUB_REPOSITORY} ]] && BUILD_USER=${GITHUB_REPOSITORY%/*}
  30. if [[ -n ${INPUT_USERNAME} ]] ; then
  31. echo ${INPUT_PASSWORD} | docker login -u ${INPUT_USERNAME} --password-stdin ${INPUT_REGISTRY}
  32. PUSH=1
  33. fi
  34. if [[ -n ${INPUT_BUILD_THREADS} ]] ; then
  35. BUILD_THREADS=$INPUT_BUILD_THREADS
  36. fi
  37. if [[ -z ${BUILD_TAG} ]] ; then
  38. echo Current tag could not be located
  39. echo Perhaps you meant to run incr.sh ?
  40. exit 2
  41. fi
  42. set -e
  43. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  44. pushd $DIR 2>&1 > /dev/null
  45. . ../cmake_modules/parse_cmake.sh
  46. parse_cmake
  47. set_tag
  48. if [[ -n ${INPUT_BUILDTYPE} ]] ; then
  49. BUILD_TYPE=$INPUT_BUILDTYPE
  50. BUILD_LABEL=${HPCC_SHORT_TAG}-$INPUT_BUILDTYPE
  51. else
  52. BUILD_LABEL=${HPCC_SHORT_TAG}
  53. BUILD_TYPE=RelWithDebInfo
  54. USE_CPPUNIT=0
  55. fi
  56. if [[ "$HPCC_MATURITY" = "release" ]] && [[ "$INPUT_LATEST" = "1" ]] ; then
  57. LATEST=1
  58. fi
  59. build_image() {
  60. local name=$1
  61. local label=$2
  62. [[ -z ${label} ]] && label=$BUILD_LABEL
  63. if ! docker pull hpccsystems/${name}:${label} ; then
  64. docker image build -t hpccsystems/${name}:${label} \
  65. --build-arg BASE_VER=${BASE_VER} \
  66. --build-arg DOCKER_REPO=hpccsystems \
  67. --build-arg BUILD_TAG=${BUILD_TAG} \
  68. --build-arg BUILD_LABEL=${BUILD_LABEL} \
  69. --build-arg BUILD_USER=${BUILD_USER} \
  70. --build-arg BUILD_TYPE=${BUILD_TYPE} \
  71. --build-arg USE_CPPUNIT=${USE_CPPUNIT} \
  72. --build-arg BUILD_THREADS=${BUILD_THREADS} \
  73. ${name}/
  74. if [ "$LATEST" = "1" ] ; then
  75. docker tag hpccsystems/${name}:${label} hpccsystems/${name}:latest
  76. if [ "$PUSH" = "1" ] ; then
  77. docker push hpccsystems/${name}:${label}
  78. docker push hpccsystems/${name}:latest
  79. fi
  80. else
  81. if [ "$PUSH" = "1" ] ; then
  82. docker push hpccsystems/${name}:${label}
  83. fi
  84. fi
  85. fi
  86. }
  87. build_image platform-build-base ${BASE_VER}
  88. build_image platform-build
  89. build_image platform-core
  90. if [[ -n ${INPUT_PASSWORD} ]] ; then
  91. echo "::set-output name=${BUILD_LABEL}"
  92. docker logout
  93. fi