12
12
type : string
13
13
14
14
jobs :
15
- build-and-release :
15
+ build-linux-binaries :
16
16
runs-on : ubuntu-latest
17
- permissions :
18
- contents : write # Needed for creating GitHub releases
19
- packages : read
20
-
21
17
strategy :
22
18
matrix :
23
- goos : [linux]
24
- goarch : [amd64, arm64]
25
-
19
+ arch : [amd64, arm64]
26
20
steps :
27
21
- name : Checkout repository
28
22
uses : actions/checkout@v4
29
23
with :
30
24
ref : ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
31
25
fetch-depth : 0 # Fetch all history for proper versioning
32
26
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
35
32
with :
36
- go-version : ' 1.24'
37
- cache : true
33
+ platforms : linux/amd64,linux/arm64
38
34
39
35
- name : Set VERSION environment variable
40
36
run : |
@@ -44,31 +40,36 @@ jobs:
44
40
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
45
41
fi
46
42
47
- - name : Build binary
43
+ - name : Build Linux ${{ matrix.arch }} binary
48
44
env :
49
- GOOS : ${{ matrix.goos }}
50
- GOARCH : ${{ matrix.goarch }}
45
+ GOARCH : ${{ matrix.arch }}
51
46
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"
56
54
57
- - name : Prepare binary for upload
55
+ - name : Generate SHA256 checksums
58
56
run : |
59
57
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"' _ {} \;
61
62
62
63
- name : Upload artifacts
63
64
uses : actions/upload-artifact@v4
64
65
with :
65
- name : cadvisor-${{ env.VERSION }} -${{ matrix.goos }}-${{ matrix.goarch }}
66
+ name : cadvisor-linux -${{ matrix.arch }}
66
67
path : |
67
- _output/cadvisor-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }} *
68
+ _output/cadvisor*
68
69
retention-days : 1
69
70
70
71
create-release :
71
- needs : build-and-release
72
+ needs : build-linux-binaries
72
73
runs-on : ubuntu-latest
73
74
permissions :
74
75
contents : write # Needed for creating GitHub releases
0 commit comments