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