Skip to content

Commit b824911

Browse files
author
Jan VL
committed
refactor(ci): split release workflow into x86_64 and ARM64 for faster builds
1 parent f65c504 commit b824911

File tree

3 files changed

+596
-0
lines changed

3 files changed

+596
-0
lines changed
Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
name: Release ARM64
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version tag (e.g., v0.80.3) - must match existing release'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
build-ubuntu-dynamic:
16+
name: Build Ubuntu 24.04 (dynamic) ARM64
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
library: [c, cpp]
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up QEMU for ARM64 emulation
26+
uses: docker/setup-qemu-action@v3
27+
with:
28+
platforms: linux/arm64
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Mark repo as safe for Git
34+
run: |
35+
docker run --rm \
36+
--platform linux/arm64 \
37+
-v $PWD:/workspace \
38+
ubuntu:24.04 \
39+
sh -c 'apt-get update && apt-get install -y git && git config --global --add safe.directory /workspace'
40+
41+
- name: Build ${{ matrix.library }} library in Ubuntu container
42+
run: |
43+
docker run --rm \
44+
--platform linux/arm64 \
45+
-v $PWD:/workspace \
46+
-w /workspace \
47+
ubuntu:24.04 \
48+
sh -c '
49+
apt-get update
50+
apt-get install -y \
51+
build-essential \
52+
clang-18 \
53+
cmake \
54+
git \
55+
protobuf-compiler \
56+
libprotobuf-dev \
57+
libabsl-dev \
58+
libssl-dev \
59+
pkg-config
60+
61+
git config --global --add safe.directory /workspace
62+
63+
cd /tmp
64+
git clone --depth 1 --branch v1.3.15 https://github.com/eclipse/paho.mqtt.c.git
65+
cd paho.mqtt.c
66+
cmake -Bbuild \
67+
-DCMAKE_BUILD_TYPE=Release \
68+
-DPAHO_WITH_SSL=ON \
69+
-DPAHO_BUILD_DOCUMENTATION=OFF \
70+
-DPAHO_BUILD_SAMPLES=OFF \
71+
-DPAHO_BUILD_STATIC=OFF
72+
cmake --build build -j$(nproc)
73+
cmake --install build
74+
75+
cd /workspace
76+
export CC=clang-18
77+
export CXX=clang++-18
78+
cmake -S . -B build-release \
79+
-DCMAKE_BUILD_TYPE=Release \
80+
-DBUILD_SHARED_LIBS=ON
81+
cmake --build build-release -j$(nproc) --target sparkplug_${{ matrix.library }}
82+
83+
VERSION="${{ inputs.version }}"
84+
VERSION="${VERSION#v}"
85+
ARCH="aarch64"
86+
PACKAGE_NAME="sparkplug-${{ matrix.library }}-${VERSION}-ubuntu24.04-${ARCH}"
87+
mkdir -p ${PACKAGE_NAME}/{lib,include}
88+
89+
cp build-release/src/libsparkplug_${{ matrix.library }}.so* ${PACKAGE_NAME}/lib/
90+
91+
if [ "${{ matrix.library }}" = "c" ]; then
92+
mkdir -p ${PACKAGE_NAME}/include/sparkplug
93+
cp include/sparkplug/sparkplug_c.h ${PACKAGE_NAME}/include/sparkplug/
94+
else
95+
cp -r include/sparkplug ${PACKAGE_NAME}/include/
96+
fi
97+
98+
printf "%s\n" \
99+
"# Sparkplug B ${{ matrix.library }} Library (Ubuntu 24.04 ARM64)" \
100+
"" \
101+
"Dynamic library build for Ubuntu 24.04 LTS on ARM64." \
102+
"" \
103+
"## Dependencies" \
104+
"" \
105+
"Install runtime dependencies:" \
106+
"\`\`\`bash" \
107+
"sudo apt-get install libprotobuf33 libabsl20230802 libpaho-mqtt-c1.3 libssl3" \
108+
"\`\`\`" \
109+
"" \
110+
"## Installation" \
111+
"" \
112+
"\`\`\`bash" \
113+
"sudo cp lib/* /usr/local/lib/" \
114+
"sudo cp -r include/* /usr/local/include/" \
115+
"sudo ldconfig" \
116+
"\`\`\`" \
117+
> ${PACKAGE_NAME}/README.md
118+
119+
tar czf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}
120+
'
121+
122+
- name: Upload artifacts
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: ubuntu-${{ matrix.library }}-aarch64
126+
path: '*.tar.gz'
127+
128+
build-alpine-static:
129+
name: Build Alpine Linux (static musl) ARM64
130+
runs-on: ubuntu-latest
131+
steps:
132+
- name: Checkout code
133+
uses: actions/checkout@v4
134+
135+
- name: Set up QEMU for ARM64 emulation
136+
uses: docker/setup-qemu-action@v3
137+
with:
138+
platforms: linux/arm64
139+
140+
- name: Set up Docker Buildx
141+
uses: docker/setup-buildx-action@v3
142+
143+
- name: Mark repo as safe for Git
144+
run: |
145+
docker run --rm \
146+
--platform linux/arm64 \
147+
-v $PWD:/workspace \
148+
alpine:latest \
149+
sh -c 'apk add --no-cache git && git config --global --add safe.directory /workspace'
150+
151+
- name: Build static musl bundle in Alpine container
152+
run: |
153+
docker run --rm \
154+
--platform linux/arm64 \
155+
-v $PWD:/workspace \
156+
-w /workspace \
157+
alpine:latest \
158+
sh -c '
159+
apk add --no-cache \
160+
build-base \
161+
cmake \
162+
git \
163+
bash \
164+
linux-headers \
165+
openssl-dev \
166+
openssl-libs-static \
167+
zlib-static \
168+
samurai \
169+
protobuf-dev \
170+
protoc
171+
172+
git config --global --add safe.directory /workspace
173+
174+
export VERSION="${{ inputs.version }}"
175+
export VERSION="${VERSION#v}"
176+
export ARCH="aarch64"
177+
bash ./scripts/build_static_musl.sh
178+
'
179+
180+
- name: Upload artifacts
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: alpine-static-c-aarch64
184+
path: 'build-static-musl/*.tar.gz'
185+
186+
build-fedora-dynamic:
187+
name: Build Fedora 42 (dynamic) ARM64
188+
runs-on: ubuntu-latest
189+
strategy:
190+
matrix:
191+
library: [c, cpp]
192+
steps:
193+
- name: Checkout code
194+
uses: actions/checkout@v4
195+
196+
- name: Set up QEMU for ARM64 emulation
197+
uses: docker/setup-qemu-action@v3
198+
with:
199+
platforms: linux/arm64
200+
201+
- name: Set up Docker Buildx
202+
uses: docker/setup-buildx-action@v3
203+
204+
- name: Mark repo as safe for Git
205+
run: |
206+
docker run --rm \
207+
--platform linux/arm64 \
208+
-v $PWD:/workspace \
209+
fedora:42 \
210+
sh -c 'dnf install -y git && git config --global --add safe.directory /workspace'
211+
212+
- name: Build ${{ matrix.library }} library in Fedora container
213+
run: |
214+
docker run --rm \
215+
--platform linux/arm64 \
216+
-v $PWD:/workspace \
217+
-w /workspace \
218+
fedora:42 \
219+
sh -c '
220+
dnf install -y \
221+
gcc-c++ \
222+
clang \
223+
cmake \
224+
ninja-build \
225+
git \
226+
protobuf-devel \
227+
abseil-cpp-devel \
228+
paho-c-devel \
229+
openssl-devel
230+
231+
git config --global --add safe.directory /workspace
232+
233+
export CC=clang
234+
export CXX=clang++
235+
236+
cmake -S . -B build-release \
237+
-GNinja \
238+
-DCMAKE_BUILD_TYPE=Release \
239+
-DBUILD_SHARED_LIBS=ON
240+
cmake --build build-release -j$(nproc) --target sparkplug_${{ matrix.library }}
241+
242+
VERSION="${{ inputs.version }}"
243+
VERSION="${VERSION#v}"
244+
ARCH="aarch64"
245+
PACKAGE_NAME="sparkplug-${{ matrix.library }}-${VERSION}-fedora42-${ARCH}"
246+
mkdir -p ${PACKAGE_NAME}/{lib,include}
247+
248+
cp build-release/src/libsparkplug_${{ matrix.library }}.so* ${PACKAGE_NAME}/lib/
249+
250+
if [ "${{ matrix.library }}" = "c" ]; then
251+
mkdir -p ${PACKAGE_NAME}/include/sparkplug
252+
cp include/sparkplug/sparkplug_c.h ${PACKAGE_NAME}/include/sparkplug/
253+
else
254+
cp -r include/sparkplug ${PACKAGE_NAME}/include/
255+
fi
256+
257+
printf "%s\n" \
258+
"# Sparkplug B ${{ matrix.library }} Library (Fedora 42 ARM64)" \
259+
"" \
260+
"Dynamic library build for Fedora 42+ on ARM64." \
261+
"" \
262+
"## Dependencies" \
263+
"" \
264+
"\`\`\`bash" \
265+
"sudo dnf install protobuf abseil-cpp paho-c openssl" \
266+
"\`\`\`" \
267+
"" \
268+
"## Installation" \
269+
"" \
270+
"\`\`\`bash" \
271+
"sudo cp lib/* /usr/local/lib64/" \
272+
"sudo cp -r include/* /usr/local/include/" \
273+
"sudo ldconfig" \
274+
"\`\`\`" \
275+
> ${PACKAGE_NAME}/README.md
276+
277+
tar czf ${PACKAGE_NAME}.tar.gz ${PACKAGE_NAME}
278+
'
279+
280+
- name: Upload artifacts
281+
uses: actions/upload-artifact@v4
282+
with:
283+
name: fedora-${{ matrix.library }}-aarch64
284+
path: '*.tar.gz'
285+
286+
upload-to-release:
287+
name: Upload ARM64 assets to existing release
288+
runs-on: ubuntu-latest
289+
needs: [build-ubuntu-dynamic, build-alpine-static, build-fedora-dynamic]
290+
steps:
291+
- name: Download all artifacts
292+
uses: actions/download-artifact@v4
293+
with:
294+
path: artifacts
295+
296+
- name: Display structure of downloaded files
297+
run: ls -R artifacts
298+
299+
- name: Prepare release assets
300+
run: |
301+
mkdir -p release-assets
302+
find artifacts -name '*.tar.gz' -exec cp {} release-assets/ \;
303+
ls -lh release-assets/
304+
305+
- name: Upload to existing release
306+
uses: softprops/action-gh-release@v2
307+
with:
308+
tag_name: ${{ inputs.version }}
309+
files: release-assets/*.tar.gz

0 commit comments

Comments
 (0)