From 65540e1e5f4c74e670ca65d9508e28924f19c013 Mon Sep 17 00:00:00 2001 From: openoms Date: Sun, 10 Mar 2024 21:34:44 +0100 Subject: [PATCH] ci: add base image build add stop file and --image_size 20G --- .github/workflows/arm64-rpi-base-image.yml | 83 ++++++++++++++++++++++ ci/arm64-rpi/build.arm64-rpi.pkr.hcl | 8 ++- ci/set_variables.sh | 4 ++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/arm64-rpi-base-image.yml diff --git a/.github/workflows/arm64-rpi-base-image.yml b/.github/workflows/arm64-rpi-base-image.yml new file mode 100644 index 000000000..a8e259f61 --- /dev/null +++ b/.github/workflows/arm64-rpi-base-image.yml @@ -0,0 +1,83 @@ +name: arm64-rpi-base-image-build + +concurrency: + group: arm64-rpi-base-image-build-${{ github.head_ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + push: + branches: ['dev', 'v1.10', 'v1.11'] + paths: + - 'build_sdcard.sh' + - 'home.admin/bitcoin.install.sh' + - 'home.admin/tor.install.sh' + - 'home.admin/blitz.i2pd.sh' + - 'home.admin/blitz.web.sh' + - 'home.admin/blitz.display.sh' + - 'ci/arm64-rpi/**' + pull_request: + branches: ['dev', 'v1.10', 'v1.11'] + paths: + - 'build_sdcard.sh' + - 'home.admin/bitcoin.install.sh' + - 'home.admin/tor.install.sh' + - 'home.admin/blitz.i2pd.sh' + - 'home.admin/blitz.web.sh' + - 'home.admin/blitz.display.sh' + - 'ci/arm64-rpi/**' + +jobs: + arm64-rpi-image-build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - 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 [ -z "$GITHUB_HEAD_REF" ]; then + echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV + else + echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + fi + if [[ "${{github.event_name}}" == "pull_request" ]]; then + echo "GITHUB_USER=${{github.event.pull_request.head.repo.owner.login}}" >> $GITHUB_OUTPUT + else + echo "GITHUB_USER=$(echo ${{github.repository}} | cut -d'/' -f1)" >> $GITHUB_OUTPUT + fi + + - name: Display the build name + run: echo "Building the raspiblitz-arm64-rpi-base-image-${{ env.BUILD_DATE }}-${{ env.BUILD_VERSION }}" + + - name: Run the build script + run: | + echo "Using the variables: --pack base --github_user ${{steps.set_values.outputs.GITHUB_USER}} --branch ${{env.BRANCH_NAME}} --image_size 20G" + cd ci/arm64-rpi + bash packer.build.arm64-rpi.sh --pack base --github_user ${{steps.set_values.outputs.GITHUB_USER}} --branch ${{env.BRANCH_NAME}} --image_size 20G + + - name: Compute checksum of the raw image + run: | + cd ci/arm64-rpi + sha256sum raspiblitz-arm64-rpi-base.img > raspiblitz-arm64-rpi-base.img.sha256 + + - name: Compress image + run: | + cd ci/arm64-rpi + gzip -v9 raspiblitz-arm64-rpi-base.img + + - name: Compute checksum of the compressed image + run: | + cd ci/arm64-rpi + sha256sum raspiblitz-arm64-rpi-base.img.gz > raspiblitz-arm64-rpi-base.img.gz.sha256 + + - name: Upload the image and checksums + uses: actions/upload-artifact@v4 + with: + name: raspiblitz-arm64-rpi-image-${{ env.BUILD_DATE }}-${{ env.BUILD_VERSION }} + path: | + ${{ github.workspace }}/ci/arm64-rpi/raspiblitz-arm64-rpi-base.img.sha256 + ${{ github.workspace }}/ci/arm64-rpi/raspiblitz-arm64-rpi-base.img.gz + ${{ github.workspace }}/ci/arm64-rpi/raspiblitz-arm64-rpi-base.img.gz.sha256 diff --git a/ci/arm64-rpi/build.arm64-rpi.pkr.hcl b/ci/arm64-rpi/build.arm64-rpi.pkr.hcl index 5726087d3..1619e138d 100644 --- a/ci/arm64-rpi/build.arm64-rpi.pkr.hcl +++ b/ci/arm64-rpi/build.arm64-rpi.pkr.hcl @@ -29,7 +29,7 @@ source "arm" "raspiblitz-arm64-rpi" { type = "83" } image_path = "raspiblitz-arm64-rpi-${var.pack}.img" - image_size = "28G" + image_size = var.image_size image_type = "dos" qemu_binary_destination_path = "/usr/bin/qemu-arm-static" qemu_binary_source_path = "/usr/bin/qemu-arm-static" @@ -68,4 +68,10 @@ build { "echo 'OK'", ] } + + provisioner "shell" { + inline = [ + "if [ \"${var.pack}\" = \"base\" ]; then echo 'Adding stop file to /boot/firmware/'; touch /boot/firmware/stop; fi" + ] + } } diff --git a/ci/set_variables.sh b/ci/set_variables.sh index c02a49fa2..14dd88acc 100755 --- a/ci/set_variables.sh +++ b/ci/set_variables.sh @@ -45,6 +45,10 @@ function set_variables() { params[desktop]="$2" shift 2 ;; + --image_size) + params[image_size]="$2" + shift 2 + ;; --) shift break