Build container image #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
jobs: | |
image: | |
name: Build container image | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
packages: write | |
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 | |
case "${ARCH}" in | |
x86_64) | |
ALT_ARCH=amd64 | |
;; | |
aarch64) | |
ALT_ARCH=arm64 | |
;; | |
*) | |
echo "### Unsupported architecture ${ARCH}" | |
exit 1 | |
;; | |
esac | |
echo "### Downloading for architecture ${ARCH} (${ALT_ARCH})" | |
mkdir -p "dist/default_linux_${ALT_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_${ALT_ARCH}" uniget | |
done | |
- name: Build container image | |
run: | | |
INPUT_VERSION="${{ inputs.version }}" | |
VERSION="${INPUT_VERSION#v}" | |
echo "### Building container image for version ${VERSION}" | |
docker buildx 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 | |
)" | |
echo "### Tagging ${LATEST_VERSION} as latest" | |
if ! regctl manifest get ghcr.io/uniget-org/cli:${LATEST_VERSION}; then | |
echo " Tag ${LATEST_VERSION} does not exist" | |
exit 1 | |
fi | |
./helper/usr/local/bin/regctl image copy \ | |
"ghcr.io/uniget-org/cli:${VERSION}" \ | |
"ghcr.io/uniget-org/cli:${LATEST_VERSION}" |