Skip to content

Commit

Permalink
Add GitHub Actions to multi-arch builds
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <[email protected]>
  • Loading branch information
kakkoyun committed Nov 7, 2023
1 parent b169e83 commit a0e46d0
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build

on:
push:
branches:
- main
- master
- release-*
pull_request:
branches:
- main
- master
- release-*
merge_group:
branches:
- main
- master

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

env:
QEMU_VERSION: 7.0.0-7

jobs:
build-multi-arch:
name: Build for ${{ matrix.arch }}
runs-on: ubuntu-latest
# Run steps on a matrix of 2 arch.
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
steps:
- uses: actions/[email protected]

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build the builder image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.builder
push: false
load: true
platforms: linux/${{ matrix.arch }}
tags: perf-map-agent-builder:latest

# - name: "Setup QEMU ${{ matrix.arch }}"
# run: |
# # Register QEMU
# docker run --rm --privileged "docker.io/multiarch/qemu-user-static:${QEMU_VERSION}" --reset -p yes

- name: "Run Builder ${{ matrix.arch }}"
run: |
# Run platform specific based builder image. Run it as a daemon in the background.
# Sleep the container for 1 day so that it keeps running until
# other steps are completed and the steps below can use the same container.
docker run \
--name=builder \
--detach \
--platform 'linux/${{ matrix.arch }}' \
--volume /home/runner/work:/home/runner/work \
--workdir "${PWD}" \
docker.io/library/perf-map-agent-builder:latest \
bash -c 'uname -m && sleep 1d'
- name: "Build ${{ matrix.arch }}"
shell: docker exec builder bash -e {0}
run: |
cmake .
make
- name: Upload generated artifacts
uses: actions/[email protected]
with:
name: perf-map-agent-${{ matrix.arch }}
if-no-files-found: error
path: out/
7 changes: 7 additions & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:22-slim-bookworm

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
&& rm -rf /var/lib/apt/lists/*

0 comments on commit a0e46d0

Please sign in to comment.