Skip to content

Commit

Permalink
ci: build arm64 images on arm64 hosted runners (#4936)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian authored Jan 17, 2025
1 parent aeecbd4 commit 6b9c900
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 67 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/build-arm64-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ env:
jobs:
build:
name: Build arm64
runs-on: ubuntu-24.04
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- uses: actions/setup-go@v5
with:
Expand Down Expand Up @@ -70,7 +67,6 @@ jobs:
- name: Build kubectl and CNI plugins from source
env:
CGO_ENABLED: "0"
GOARCH: arm64
GO_INSTALL: "go install -v -mod=mod -trimpath"
run: |
cat trivy-result.json
Expand All @@ -79,7 +75,7 @@ jobs:
cni_plugins_build_flags="-ldflags '-extldflags -static -X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=$cni_plugins_version'"
jq -r '.Results[] | select((.Type=="gobinary") and (.Vulnerabilities!=null)) | .Target' trivy-result.json | while read f; do
bin=`basename $f`
go_bin_dir=`go env GOPATH`/bin/linux_arm64
go_bin_dir=`go env GOPATH`/bin
case $bin in
loopback|macvlan)
echo "Building $bin@$cni_plugins_version from source..."
Expand Down
72 changes: 11 additions & 61 deletions .github/workflows/build-kube-ovn-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ on:
- cron: "20 19 * * *"

jobs:
build-amd64:
build:
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
branch:
- master
- release-1.13
- release-1.12
- release-1.11
- release-1.9
- release-1.12-mc
name: Build AMD64
runs-on: ubuntu-24.04
name: Build
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
steps:
- uses: actions/checkout@v4
if: (github.event.inputs.branch || matrix.branch) == matrix.branch
Expand All @@ -53,67 +56,15 @@ jobs:
GO_VERSION: ${{ steps.setup-go.outputs.go-version }}
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
run: |
make base-amd64
make base-tar-amd64
make base-${{ matrix.arch }}
make base-tar-${{ matrix.arch }}
- name: Upload image to artifact
if: (github.event.inputs.branch || matrix.branch) == matrix.branch
uses: actions/upload-artifact@v4
with:
name: image-amd64-${{ matrix.branch }}
path: image-amd64.tar
retention-days: 7

build-arm64:
strategy:
fail-fast: false
matrix:
branch:
- master
- release-1.13
- release-1.12
- release-1.11
- release-1.9
- release-1.12-mc
name: Build ARM64
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
if: (github.event.inputs.branch || matrix.branch) == matrix.branch
with:
ref: ${{ matrix.branch }}

- uses: docker/setup-buildx-action@v3
if: (github.event.inputs.branch || matrix.branch) == matrix.branch

- uses: docker/setup-qemu-action@v3
if: (github.event.inputs.branch || matrix.branch) == matrix.branch
with:
platforms: arm64

- uses: actions/setup-go@v5
if: (github.event.inputs.branch || matrix.branch) == matrix.branch
id: setup-go
with:
go-version-file: go.mod
check-latest: true
cache: false

- name: Build
if: (github.event.inputs.branch || matrix.branch) == matrix.branch
env:
GO_VERSION: ${{ steps.setup-go.outputs.go-version }}
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
run: |
make base-arm64 || make base-arm64
make base-tar-arm64
- name: Upload image to artifact
if: (github.event.inputs.branch || matrix.branch) == matrix.branch
uses: actions/upload-artifact@v4
with:
name: image-arm64-${{ matrix.branch }}
path: image-arm64.tar
name: image-${{ matrix.arch }}-${{ matrix.branch }}
path: image-${{ matrix.arch }}.tar
retention-days: 7

push:
Expand All @@ -128,8 +79,7 @@ jobs:
- release-1.9
- release-1.12-mc
needs:
- build-arm64
- build-amd64
- build
name: push
runs-on: ubuntu-24.04
steps:
Expand Down

0 comments on commit 6b9c900

Please sign in to comment.