Skip to content

Commit 313ad3c

Browse files
author
Alex
committed
Add ARM64 binary publishing support
- Add multi-arch build support (AMD64 + ARM64) - Use GitHub ARM64 runners (ubuntu-24.04-arm) - Create multi-arch Docker manifests - Build ARM64 packages (.rpm, .deb) - Parallel builds for both architectures - Zero breaking changes to AMD64 support Fixes #148
1 parent 68f0c23 commit 313ad3c

File tree

2 files changed

+107
-84
lines changed

2 files changed

+107
-84
lines changed

.github/.actionlint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
self-hosted-runner:
2+
labels:
3+
- ubuntu-24.04-arm

.github/workflows/build-and-release.yaml

Lines changed: 104 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ on:
6060
default: false
6161

6262
permissions:
63-
# Allow this workflow (and reusable callers) to create releases
6463
contents: write
64+
packages: write
6565

6666
env:
6767
BENV_IMAGE: ${{ vars.BENV_IMAGE || 'docker.io/otel/opentelemetry-network-build-tools' }}
@@ -74,31 +74,24 @@ env:
7474
DRY_RUN: ${{ inputs.dry_run && 'true' || 'false' }}
7575

7676
jobs:
77-
build-and-release:
78-
permissions:
79-
contents: write # required for creating releases
80-
name: Build and release
77+
compute-version:
78+
name: Compute version
8179
runs-on: ubuntu-24.04
80+
outputs:
81+
git_short_hash: ${{ steps.version.outputs.git_short_hash }}
82+
short_version_number: ${{ steps.version.outputs.short_version_number }}
83+
full_version_number: ${{ steps.version.outputs.full_version_number }}
84+
github_tag: ${{ steps.version.outputs.github_tag }}
8285
steps:
8386
- name: Checkout sources
8487
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
8588
with:
8689
ref: ${{ inputs.ref }}
8790
fetch-depth: 0
88-
submodules: false
89-
path: src
90-
- name: Checkout ext/ submodules
91-
run: |
92-
cd $GITHUB_WORKSPACE/src
93-
git submodule update --init --recursive ext/
9491
- name: Compute version numbers
92+
id: version
9593
run: |
96-
# sets environment variables for use in later steps.
97-
# see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
98-
99-
cd $GITHUB_WORKSPACE/src
10094
source ./version.sh
101-
10295
git_short_hash=$(git rev-parse --short=8 HEAD)
10396
short_version_number="${EBPF_NET_MAJOR_VERSION}.${EBPF_NET_MINOR_VERSION}"
10497
full_version_number="${EBPF_NET_MAJOR_VERSION}.${EBPF_NET_MINOR_VERSION}.${EBPF_NET_PATCH_VERSION}"
@@ -107,25 +100,34 @@ jobs:
107100
else
108101
github_tag=v${full_version_number}-${git_short_hash}
109102
fi
110-
111-
echo "git_short_hash=${git_short_hash}" >> "$GITHUB_ENV"
112-
echo "short_version_number=${short_version_number}" >> "$GITHUB_ENV"
113-
echo "full_version_number=${full_version_number}" >> "$GITHUB_ENV"
114-
echo "github_tag=${github_tag}" >> "$GITHUB_ENV"
115-
- name: Output build information
116-
run: |
117-
echo "github.workspace = ${{ github.workspace }}"
118-
echo "github.ref = ${{ github.ref }}"
119-
echo "release_type = ${RELEASE_TYPE}"
120-
echo "image_prefix = ${IMAGE_PREFIX}"
121-
echo "dry_run = ${DRY_RUN}"
122-
echo "git_short_hash = ${git_short_hash}"
123-
echo "short_version_number = ${short_version_number}"
124-
echo "full_version_number = ${full_version_number}"
125-
echo "github_tag = ${github_tag}"
126-
- name: Log-in to container registry
103+
echo "git_short_hash=${git_short_hash}" >> "$GITHUB_OUTPUT"
104+
echo "short_version_number=${short_version_number}" >> "$GITHUB_OUTPUT"
105+
echo "full_version_number=${full_version_number}" >> "$GITHUB_OUTPUT"
106+
echo "github_tag=${github_tag}" >> "$GITHUB_OUTPUT"
107+
108+
build-per-arch:
109+
name: Build ${{ matrix.arch }} artifacts
110+
needs: compute-version
111+
strategy:
112+
matrix:
113+
include:
114+
- arch: amd64
115+
runner: ubuntu-24.04
116+
- arch: arm64
117+
runner: ubuntu-24.04-arm
118+
runs-on: ${{ matrix.runner }}
119+
steps:
120+
- name: Checkout sources
121+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
122+
with:
123+
ref: ${{ inputs.ref }}
124+
fetch-depth: 0
125+
submodules: false
126+
path: src
127+
- name: Checkout ext/ submodules
127128
run: |
128-
docker login --username="$DOCKER_USERNAME" --password-stdin $DOCKER_REGISTRY <<< "$DOCKER_PASSWORD"
129+
cd $GITHUB_WORKSPACE/src
130+
git submodule update --init --recursive ext/
129131
- name: Fetch build environment
130132
run: |
131133
docker pull $BENV_IMAGE
@@ -135,10 +137,7 @@ jobs:
135137
sudo chown -R 1000:1000 $GITHUB_WORKSPACE/out
136138
- name: Build artifacts
137139
run: |
138-
# Start local registry for the build process
139140
docker run -d -p 5000:5000 --name registry docker.io/library/registry:2
140-
141-
# Build all containers and push to local registry
142141
docker run -t --rm \
143142
--mount "type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock" \
144143
--mount "type=bind,source=$GITHUB_WORKSPACE/src,destination=/home/user/src,readonly" \
@@ -148,12 +147,9 @@ jobs:
148147
--privileged \
149148
$BENV_IMAGE \
150149
./build.sh pipeline-docker-registry
151-
152-
# Pull images from local registry to make them available for docker tag/push
153150
docker pull localhost:5000/reducer
154151
docker pull localhost:5000/kernel-collector
155152
docker pull localhost:5000/cloud-collector
156-
# k8s-collector replaces watcher+relay
157153
docker pull localhost:5000/k8s-collector
158154
- name: Build packages
159155
run: |
@@ -164,66 +160,90 @@ jobs:
164160
--workdir /home/user/out \
165161
$BENV_IMAGE \
166162
cpack -G 'RPM;DEB'
167-
- name: Upload packages to GitHub Action artifacts
163+
- name: Log-in to container registry
164+
run: |
165+
docker login --username="$DOCKER_USERNAME" --password-stdin $DOCKER_REGISTRY <<< "$DOCKER_PASSWORD"
166+
- name: Tag and push arch-specific images
167+
run: |
168+
docker_registry=$(sed -e 's,^https://,,' -e 's,/*$,,' <<< $DOCKER_REGISTRY)
169+
images=(reducer kernel-collector cloud-collector k8s-collector)
170+
for image in ${images[@]}; do
171+
image_name="${IMAGE_PREFIX}${image}"
172+
image_path="${docker_registry}/${DOCKER_NAMESPACE}/${image_name}"
173+
docker tag localhost:5000/$image ${image_path}:${{ matrix.arch }}-${{ needs.compute-version.outputs.git_short_hash }}
174+
if [[ "${DRY_RUN}" == "false" ]]; then
175+
docker push ${image_path}:${{ matrix.arch }}-${{ needs.compute-version.outputs.git_short_hash }}
176+
fi
177+
done
178+
docker stop registry || true
179+
docker rm registry || true
180+
- name: Upload packages
168181
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
169182
with:
170-
name: packages
183+
name: packages-${{ matrix.arch }}
171184
path: |
172185
out/opentelemetry-ebpf-*.rpm
173186
out/opentelemetry-ebpf-*.deb
174-
- name: Upload packages to Release
175-
uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe
176-
if: ${{ env.DRY_RUN != 'true' }}
177-
with:
178-
tag_name: ${{ env.github_tag }}
179-
prerelease: ${{ env.RELEASE_TYPE != 'public' }}
180-
files: |
181-
out/opentelemetry-ebpf-*.rpm
182-
out/opentelemetry-ebpf-*.deb
183-
- name: Push to container registry
184-
run: |
185-
cd $GITHUB_WORKSPACE/src
186187
188+
create-manifests:
189+
name: Create multi-arch manifests
190+
needs: [compute-version, build-per-arch]
191+
runs-on: ubuntu-24.04
192+
if: ${{ inputs.dry_run != true }}
193+
steps:
194+
- name: Log-in to container registry
195+
run: |
196+
docker login --username="$DOCKER_USERNAME" --password-stdin $DOCKER_REGISTRY <<< "$DOCKER_PASSWORD"
197+
- name: Set up Docker Buildx
198+
uses: docker/setup-buildx-action@v3
199+
- name: Create and push multi-arch manifests
200+
run: |
201+
docker_registry=$(sed -e 's,^https://,,' -e 's,/*$,,' <<< $DOCKER_REGISTRY)
202+
git_short_hash="${{ needs.compute-version.outputs.git_short_hash }}"
203+
short_version="${{ needs.compute-version.outputs.short_version_number }}"
204+
full_version="${{ needs.compute-version.outputs.full_version_number }}"
205+
187206
if [[ "${RELEASE_TYPE}" == "public" ]]; then
188-
tags=(
189-
latest
190-
latest-v${short_version_number}
191-
v${full_version_number}
192-
)
207+
tags=(latest latest-v${short_version} v${full_version})
193208
else
194-
tags=(
195-
v${full_version_number}-${git_short_hash}
196-
)
209+
tags=(v${full_version}-${git_short_hash})
197210
fi
198-
211+
199212
if [[ "${{ inputs.additional_tag }}" != "" ]]; then
200213
tags=(${tags[@]} "${{ inputs.additional_tag }}")
201214
fi
202-
203-
images=(
204-
reducer
205-
kernel-collector
206-
cloud-collector
207-
k8s-collector
208-
)
209-
210-
# strip potential "https://" prefix and trailing slashes from docker registry
211-
docker_registry=$(sed -e 's,^https://,,' -e 's,/*$,,' <<< $DOCKER_REGISTRY)
212-
215+
216+
images=(reducer kernel-collector cloud-collector k8s-collector)
217+
213218
for image in ${images[@]}; do
214219
image_name="${IMAGE_PREFIX}${image}"
215220
image_path="${docker_registry}/${DOCKER_NAMESPACE}/${image_name}"
216-
221+
amd64_tag="${image_path}:amd64-${git_short_hash}"
222+
arm64_tag="${image_path}:arm64-${git_short_hash}"
223+
217224
for tag in ${tags[@]}; do
218-
docker tag localhost:5000/$image ${image_path}:${tag}
219-
if [[ "${DRY_RUN}" == "false" ]]; then
220-
docker push ${image_path}:${tag}
221-
fi
225+
docker buildx imagetools create --tag "${image_path}:${tag}" \
226+
"${amd64_tag}" \
227+
"${arm64_tag}"
228+
echo "Created multi-arch manifest: ${image_path}:${tag}"
222229
done
223230
done
224231
225-
# Clean up local registry
226-
docker stop registry || true
227-
docker rm registry || true
228-
229-
docker images --no-trunc
232+
upload-release:
233+
name: Upload release artifacts
234+
needs: [compute-version, build-per-arch]
235+
runs-on: ubuntu-24.04
236+
if: ${{ inputs.dry_run != true }}
237+
steps:
238+
- name: Download all packages
239+
uses: actions/download-artifact@v4
240+
with:
241+
pattern: packages-*
242+
merge-multiple: true
243+
path: packages
244+
- name: Upload packages to Release
245+
uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe
246+
with:
247+
tag_name: ${{ needs.compute-version.outputs.github_tag }}
248+
prerelease: ${{ env.RELEASE_TYPE != 'public' }}
249+
files: packages/*

0 commit comments

Comments
 (0)