feat: Build for both x86_64 and aarch64 platforms.

This commit is contained in:
Peter Johanson 2022-01-27 14:51:19 -05:00 committed by Pete Johanson
parent edb0828240
commit 86a7d2fd65
2 changed files with 54 additions and 15 deletions

View File

@ -146,6 +146,7 @@ jobs:
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
target: dev-generic target: dev-generic
platforms: linux/amd64,linux/arm64
build-args: | build-args: |
ZEPHYR_VERSION=${{ env.zephyr-version }} ZEPHYR_VERSION=${{ env.zephyr-version }}
no-cache: ${{ env.no-cache == 'true' }} no-cache: ${{ env.no-cache == 'true' }}
@ -162,6 +163,7 @@ jobs:
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
target: dev-generic target: dev-generic
platforms: linux/amd64,linux/arm64
build-args: | build-args: |
ZEPHYR_VERSION=${{ env.zephyr-version }} ZEPHYR_VERSION=${{ env.zephyr-version }}
tags: | tags: |
@ -431,14 +433,51 @@ jobs:
- name: Stop container - name: Stop container
shell: bash shell: bash
run: docker stop candidate run: docker stop candidate
- name: Push candidate images to the registry - name: Build and push 'build' candidate image (x86_64 and arm64)
if: ${{ steps.docker-hub-login.outcome == 'success' }} uses: docker/build-push-action@v2
shell: bash with:
run: | target: build
docker image push ${{ steps.paths.outputs.build-candidate }} platforms: linux/amd64,linux/arm64
docker image push ${{ steps.paths.outputs.build-branch }} build-args: |
docker image push ${{ steps.paths.outputs.dev-candidate }} ${{ steps.build-args.outputs.list }}
docker image push ${{ steps.paths.outputs.dev-branch }} labels: |
${{ steps.labels.outputs.list }}
tags: |
${{ steps.paths.outputs.build-candidate }}
${{ steps.paths.outputs.build-branch }}
cache-from: |
type=local,src=${{ steps.paths.outputs.dev-generic }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-candidate) }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-branch) }}
${{ (env.no-cache == 'false') && (steps.paths.outputs.build-base != '') && format('type=registry,ref={0}', steps.paths.outputs.build-base) || '' }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-major-minor-branch) }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-branch-upstream) }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-major-minor-branch-upstream) }}
cache-to: type=inline
push: true
- name: Build and push 'dev' candidate image (x86_64 + arm64)
uses: docker/build-push-action@v2
with:
target: dev
platforms: linux/amd64,linux/arm64
build-args: |
${{ steps.build-args.outputs.list }}
labels: |
${{ steps.labels.outputs.list }}
tags: |
${{ steps.paths.outputs.dev-candidate }}
${{ steps.paths.outputs.dev-branch }}
cache-from: |
type=registry,ref=${{ steps.paths.outputs.build-candidate }}
type=local,src=${{ steps.paths.outputs.dev-generic }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-candidate) }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-branch) }}
${{ (env.no-cache == 'false') && (steps.paths.outputs.dev-base != '') && format('type=registry,ref={0}', steps.paths.outputs.dev-base) || '' }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-major-minor-branch) }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-branch-upstream) }}
${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-major-minor-branch-upstream) }}
cache-to: type=inline
push: true
release-trigger: release-trigger:
if: ${{ startsWith(github.ref, 'refs/tags') }} if: ${{ startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -8,11 +8,12 @@ ARG ZEPHYR_VERSION
ENV ZEPHYR_VERSION=${ZEPHYR_VERSION} ENV ZEPHYR_VERSION=${ZEPHYR_VERSION}
RUN \ RUN \
apt-get -y update \ apt-get -y update \
&& if [ "$(uname -m)" = "x86_64" ]; then gcc_multilib="gcc-multilib"; else gcc_multilib=""; fi \
&& apt-get -y install --no-install-recommends \ && apt-get -y install --no-install-recommends \
ccache \ ccache \
file \ file \
gcc \ gcc \
gcc-multilib \ "${gcc_multilib}" \
git \ git \
gperf \ gperf \
make \ make \
@ -48,7 +49,6 @@ RUN \
&& apt-get -y update \ && apt-get -y update \
&& apt-get -y install --no-install-recommends \ && apt-get -y install --no-install-recommends \
clang-format \ clang-format \
g++-multilib \
gdb \ gdb \
gpg \ gpg \
gpg-agent \ gpg-agent \
@ -86,16 +86,16 @@ FROM common AS build
ARG ARCHITECTURE ARG ARCHITECTURE
ARG ZEPHYR_SDK_VERSION ARG ZEPHYR_SDK_VERSION
ARG ZEPHYR_SDK_SETUP_FILENAME=zephyr-toolchain-${ARCHITECTURE}-${ZEPHYR_SDK_VERSION}-linux-x86_64-setup.run
ARG ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-${ZEPHYR_SDK_VERSION} ARG ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-${ZEPHYR_SDK_VERSION}
RUN \ RUN \
apt-get -y update \ export sdk_file_name="zephyr-toolchain-${ARCHITECTURE}-${ZEPHYR_SDK_VERSION}-linux-$(uname -m)-setup.run" \
&& apt-get -y update \
&& apt-get -y install --no-install-recommends \ && apt-get -y install --no-install-recommends \
wget \ wget \
xz-utils \ xz-utils \
&& wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${ZEPHYR_SDK_SETUP_FILENAME}" \ && wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${sdk_file_name}" \
&& sh ${ZEPHYR_SDK_SETUP_FILENAME} --quiet -- -d ${ZEPHYR_SDK_INSTALL_DIR} \ && sh ${sdk_file_name} --quiet -- -d ${ZEPHYR_SDK_INSTALL_DIR} \
&& rm ${ZEPHYR_SDK_SETUP_FILENAME} \ && rm ${sdk_file_name} \
&& apt-get remove -y --purge \ && apt-get remove -y --purge \
wget \ wget \
xz-utils \ xz-utils \