Skip to content

Build container image #5

Build container image

Build container image #5

name: Build container image
on:
workflow_call:
inputs:
version:
description: 'uniget version to build container image for'
type: string
required: true
workflow_dispatch:
inputs:
version:
description: 'uniget version to build container image for'
type: string
required: true
permissions:
contents: read
id-token: write
jobs:
image:
name: Build container image
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- 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: Fetch release asset
run: |
INPUT_VERSION="${{ inputs.version }}"
VERSION="${INPUT_VERSION#v}"
echo "### Downloading from release ${VERSION}"
for ARCH in x86_64 aarch64; do
echo "### Downloading for architecture ${ARCH}"
mkdir -p "dist/default_linux_${ARCH}"
url="https://github.com/uniget-org/cli/releases/download/v${VERSION}/uniget_Linux_${ARCH}.tar.gz"
echo "### Downloading from ${url}"
curl --silent --show-error --location --fail "${url}" \
| tar --extract --gzip --directory "dist/default_linux_${ARCH}" uniget
done
- name: Build container image
run: |
INPUT_VERSION="${{ inputs.version }}"
VERSION="${INPUT_VERSION#v}"
echo "### Building container image for version ${VERSION}"
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}"