Skip to content

buildx-binfmt

buildx-binfmt #11

Workflow file for this run

name: buildx-binfmt
on:
workflow_dispatch:
inputs:
source-tag:
description: 'binfmt source Docker tag'
required: true
default: 'patch_loong64'
full-tag:
description: 'binfmt full Docker tag'
required: true
default: 'v8.1.5-43'
jobs:
build:
runs-on: ubuntu-24.04
steps:
-
name: Checkout source
uses: actions/checkout@v4
with:
repository: loong64/binfmt
ref: ${{ github.event.inputs.source-tag }}
-
name: Setup Environment
run: |
GO_VERSION=$(cat Dockerfile | grep '^ARG GO_VERSION=' | awk -F "=" '{print $2}')
QEMU_VERSION=$(cat docker-bake.hcl | grep "QEMU_VERSION" -A2 | grep default | awk -F'"' '{print $2}')
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Setup QEMU
run: docker run --rm --privileged ghcr.io/loong64/qemu-user-static --reset -p yes
-
name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
-
name: Build binfmt
run: |
GOOS=linux GOARCH=loong64 go build -ldflags "-X main.revision=$(git rev-parse --short HEAD) -X main.qemuVersion=${QEMU_VERSION}" -o /go/bin/binfmt ./cmd/binfmt
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Prepare environment
run: |
full_tag=${{ github.event.inputs.full-tag }}
major_tag=${full_tag%%-*}
echo "full_tag=$full_tag" >> $GITHUB_ENV
echo "major_tag=$major_tag" >> $GITHUB_ENV
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.loong64
platforms: linux/loong64
push: true
build-args: |
BUILDPLATFORM=linux/loong64
GO_VERSION=${GO_VERSION}
QEMU_VERSION=${QEMU_VERSION}
tags: |
ghcr.io/${{ github.repository_owner }}/binfmt:${{ env.full_tag }}
ghcr.io/${{ github.repository_owner }}/binfmt:${{ env.major_tag }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max