diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..23c4cb3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/next.yml b/.github/workflows/next.yml new file mode 100644 index 0000000..c263425 --- /dev/null +++ b/.github/workflows/next.yml @@ -0,0 +1,125 @@ +--- +name: "🏗 Next" + +on: + push: + branch: + - master + +jobs: + build_staging: + runs-on: ubuntu-latest + strategy: + matrix: + type: + - debian + name: debian staging build container + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.4.0 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image + uses: docker/build-push-action@v6.3.0 + with: + file: staging/Dockerfile.${{ matrix.type }}.staging + platforms: linux/amd64 + push: true + provenance: false + tags: | + ghcr.io/igaw/linux-nvme/${{ matrix.type }}.staging:next + + build_tools: + runs-on: ubuntu-latest + name: build samurai and muon + needs: build_staging + container: + image: ghcr.io/igaw/linux-nvme/debian.staging:next + steps: + - uses: actions/checkout@v4 + - name: build + run: | + scripts/build-muon.sh + - uses: actions/upload-artifact@v4 + name: Upload artifacts + with: + name: samu-muon + path: bin + + deploy_debian_containers: + runs-on: ubuntu-latest + strategy: + matrix: + type: + - debian + - debian.python + needs: build_tools + name: debian build containers + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: samu-muon + path: bin + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.4.0 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image + uses: docker/build-push-action@v6.3.0 + with: + context: . + file: Dockerfile.${{ matrix.type }} + platforms: linux/amd64 + push: true + provenance: false + tags: | + ghcr.io/igaw/linux-nvme/${{ matrix.type }}:next + + deploy_cross_containers: + runs-on: ubuntu-latest + strategy: + matrix: + arch: + - armhf + - ppc64le + - s390x + name: ubuntu cross container + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.4.0 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image + uses: docker/build-push-action@v6.3.0 + with: + file: Dockerfile.ubuntu.${{ matrix.arch }} + platforms: linux/amd64 + push: true + provenance: false + tags: | + ghcr.io/igaw/linux-nvme/ubuntu-cross-${{ matrix.arch }}:next diff --git a/.github/workflows/registry.yml b/.github/workflows/registry.yml new file mode 100644 index 0000000..b14f9c3 --- /dev/null +++ b/.github/workflows/registry.yml @@ -0,0 +1,28 @@ +--- +name: "♻ Cleanup GHCR" + +on: + schedule: + - cron: "0 0 * * 0" # At 00:00 on Sunday. + +jobs: + clean-ghcr: + name: cleanup images + runs-on: ubuntu-latest + steps: + - name: Delete old container images + uses: snok/container-retention-policy@v2 + id: retention + with: + image-names: linux-nvme* + cut-off: One week ago UTC + keep-at-least: 1 + timestamp-to-use: updated_at + skip-tags: latest + account-type: personal + token: ${{ secrets.PAT }} + + - name: Print Output + run: |- + echo "Failed cleanup for = ${{ steps.retention.outputs.failed }}" + echo "Needs manual cleanup = ${{ steps.retention.outputs.needs-github-assistance }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a19edad --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,131 @@ +--- +name: "🚀 Release" + +on: + push: + tags: + - '*.*' + +jobs: + build_staging: + runs-on: ubuntu-latest + strategy: + matrix: + type: + - debian + name: debian staging build container + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.4.0 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image + uses: docker/build-push-action@v6.3.0 + with: + file: staging/Dockerfile.${{ matrix.type }}.staging + platforms: linux/amd64 + push: true + provenance: false + tags: | + ghcr.io/igaw/linux-nvme/${{ matrix.type }}.staging:main + + build_tools: + runs-on: ubuntu-latest + name: build samurai and muon + needs: build_staging + container: + image: ghcr.io/igaw/linux-nvme/debian.staging:main + steps: + - uses: actions/checkout@v4 + - name: build + run: | + scripts/build-muon.sh + - uses: actions/upload-artifact@v4 + name: Upload artifacts + with: + name: samu-muon + path: bin + + deploy_debian_containers: + runs-on: ubuntu-latest + strategy: + matrix: + type: + - debian + - debian.python + needs: build_tools + name: debian build containers + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Get release + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: samu-muon + path: bin + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.4.0 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image + uses: docker/build-push-action@v6.3.0 + with: + context: . + file: Dockerfile.${{ matrix.type }} + platforms: linux/amd64 + push: true + provenance: false + tags: | + ghcr.io/igaw/linux-nvme/${{ matrix.type }}:${{ env.RELEASE_VERSION }} + ghcr.io/igaw/linux-nvme/${{ matrix.type }}:latest + + deploy_cross_containers: + runs-on: ubuntu-latest + strategy: + matrix: + arch: + - armhf + - ppc64le + - s390x + name: ubuntu cross container + steps: + - name: Check out repo + uses: actions/checkout@v4 + - name: Get release + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.4.0 + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build image + uses: docker/build-push-action@v6.3.0 + with: + file: Dockerfile.ubuntu.${{ matrix.arch }} + platforms: linux/amd64 + push: true + provenance: false + tags: | + ghcr.io/igaw/linux-nvme/ubuntu-cross-${{ matrix.arch }}:${{ env.RELEASE_VERSION }} + ghcr.io/igaw/linux-nvme/ubuntu-cross-${{ matrix.arch }}:latest diff --git a/Dockerfile.debian b/Dockerfile.debian new file mode 100644 index 0000000..9f048f0 --- /dev/null +++ b/Dockerfile.debian @@ -0,0 +1,19 @@ +FROM debian:bookworm-slim + +ARG TARGETPLATFORM +ARG DEBIAN_FRONTEND=noninteractive +ENV LANG=en_US.utf8 +ENV TZ=Europe/Berlin +RUN apt-get update && \ + apt-get install -y locales tzdata && \ + localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \ + apt-get install --no-install-recommends -y \ + python3-distutils python3-openssl \ + make meson gcc g++ clang pkg-config \ + libjson-c-dev libssl-dev libkeyutils-dev libdbus-1-dev swig xz-utils \ + ca-certificates git libcurl4 libarchive13 \ + python3-sphinx asciidoc xmlto && \ + apt-get update && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +COPY --chmod=755 bin/samu bin/muon /usr/bin diff --git a/Dockerfile.debian.python b/Dockerfile.debian.python new file mode 100644 index 0000000..7ab0694 --- /dev/null +++ b/Dockerfile.debian.python @@ -0,0 +1,18 @@ +FROM debian:bookworm-slim + +ARG TARGETPLATFORM +ARG DEBIAN_FRONTEND=noninteractive +ENV LANG=en_US.utf8 +ENV TZ=Europe/Berlin +RUN apt-get update && \ + apt-get install -y locales tzdata && \ + localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \ + apt-get install --no-install-recommends -y \ + meson gcc g++ clang pkg-config git \ + libjson-c-dev libssl-dev libkeyutils-dev libdbus-1-dev libpython3-dev \ + pipx python3-dev swig xz-utils \ + xz-utils \ + lcov && \ + apt-get update && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/Dockerfile.ubuntu.armhf b/Dockerfile.ubuntu.armhf new file mode 100644 index 0000000..3371073 --- /dev/null +++ b/Dockerfile.ubuntu.armhf @@ -0,0 +1,18 @@ +FROM ubuntu:jammy + +ARG TARGETPLATFORM +ARG DEBIAN_FRONTEND=noninteractive +ENV LANG=en_US.utf8 +RUN dpkg --add-architecture armhf && \ + sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list && \ + echo "deb [arch=armhf] http://ports.ubuntu.com/ jammy main universe restricted" > /etc/apt/sources.list.d/armhf.list && \ + echo "deb [arch=armhf] http://ports.ubuntu.com/ jammy-updates main universe restricted" >> /etc/apt/sources.list.d/armhf.list && \ + apt-get update && \ + apt-get install -y locales && \ + localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \ + apt-get install --no-install-recommends -y \ + meson pkg-config ca-certificates git qemu-user-static \ + gcc-arm-linux-gnueabihf libc-dev:armhf libjson-c-dev:armhf \ + xz-utils && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/Dockerfile.ubuntu.ppc64le b/Dockerfile.ubuntu.ppc64le new file mode 100644 index 0000000..e41040f --- /dev/null +++ b/Dockerfile.ubuntu.ppc64le @@ -0,0 +1,18 @@ +FROM ubuntu:jammy + +ARG TARGETPLATFORM +ARG DEBIAN_FRONTEND=noninteractive +ENV LANG=en_US.utf8 +RUN dpkg --add-architecture ppc64el && \ + sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list && \ + echo "deb [arch=ppc64el] http://ports.ubuntu.com/ jammy main universe restricted" > /etc/apt/sources.list.d/ppc64le.list && \ + echo "deb [arch=ppc64el] http://ports.ubuntu.com/ jammy-updates main universe restricted" >> /etc/apt/sources.list.d/ppc64le.list && \ + apt-get update && \ + apt-get install -y locales && \ + localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \ + apt-get install --no-install-recommends -y \ + meson pkg-config ca-certificates git qemu-user-static \ + gcc-powerpc64le-linux-gnu libc-dev:ppc64el libjson-c-dev:ppc64el \ + xz-utils && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/Dockerfile.ubuntu.s390x b/Dockerfile.ubuntu.s390x new file mode 100644 index 0000000..368d9ca --- /dev/null +++ b/Dockerfile.ubuntu.s390x @@ -0,0 +1,18 @@ +FROM ubuntu:jammy + +ARG TARGETPLATFORM +ARG DEBIAN_FRONTEND=noninteractive +ENV LANG=en_US.utf8 +RUN dpkg --add-architecture s390x && \ + sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list && \ + echo "deb [arch=s390x] http://ports.ubuntu.com/ jammy main universe restricted" > /etc/apt/sources.list.d/armhf.list && \ + echo "deb [arch=s390x] http://ports.ubuntu.com/ jammy-updates main universe restricted" >> /etc/apt/sources.list.d/armhf.list && \ + apt-get update && \ + apt-get install -y locales && \ + localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \ + apt-get install --no-install-recommends -y \ + meson pkg-config ca-certificates git qemu-user-static \ + gcc-s390x-linux-gnu libc-dev:s390x libjson-c-dev:s390x \ + xz-utils && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/build-all.sh b/build-all.sh new file mode 100755 index 0000000..83dcc32 --- /dev/null +++ b/build-all.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +for dockerfile in Dockerfile.*; do + docker buildx build --platform linux/amd64 . -f "${dockerfile}" +done diff --git a/scripts/build-muon.sh b/scripts/build-muon.sh new file mode 100755 index 0000000..b278ec9 --- /dev/null +++ b/scripts/build-muon.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +BUILDDIR="$(pwd)/.build" +CC=${CC:-"gcc"} + +tools_build_samurai() { + mkdir -p "${BUILDDIR}"/build-tools + git clone --depth 1 https://github.com/michaelforney/samurai.git \ + "${BUILDDIR}/build-tools/samurai" + pushd "${BUILDDIR}/build-tools/samurai" || exit 1 + + CC="${CC}" make + SAMU="${BUILDDIR}/build-tools/samurai/samu" + + popd || exit 1 + + cp ${SAMU} . +} + +tools_build_muon() { + mkdir -p "${BUILDDIR}"/build-tools + git clone --depth 1 https://git.sr.ht/~lattis/muon \ + "${BUILDDIR}/build-tools/muon" + pushd "${BUILDDIR}/build-tools/muon" || exit 1 + + CC="${CC}" ninja="${SAMU}" meson setup \ + -Dprefix="${BUILDDIR}/build-tools" \ + -Dlibcurl=enabled \ + -Dlibarchive=enabled \ + -Dlibpkgconf=enabled \ + -Ddocs=disabled \ + -Dsamurai=disabled \ + "${BUILDDIR}/build-tools/.build-muon" + meson compile -C "${BUILDDIR}/build-tools/.build-muon" + meson test -C "${BUILDDIR}/build-tools/.build-muon" + + popd || exit 1 + + cp "${BUILDDIR}/build-tools/.build-muon/muon" . +} + +export PATH=$PATH:$(pwd) + +tools_build_samurai +tools_build_muon + +mkdir -p bin +mv samu bin +mv muon bin diff --git a/staging/Dockerfile.debian.staging b/staging/Dockerfile.debian.staging new file mode 100644 index 0000000..823acf9 --- /dev/null +++ b/staging/Dockerfile.debian.staging @@ -0,0 +1,14 @@ +FROM debian:bookworm-slim + +ARG TARGETPLATFORM +ARG DEBIAN_FRONTEND=noninteractive +ENV LANG=en_US.utf8 +RUN apt-get update && \ + apt-get install -y locales && \ + localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \ + apt-get install --no-install-recommends -y \ + gcc g++ pkg-config libpkgconf-dev libcurl4-openssl-dev libarchive-dev \ + ca-certificates git make meson libpam-dev libcap-ng-dev python3 && \ + apt-get update && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*