build-container.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # This automation builds a aarch64 Ubuntu container
  2. name: Build Container
  3. on:
  4. # Allows you to run this workflow manually from the Actions tag
  5. workflow_dispatch:
  6. push:
  7. branches:
  8. - main
  9. - development
  10. paths:
  11. - .github/workflows/build-container.yaml
  12. jobs:
  13. build-container:
  14. name: Build Ubuntu container for aarch64
  15. runs-on: ubuntu-latest
  16. permissions:
  17. contents: read
  18. # We use ghcr.io to store the docker image cache for ARM builds
  19. packages: write
  20. steps:
  21. - name: Run build command (aarch64)
  22. uses: uraimo/[email protected]
  23. with:
  24. env: |
  25. GITHUB_WORKFLOW: ${{ github.workflow }} # Sets the docker image to the name of the workflow
  26. arch: aarch64
  27. distro: ubuntu22.04
  28. githubToken: ${{ github.token }}
  29. shell: /bin/bash
  30. install: |
  31. ## Set variables. "env" not supported in install phase
  32. export CLANG_VER=12
  33. export GCC_VER=9
  34. export SCCACHE_VER=0.5.4
  35. export CMAKE_VER=3.27.6
  36. ## Install build dependancies from apt
  37. apt-get update
  38. apt-get install -y build-essential curl git libssl-dev libffi-dev libbz2-dev libgdbm-compat-dev libgdbm-dev liblzma-dev libreadline-dev libtool \
  39. ninja-build python3 python3-pip tcl8.6-dev tk8.6-dev texinfo software-properties-common wget libc6
  40. python3 -m pip install boto3 certifi
  41. # Install Clang/GCC at specific version
  42. apt-get install -y clang-${CLANG_VER} gcc-${GCC_VER} g++-${GCC_VER}
  43. update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_VER} 10
  44. update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VER} 10
  45. update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VER} 10
  46. update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_VER} 10
  47. ## Install sccache
  48. wget -qO- "https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VER}/sccache-v${SCCACHE_VER}-aarch64-unknown-linux-musl.tar.gz" \
  49. | tar xzf - -O --wildcards '*/sccache' > '/usr/local/bin/sccache' \
  50. && chmod +x '/usr/local/bin/sccache'
  51. ## Install cmake
  52. wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-linux-aarch64.sh" \
  53. -O /tmp/cmake-install.sh \
  54. && chmod u+x /tmp/cmake-install.sh \
  55. && mkdir /opt/cmake-${CMAKE_VER} \
  56. && /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VER} \
  57. && rm /tmp/cmake-install.sh \
  58. && ln -s /opt/cmake-${CMAKE_VER}/bin/* /usr/local/bin
  59. rm -rf /var/lib/apt/lists/*
  60. # Add Docker's official GPG key:
  61. apt-get update
  62. sudo apt-get install ca-certificates curl
  63. sudo install -m 0755 -d /etc/apt/keyrings
  64. sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
  65. sudo chmod a+r /etc/apt/keyrings/docker.asc
  66. # Add the repository to Apt sources:
  67. echo \
  68. "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  69. $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  70. tee /etc/apt/sources.list.d/docker.list > /dev/null
  71. apt-get update
  72. apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  73. apt-get install -y qemu-user-static binfmt-support
  74. update-binfmts --install qemu-aarch64 /usr/bin/qemu-aarch64-static --magic '\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
  75. run: |
  76. lsb_release -a
  77. uname -a
  78. gcc --version
  79. g++ --version
  80. clang --version
  81. sccache --version
  82. cmake --version
  83. git --version
  84. python3 --version
  85. docker --version