Skip to content

Commit 0fe6599

Browse files
committed
use qemu/docker to build arch specific binaries
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent 1dd17f0 commit 0fe6599

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

.github/workflows/release-binaries.yml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,25 @@ on:
1212
type: string
1313

1414
jobs:
15-
build-and-release:
15+
build-linux-binaries:
1616
runs-on: ubuntu-latest
17-
permissions:
18-
contents: write # Needed for creating GitHub releases
19-
packages: read
20-
2117
strategy:
2218
matrix:
23-
goos: [linux]
24-
goarch: [amd64, arm64]
25-
19+
arch: [amd64, arm64]
2620
steps:
2721
- name: Checkout repository
2822
uses: actions/checkout@v4
2923
with:
3024
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
3125
fetch-depth: 0 # Fetch all history for proper versioning
3226

33-
- name: Set up Go
34-
uses: actions/setup-go@v5
27+
- name: Set up Docker
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
3532
with:
36-
go-version: '1.24'
37-
cache: true
33+
platforms: linux/amd64,linux/arm64
3834

3935
- name: Set VERSION environment variable
4036
run: |
@@ -44,31 +40,36 @@ jobs:
4440
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
4541
fi
4642
47-
- name: Build binary
43+
- name: Build Linux ${{ matrix.arch }} binary
4844
env:
49-
GOOS: ${{ matrix.goos }}
50-
GOARCH: ${{ matrix.goarch }}
45+
GOARCH: ${{ matrix.arch }}
5146
OUTPUT_NAME_WITH_ARCH: "true"
52-
BUILD_USER: "github-actions"
53-
BUILD_DATE: ${{ github.event.repository.updated_at }}
54-
GO_FLAGS: "-tags=netgo"
55-
run: ./build/build.sh
47+
VERSION: ${{ env.VERSION }}
48+
run: |
49+
# Create a Docker container with the appropriate architecture
50+
docker run --rm -v ${PWD}:/go/src/github.com/google/cadvisor \
51+
--platform linux/${{ matrix.arch }} \
52+
golang:1.24 \
53+
/bin/bash -c "cd /go/src/github.com/google/cadvisor && GOARCH=${{ matrix.arch }} OUTPUT_NAME_WITH_ARCH=true VERSION=${{ env.VERSION }} ./build/build.sh"
5654
57-
- name: Prepare binary for upload
55+
- name: Generate SHA256 checksums
5856
run: |
5957
cd _output
60-
sha256sum cadvisor-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }} > cadvisor-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.sha256
58+
# List all files in the output directory
59+
ls -la
60+
# Generate SHA256 checksums for all binaries
61+
find . -name "cadvisor*" -type f -not -name "*.sha256" -exec sh -c 'sha256sum "$1" > "$1.sha256"' _ {} \;
6162
6263
- name: Upload artifacts
6364
uses: actions/upload-artifact@v4
6465
with:
65-
name: cadvisor-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}
66+
name: cadvisor-linux-${{ matrix.arch }}
6667
path: |
67-
_output/cadvisor-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}*
68+
_output/cadvisor*
6869
retention-days: 1
6970

7071
create-release:
71-
needs: build-and-release
72+
needs: build-linux-binaries
7273
runs-on: ubuntu-latest
7374
permissions:
7475
contents: write # Needed for creating GitHub releases

0 commit comments

Comments
 (0)