Skip to content

Build Containerd Binaries #46

Build Containerd Binaries

Build Containerd Binaries #46

name: Build Containerd Binaries
on:
workflow_dispatch:
schedule:
- cron: '0 15 * * *'
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
CONTAINERD_VERSION: ${{ steps.get-version.outputs.CONTAINERD_VERSION }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Get Version
id: get-version
run: |
PACKAGE_VERSION=v$(curl -sSL https://github.com/docker/containerd-packaging/raw/main/debian/changelog | head -n 1 | grep -oP '\(\K[^\)]+' | cut -d'-' -f1)
BINARIES_VERSION=$(curl -s "https://api.github.com/repos/containerd/containerd/releases/latest" | jq -r .tag_name)
sed -i "s@CONTAINERD_VERSION=.*@CONTAINERD_VERSION=${PACKAGE_VERSION}@g" build-containerd.sh
sed -i "s@ARG CONTAINERD_VERSION=.*@ARG CONTAINERD_VERSION=${BINARIES_VERSION}@g" binaries/Dockerfile
echo "CONTAINERD_VERSION=${BINARIES_VERSION}" >> $GITHUB_ENV
echo "CONTAINERD_VERSION=${BINARIES_VERSION}" >> $GITHUB_OUTPUT
echo ""
echo "========== Build Args =========="
echo "PACKAGE_VERSION=${PACKAGE_VERSION}"
echo "BINARIES_VERSION=${BINARIES_VERSION}"
- name: Check Release
id: check-release
run: |
gh release view ${{ env.CONTAINERD_VERSION }} -R ${{ github.repository }} >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Tag
if : steps.check-release.outputs.create == '1'
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "Release ${{ env.CONTAINERD_VERSION }}" || true
git tag ${{ env.CONTAINERD_VERSION }}
git push origin ${{ env.CONTAINERD_VERSION }} || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if : steps.check-release.outputs.create == '1'
run: |
gh release create ${{ env.CONTAINERD_VERSION }} -R ${{ github.repository }} --title ${{ env.CONTAINERD_VERSION }} --notes "**Full Changelog**: [${{ env.CONTAINERD_VERSION }}](https://github.com/containerd/containerd/releases/tag/${{ env.CONTAINERD_VERSION }})"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-binaries:
runs-on: ubuntu-latest
needs: check-version
env:
CONTAINERD_VERSION: ${{ needs.check-version.outputs.CONTAINERD_VERSION }}
steps:
- name: Get Version
run: |
echo "========== Build Args =========="
echo "CONTAINERD_VERSION=${CONTAINERD_VERSION}"
- uses: actions/checkout@v4
with:
ref: ${{ env.CONTAINERD_VERSION }}
- uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: build-binaries-${{ github.sha }}
restore-keys: build-binaries-
- uses: docker/setup-buildx-action@v3
- name: Check Release
id: create-binaries
run: |
gh release view ${{ env.CONTAINERD_VERSION }} -R ${{ github.repository }} | grep containerd-.*.sha256sum >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup QEMU
if : steps.create-binaries.outputs.create == '1'
run: docker run --rm --privileged ghcr.io/loong64/qemu-user-static --reset -p yes
- name: Build Containerd Binaries
uses: docker/build-push-action@v6
if : steps.create-binaries.outputs.create == '1'
with:
context: binaries
platforms: linux/loong64
push: false
load: true
build-args: |
CONTAINERD_VERSION=${{ env.CONTAINERD_VERSION }}
tags: |
containerd-static-loong64:${{ env.CONTAINERD_VERSION }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Upgrade Release
if : steps.create-binaries.outputs.create == '1'
run: |
docker run --rm -v $(pwd)/dist:/dist containerd-static-loong64:${{ env.CONTAINERD_VERSION }}
ls -al dist
gh release upload ${{ env.CONTAINERD_VERSION }} -R ${{ github.repository }} dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move cache
if : steps.create-binaries.outputs.create == '1'
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache