diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e3b9de..8768056 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,6 +79,8 @@ jobs: - uses: actions/setup-go@v3 with: go-version: '1.21' + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - uses: actions/checkout@v3 - name: Release beskar-ostree image run: ./scripts/mage ci:image ghcr.io/ctrliq/beskar-ostree:${{ github.ref_name }} "${{ github.actor }}" "${{ secrets.GITHUB_TOKEN }}" diff --git a/build/mage/build.go b/build/mage/build.go index db67797..ef676c8 100644 --- a/build/mage/build.go +++ b/build/mage/build.go @@ -49,6 +49,7 @@ type genAPI struct { type binaryConfig struct { configFiles map[string]string excludedPlatforms map[dagger.Platform]struct{} + useQEMUForCIImage bool execStmts [][]string useProto bool genAPI *genAPI @@ -172,6 +173,7 @@ var binaries = map[string]binaryConfig{ "linux/arm/v6": {}, "linux/arm/v7": {}, }, + useQEMUForCIImage: true, }, BeskarMirrorBinary: { configFiles: map[string]string{ @@ -311,7 +313,8 @@ func (b Build) build(ctx context.Context, name string) error { } binary := name - if string(platform) != currentPlatform { + nativePlatform := string(platform) == currentPlatform + if !nativePlatform { binary += "-" + getPlatformBinarySuffix(string(platform)) } @@ -319,7 +322,15 @@ func (b Build) build(ctx context.Context, name string) error { src := getSource(client) - golang := client.Container().From(GoImage) + var opts []dagger.ContainerOpts + + if binaryConfig.useQEMUForCIImage && buildOpts.publishOptions != nil && !nativePlatform { + opts = append(opts, dagger.ContainerOpts{ + Platform: platform, + }) + } + + golang := client.Container(opts...).From(GoImage) golang = golang. WithMountedDirectory("/src", src).