From 5d4f90905be156fdf87b22fe1e77c76b61dd1e7d Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Wed, 15 Jan 2025 22:10:25 -0500 Subject: [PATCH 1/3] add a container to preload dependencies for CI --- container/Containerfile | 10 ++++++++++ container/docker-bake.hcl | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 container/Containerfile create mode 100644 container/docker-bake.hcl diff --git a/container/Containerfile b/container/Containerfile new file mode 100644 index 0000000000..67b69b3278 --- /dev/null +++ b/container/Containerfile @@ -0,0 +1,10 @@ +FROM ghcr.io/void-linux/void-glibc-full:latest + +ARG MIRROR="https://repo-default.voidlinux.org/" + +RUN xbps-install -SyuR "${MIRROR}/current" xbps \ + && xbps-install -yuR "${MIRROR}/current" \ + && xbps-install -yuR "${MIRROR}/current" \ + bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs + +CMD ["/bin/sh"] diff --git a/container/docker-bake.hcl b/container/docker-bake.hcl new file mode 100644 index 0000000000..93e581af9e --- /dev/null +++ b/container/docker-bake.hcl @@ -0,0 +1,20 @@ +variable "MIRROR" { + default = "https://repo-ci.voidlinux.org/" +} + +target "docker-metadata-action" {} + +target "_common" { + inherits = ["docker-metadata-action"] + dockerfile = "container/Containerfile" + cache-to = ["type=local,dest=/tmp/buildx-cache"] + cache-from = ["type=local,src=/tmp/buildx-cache"] + args = { + "MIRROR" = "${MIRROR}" + } +} + +target "void-mklive" { + inherits = ["_common"] + platforms = ["linux/amd64"] +} From 9572631a49f72eeabcede2c8d053ed9ca14c00ef Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Wed, 15 Jan 2025 22:11:06 -0500 Subject: [PATCH 2/3] .github/workflows: add workflow to build container --- .github/workflows/container.yaml | 89 ++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/container.yaml diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml new file mode 100644 index 0000000000..6017be3915 --- /dev/null +++ b/.github/workflows/container.yaml @@ -0,0 +1,89 @@ +--- +name: 'Build container' + +on: + workflow_dispatch: + pull_request: + branches: + - master + paths: + - container/** + push: + branches: + - master + paths: + - container/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: classabbyamp/treeless-checkout-action@v1 + + - name: Get image release + id: release + run: | + # gets the list of all date-shaped tags for the image, finds the most recent one + tag="$(skopeo list-tags "docker://ghcr.io/${{ github.repository_owner }}/void-mklive" | \ + jq -r '.Tags | sort | reverse | map(select(test("^[0-9]{8}(R[0-9]+)?$")))[0]')" + # tags from a different day or pre-YYYYMMDDRN + if [ "${tag%R*}" != "$(date -u +%Y%m%d)" ] || [ "${tag%R*}" = "${tag}" ]; then + rel=1 + else + rel=$(( ${tag##*R} + 1 )) + fi + echo "rel=${rel}" >> "${GITHUB_OUTPUT}" + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/${{ github.repository_owner }}/void-mklive + tags: | + type=sha,prefix= + type=raw,value=latest,enable={{is_default_branch}} + type=raw,value={{date 'YYYYMMDD'}}R${{ steps.release.outputs.rel }},enable={{is_default_branch}},priority=1000 + flavor: latest=false + labels: | + org.opencontainers.image.authors=Void Linux team and contributors + org.opencontainers.image.url=https://voidlinux.org + org.opencontainers.image.documentation=https://github.com/${{ github.repository }} + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.vendor=Void Linux + org.opencontainers.image.title=Void Linux mklive container + org.opencontainers.image.description=Image for building mklive images + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GCHR + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push images + id: build_and_push + uses: docker/bake-action@v3 + with: + push: ${{ github.event_name != 'pull_request' }} + targets: void-mklive + files: | + container/docker-bake.hcl + ${{ steps.meta.outputs.bake-file }} + set: | + _common.cache-to=type=gha + _common.cache-from=type=gha From d4937c64e14d64b1f0f1b09638a6f4b633caae10 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Wed, 15 Jan 2025 22:11:18 -0500 Subject: [PATCH 3/3] .github/workflows: use container --- .github/workflows/gen-images.yml | 59 ++++++++------------------------ 1 file changed, 15 insertions(+), 44 deletions(-) diff --git a/.github/workflows/gen-images.yml b/.github/workflows/gen-images.yml index e69a54d4d9..0749295077 100644 --- a/.github/workflows/gen-images.yml +++ b/.github/workflows/gen-images.yml @@ -110,7 +110,7 @@ jobs: flavor: ${{ fromJson(needs.prepare.outputs.live_flavors) }} container: - image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' + image: 'ghcr.io/void-linux/void-mklive:20250116R1' options: --privileged volumes: - /dev:/dev @@ -121,13 +121,8 @@ jobs: steps: - name: Prepare container shell: sh - run: | - # Switch to mirror - mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ - sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ - /etc/xbps.d/*-repository-*.conf - xbps-install -Syu xbps && xbps-install -yu - xbps-install -yu bash make git kmod xz lzo qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs + run: xbps-install -Syu xbps && xbps-install -yu + - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -160,7 +155,7 @@ jobs: arch: ${{ fromJson(needs.prepare.outputs.rootfs) }} container: - image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' + image: 'ghcr.io/void-linux/void-mklive:20250116R1' options: --privileged volumes: - /dev:/dev @@ -171,13 +166,8 @@ jobs: steps: - name: Prepare container shell: sh - run: | - # Switch to mirror - mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ - sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ - /etc/xbps.d/*-repository-*.conf - xbps-install -Syu xbps && xbps-install -yu - xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs + run: xbps-install -Syu xbps && xbps-install -yu + - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -210,7 +200,7 @@ jobs: platform: ${{ fromJson(needs.prepare.outputs.platformfs) }} container: - image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' + image: 'ghcr.io/void-linux/void-mklive:20250116R1' options: --privileged volumes: - /dev:/dev @@ -221,13 +211,8 @@ jobs: steps: - name: Prepare container shell: sh - run: | - # Switch to mirror - mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ - sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ - /etc/xbps.d/*-repository-*.conf - xbps-install -Syu xbps && xbps-install -yu - xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs + run: xbps-install -Syu xbps && xbps-install -yu + - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -261,7 +246,7 @@ jobs: platform: ${{ fromJson(needs.prepare.outputs.sbc_imgs) }} container: - image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' + image: 'ghcr.io/void-linux/void-mklive:20250116R1' options: --privileged volumes: - /dev:/dev @@ -272,13 +257,8 @@ jobs: steps: - name: Prepare container shell: sh - run: | - # Switch to mirror - mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ - sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ - /etc/xbps.d/*-repository-*.conf - xbps-install -Syu xbps && xbps-install -yu - xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs + run: xbps-install -Syu xbps && xbps-install -yu + - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1 @@ -314,7 +294,7 @@ jobs: - build-sbc-img container: - image: 'ghcr.io/void-linux/void-glibc-full:20231230R1' + image: 'ghcr.io/void-linux/void-mklive:20250116R1' env: PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' MKLIVE_REV: "${{ needs.prepare.outputs.revision }}" @@ -322,17 +302,8 @@ jobs: steps: - name: Prepare container shell: sh - run: | - # Switch to mirror - mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/ - sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \ - /etc/xbps.d/*-repository-*.conf - # Sync and upgrade once, assume error comes from xbps update - xbps-install -Syu || xbps-install -yu xbps - # Upgrade again (in case there was a xbps update) - xbps-install -yu - # Install depedencies - xbps-install -yu bash make git outils + run: xbps-install -Syu xbps && xbps-install -yu + - name: Clone and checkout uses: classabbyamp/treeless-checkout-action@v1