From 2c03aa846236bb5d3e5e93ec85d34f868d2156ad Mon Sep 17 00:00:00 2001 From: Nicholas Dille Date: Sun, 20 Oct 2024 12:53:28 +0200 Subject: [PATCH] Added container image --- .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++++++++ Dockerfile | 9 +++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d11b0e9d..1bad4cc4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,3 +79,64 @@ jobs: --build-arg ACTIONS_ID_TOKEN_REQUEST_TOKEN \ --build-arg GITHUB_REF_NAME \ . + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: uniget-bot + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install uniget + uses: uniget-org/uniget-action@v1 + with: + prefix: helper + tools: jq regclient + + - name: Build container image + run: | + case "$( uname -m )" in + x86_64) + ARCH=amd64 + ;; + aarch64) + ARCH=arm64 + ;; + *) + echo "Unsupported architecture: $( uname -m )" + exit 1 + ;; + esac + UNIGET_PATH="$( + ./helper/usr/local/bin/jq --raw-output --arg arch "${ARCH}" '.[] | select(.goarch == $arch) | .path' dist/artifacts.json \ + | cut -d/ -f-2 + )" + + mv "${UNIGET_PATH}" "dist/default_linux_${ARCH}" + VERSION="$( + "dist/default_linux_${ARCH}/uniget" --version \ + | cut -d' ' -f3 + )" + + docker build . \ + --target systemd-uniget \ + --platform linux/amd64,linux/arm64 \ + --build-arg version="${VERSION}" \ + --tag ghcr.io/uniget-org/uniget:${VERSION} \ + --push + + LATEST_VERSION="$( + ./helper/usr/local/bin/regctl tag list ghcr.io/uniget-org/cli \ + | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \ + | sort -Vr \ + | head -n 1 + )" + ./helper/usr/local/bin/regctl image copy \ + "ghcr.io/uniget-org/uniget:${VERSION}" \ + "ghcr.io/uniget-org/uniget:${LATEST_VERSION}" diff --git a/Dockerfile b/Dockerfile index 6ad215ea..cbefbe57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -116,4 +116,11 @@ COPY --from=bin /uniget /uniget ENTRYPOINT [ "/uniget"] FROM ghcr.io/uniget-org/images/systemd:ubuntu24.04 AS systemd-uniget -COPY --from=bin /uniget /usr/local/bin/uniget \ No newline at end of file +ARG version +ARG TARGETARCH +COPY dist/default_linux_${TARGETARCH}/uniget /usr/local/bin/uniget +LABEL \ + org.opencontainers.image.source="https://github.com/uniget-org/cli" \ + org.opencontainers.image.title="uniget" \ + org.opencontainers.image.description="The universal installer and updater for (container) tools" \ + org.opencontainers.image.version="${version}"