Build Containerd Packages #61
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 Containerd Packages | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 21 * * *' | |
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) | |
sed -i "s@CONTAINERD_VERSION=.*@CONTAINERD_VERSION=${PACKAGE_VERSION}@g" build-containerd.sh | |
sed -i "s@ARG CONTAINERD_VERSION=.*@ARG CONTAINERD_VERSION=${PACKAGE_VERSION}@g" binaries/Dockerfile | |
echo "CONTAINERD_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV | |
echo "CONTAINERD_VERSION=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT | |
echo "" | |
echo "========== Build Args ==========" | |
echo "CONTAINERD_VERSION=${PACKAGE_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 }})" --latest=false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build-package: | |
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: docker/setup-buildx-action@v3 | |
- name: Check Release | |
id: create-package | |
run: | | |
gh release view ${{ env.CONTAINERD_VERSION }} -R ${{ github.repository }} | grep containerd.*.deb >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup QEMU | |
if : steps.create-package.outputs.create == '1' | |
run: docker run --rm --privileged ghcr.io/loong64/qemu-user-static --reset -p yes | |
- name: Build Containerd Package | |
if : steps.create-package.outputs.create == '1' | |
run: | | |
sed -i "s@CONTAINERD_VERSION=.*@CONTAINERD_VERSION=${{ env.CONTAINERD_VERSION }}@g" build-containerd.sh | |
bash build-containerd.sh | |
- name: Upgrade Release | |
if : steps.create-package.outputs.create == '1' | |
run: | | |
ls -al dist | |
gh release upload ${{ env.CONTAINERD_VERSION }} -R ${{ github.repository }} dist/* | |
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-packages-${{ github.sha }} | |
restore-keys: build-packages- | |
- 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 |