diff --git a/.github/workflows/amd64-image-build.yml b/.github/workflows/amd64-image-build.yml index f0524bc..932e67c 100644 --- a/.github/workflows/amd64-image-build.yml +++ b/.github/workflows/amd64-image-build.yml @@ -1,5 +1,9 @@ name: amd64-image-build +concurrency: + group: amd64-image-build-${{ github.head_ref }} + cancel-in-progress: true + on: push: branches: [ "master" ] diff --git a/.github/workflows/arm64-rpi-image-build.yml b/.github/workflows/arm64-rpi-image-build.yml index 66640fb..6f05d40 100644 --- a/.github/workflows/arm64-rpi-image-build.yml +++ b/.github/workflows/arm64-rpi-image-build.yml @@ -1,5 +1,9 @@ name: arm64-rpi-image-build +concurrency: + group: arm64-rpi-image-build-${{ github.head_ref }} + cancel-in-progress: true + on: push: branches: [ "master" ] diff --git a/.github/workflows/arm64-rpi5-image-build.yml b/.github/workflows/arm64-rpi5-image-build.yml new file mode 100644 index 0000000..dba0e8e --- /dev/null +++ b/.github/workflows/arm64-rpi5-image-build.yml @@ -0,0 +1,81 @@ +name: arm64-rpi5-image-build + +concurrency: + group: arm64-rpi5-image-build-${{ github.head_ref }} + cancel-in-progress: true + +on: + push: + branches: [ "master" ] + paths-ignore: + - '*.md' + - '.gitignore' + - 'images' + - 'ci/amd64/**' + - 'scripts/jam-remote' + - 'Makefile' + pull_request: + branches: [ "master" ] + paths-ignore: + - '*.md' + - '.gitignore' + - 'images' + - 'ci/amd64/**' + - 'scripts/jam-remote' + - 'Makefile' + workflow_dispatch: + +jobs: + arm64-rpi5-image-build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Set values + id: set_values + run: | + echo "BUILD_DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV + echo "BUILD_VERSION=$(git describe --always --tags)" >> $GITHUB_ENV + if [[ "${{github.event_name}}" == "pull_request" ]]; then + echo "::set-output name=github_user::${{github.event.pull_request.head.repo.owner.login}}" + else + echo "::set-output name=github_user::$(echo ${{github.repository}} | cut -d'/' -f1)" + fi + + - name: Display the build name + run: echo "Building the joininbox-arm64-rpi5-image-${{ env.BUILD_DATE }}-${{ env.BUILD_VERSION }}" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/amd64,linux/arm64 + + - name: Run the build script + run: | + echo "Running with: ${{steps.set_values.outputs.github_user}} $GITHUB_HEAD_REF" + cd ci/arm64-rpi + bash arm64-rpi5.sh ${{steps.set_values.outputs.github_user}} $GITHUB_HEAD_REF + + - name: Compute checksum of the raw image + run: | + cd ci/arm64-rpi + sha256sum joininbox-arm64-rpi5.img > joininbox-arm64-rpi5.img.sha256 + + - name: Compress image + run: | + cd ci/arm64-rpi + gzip -v9 joininbox-arm64-rpi5.img + + - name: Compute checksum of the compressed image + run: | + cd ci/arm64-rpi + sha256sum joininbox-arm64-rpi5.img.gz > joininbox-arm64-rpi5.img.gz.sha256 + + - name: Upload the image and checksums + uses: actions/upload-artifact@v3 + with: + name: joininbox-arm64-rpi5-image-${{ env.BUILD_DATE }}-${{ env.BUILD_VERSION }} + path: | + ${{ github.workspace }}/ci/arm64-rpi/joininbox-arm64-rpi5.img.sha256 + ${{ github.workspace }}/ci/arm64-rpi/joininbox-arm64-rpi5.img.gz + ${{ github.workspace }}/ci/arm64-rpi/joininbox-arm64-rpi5.img.gz.sha256 diff --git a/Makefile b/Makefile index f26dc65..c34acd8 100644 --- a/Makefile +++ b/Makefile @@ -35,3 +35,20 @@ arm64-rpi-image: # Compute checksum of the compressed image cd ci/arm64-rpi && \ sha256sum joininbox-arm64-rpi.img.gz > joininbox-arm64-rpi.img.gz.sha256 + +arm64-rpi5-image: + # build image + cd ci/arm64-rpi && \ + bash arm64-rpi5.sh $(GITHUB_USER) $(CURRENT_BRANCH) + + # Compute checksum of the raw image + cd ci/arm64-rpi && \ + sha256sum joininbox-arm64-rpi5.img > joininbox-arm64-rpi5.img.sha256 + + # Compress image + cd ci/arm64-rpi && \ + gzip -v9 joininbox-arm64-rpi5.img + + # Compute checksum of the compressed image + cd ci/arm64-rpi && \ + sha256sum joininbox-arm64-rpi5.img.gz > joininbox-arm64-rpi5.img.gz.sha256 diff --git a/ci/amd64/packer.build.amd64-debian.sh b/ci/amd64/packer.build.amd64-debian.sh index 8da4c62..1970b41 100644 --- a/ci/amd64/packer.build.amd64-debian.sh +++ b/ci/amd64/packer.build.amd64-debian.sh @@ -3,7 +3,7 @@ # install packer if ! packer version 2>/dev/null; then curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" + sudo apt-add-repository -y "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" sudo apt-get update echo -e "\nInstalling packer..." sudo apt-get install -y packer diff --git a/ci/arm64-rpi/arm64-rpi5.pkr.hcl b/ci/arm64-rpi/arm64-rpi5.pkr.hcl new file mode 100644 index 0000000..dcdd912 --- /dev/null +++ b/ci/arm64-rpi/arm64-rpi5.pkr.hcl @@ -0,0 +1,60 @@ +variable "github_user" {} +variable "branch" {} + +source "arm" "joininbox-arm64-rpi5" { + file_checksum_type = "sha256" + file_checksum = "6ac3a10a1f144c7e9d1f8e568d75ca809288280a593eb6ca053e49b539f465a4" + file_target_extension = "xz" + file_unarchive_cmd = ["xz", "--decompress", "$ARCHIVE_PATH"] + file_urls = ["https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-11-19/2024-11-19-raspios-bookworm-arm64-lite.img.xz"] + image_build_method = "resize" + image_chroot_env = ["PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"] + image_partitions { + filesystem = "vfat" + mountpoint = "/boot" + name = "boot" + size = "256M" + start_sector = "8192" + type = "c" + } + image_partitions { + filesystem = "ext4" + mountpoint = "/" + name = "root" + size = "0" + start_sector = "532480" + type = "83" + } + image_path = "joininbox-arm64-rpi5.img" + image_size = "8G" + image_type = "dos" + qemu_binary_destination_path = "/usr/bin/qemu-aarch64-static" + qemu_binary_source_path = "/usr/bin/qemu-aarch64-static" +} + +build { + sources = ["source.arm.joininbox-arm64-rpi5"] + + provisioner "shell" { + inline = [ + "echo 'nameserver 1.1.1.1' >/etc/resolv.conf", + "echo 'nameserver 8.8.8.8' >>/etc/resolv.conf", + "echo $(hostname -I | awk '{print $1}') $(hostname) >>/etc/hosts", + "echo 127.0.1.1 $(hostname) >>/etc/hosts", + "echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections", + "apt-get update", + "apt-get install -y sudo wget", + "apt-get -y autoremove", + "apt-get -y clean", + ] + } + + provisioner "shell" { + environment_vars = [ + "github_user=${var.github_user}", + "branch=${var.branch}" + ] + script = "./joininbox.sh" + } + +} diff --git a/ci/arm64-rpi/arm64-rpi5.sh b/ci/arm64-rpi/arm64-rpi5.sh new file mode 100644 index 0000000..6f0a13b --- /dev/null +++ b/ci/arm64-rpi/arm64-rpi5.sh @@ -0,0 +1,20 @@ +#!/bin/bash -e + +if [ $# -gt 0 ]; then + github_user=$1 +else + github_user=openoms +fi + +if [ $# -gt 1 ]; then + branch=$2 +else + branch=master +fi + +# Build the image in docker +echo -e "\nBuild Packer image..." +# from https://hub.docker.com/r/mkaczanowski/packer-builder-arm/tags +docker run --rm --privileged -v /dev:/dev -v ${PWD}:/build \ + mkaczanowski/packer-builder-arm:1.0.4@sha256:df09a8e249a292f10ca9b8cfd73420f5b987b6ac337d4ef28b6f4a8e61118822 \ + build -var "github_user=${github_user}" -var "branch=${branch}" arm64-rpi5.pkr.hcl