forked from smartmontools/smartmontools
-
Notifications
You must be signed in to change notification settings - Fork 0
358 lines (344 loc) · 16.5 KB
/
build.yml
File metadata and controls
358 lines (344 loc) · 16.5 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: Build smartmontools (non-release)
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
# job to create tar.gz tarball, used by other builders
make-src-tgz:
runs-on: ubuntu-latest
name: Create smartmontools dist
outputs:
SOURCE_DATE_EPOCH: ${{ steps.set-env.outputs.SMARTMONTOOLS_GIT_REV_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ steps.set-env.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ steps.set-env.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
artficact-id: ${{ steps.artifact-upload-step.outputs.artifact-id }}
steps:
- uses: actions/checkout@v4
with:
# Provide at least the commit log since last release for 'getversion.sh'.
# 'git clone --shallow-since=2025-04-29' would be sufficient but this is
# not supported by 'actions/checkout@v4'.
fetch-depth: 800
# Include (future) release tags for 'getversion.sh'
fetch-tags: true
- name: Setting environment variables
id: set-env
run: |
src/getversion.sh -g >> $GITHUB_ENV
cat $GITHUB_ENV | tee $GITHUB_OUTPUT
- name: Creating src.tar.gz
run: |
./autogen.sh --force &&
mkdir build && cd build &&
../configure SOURCE_DATE_EPOCH=${SMARTMONTOOLS_GIT_REV_EPOCH} &&
make dist && tar -tvzf "smartmontools-${SMARTMONTOOLS_PKG_VER}.tar.gz" &&
mkdir artifacts &&
echo ${SMARTMONTOOLS_GIT_REV_EPOCH} > artifacts/SOURCE_DATE_EPOCH &&
touch -d @${SMARTMONTOOLS_GIT_REV_EPOCH} artifacts/SOURCE_DATE_EPOCH &&
mv smartmontools-${SMARTMONTOOLS_PKG_VER}.tar.gz artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz
- name: Upload artifacts
id: artifact-upload-step
uses: actions/upload-artifact@v4
with:
name: artifacts
path: build/artifacts/
retention-days: 1
compile-linux-static-x86_64:
name: Creating static x86_64 linux binaries
needs: make-src-tgz
runs-on: ubuntu-latest
env:
SOURCE_DATE_EPOCH: ${{ needs.make-src-tgz.outputs.SOURCE_DATE_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
steps:
- uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.make-src-tgz.outputs.artficact-id }}
- name: build
run: |
tar -xvf artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz &&
cd smartmontools-${SMARTMONTOOLS_PKG_VER} && mkdir build && cd build &&
../configure --with-build-info='(GHA Build)' --enable-static-link \
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check &&
mkdir -p ${GITHUB_WORKSPACE}/artifacts &&
make bin-dist bin_distfile="${GITHUB_WORKSPACE}/artifacts/smartmontools-linux-x86_64-static-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux_static_x86_64
path: artifacts/smartmontools-linux-x86_64-static-${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}.tar.gz
retention-days: 1
compile-linux-static-i386:
name: Creating static i386 linux binaries
needs: make-src-tgz
runs-on: ubuntu-latest
env:
SOURCE_DATE_EPOCH: ${{ needs.make-src-tgz.outputs.SOURCE_DATE_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
steps:
- uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.make-src-tgz.outputs.artficact-id }}
- name: install m32 dependencies
run: sudo apt-get update && sudo apt-get install gcc-multilib g++-multilib
- name: build
# 'config.guess' from automake 1.16 misdetects 'host=x86_64-pc-linux-gnux32' (x86_64 with x32 ABI).
# With 'setarch i686 ...' it correctly detects 'host=i686-pc-linux-gnu'.
# TODO: Remove this workaround if 'ubuntu-latest' provides automake >= 1.17.
run: |
tar -xvf artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz &&
cd smartmontools-${SMARTMONTOOLS_PKG_VER} && mkdir build && cd build &&
setarch i686 ../configure --with-build-info='(GHA Build)' --enable-static-link \
CC="gcc -m32" CXX="g++ -m32" SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check &&
mkdir -p ${GITHUB_WORKSPACE}/artifacts &&
make bin-dist bin_distfile="${GITHUB_WORKSPACE}/artifacts/smartmontools-linux-i386-static-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux_static_i386
path: artifacts/smartmontools-linux-i386-static-${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}.tar.gz
retention-days: 1
compile-darwin:
name: Creating Darwin image
needs: make-src-tgz
runs-on: ubuntu-latest
# we are using clang/osxcross to build it, so running in container
# see smartmontools/docker-build for the source
container:
image: ghcr.io/smartmontools/docker-build:master
env:
SOURCE_DATE_EPOCH: ${{ needs.make-src-tgz.outputs.SOURCE_DATE_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
steps:
- uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.make-src-tgz.outputs.artficact-id }}
- name: build
run: |
export PATH=/usr/osxcross/bin/:$PATH &&
export LD_LIBRARY_PATH=/usr/osxcross/lib &&
tar -xvf artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz &&
cd smartmontools-${SMARTMONTOOLS_PKG_VER} &&
mkdir build && cd build &&
../configure --build=$(../config.guess) --host=x86_64-apple-darwin20.4 \
--sysconfdir=/private/etc --with-build-info='(GHA Build)' \
'CC=o64-clang' 'CXX=o64-clang++' 'CFLAGS=-arch arm64 -arch x86_64' \
'CXXFLAGS=-arch arm64 -arch x86_64 -stdlib=libc++' \
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check &&
make pkg_darwin=smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.pkg dmg_darwin=smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.dmg install-darwin &&
mkdir -p inst ${GITHUB_WORKSPACE}/artifacts &&
mv ./src/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.dmg ${GITHUB_WORKSPACE}/artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: darwin
path: artifacts/smartmontools-${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}.dmg
retention-days: 1
compile-freebsd:
name: Creating FreeBSD binaries
needs: make-src-tgz
runs-on: ubuntu-latest
# FreeBSD cross-compilation. We need to check, very possible it would be
# faster to do everything in normal runner, by installing things locally
# and using cache
container:
image: ghcr.io/smartmontools/docker-build:master
env:
SOURCE_DATE_EPOCH: ${{ needs.make-src-tgz.outputs.SOURCE_DATE_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
steps:
- uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.make-src-tgz.outputs.artficact-id }}
- name: FreeBSD 14 build
run: |
tar -xvf artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz &&
cd smartmontools-${SMARTMONTOOLS_PKG_VER} &&
mkdir build && cd build &&
export TARGET="-target x86_64-unknown-freebsd14 --sysroot=/opt/cross-freebsd-14/" &&
TARGET="$TARGET -isystem /opt/cross-freebsd-14/usr/include/c++/v1" &&
../configure --host=x86_64-pc-freebsd14 --with-build-info='(GHA Build)' --enable-static-link \
CC="clang $TARGET" CXX="clang++ $TARGET" SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check &&
mkdir -p ${GITHUB_WORKSPACE}/artifacts &&
make bin-dist bin_distfile="${GITHUB_WORKSPACE}/artifacts/smartmontools-freebsd-14-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: freebsd14
path: artifacts/smartmontools-freebsd-14-${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}.tar.gz
retention-days: 1
- name: cleanup
run: rm -rf smartmontools-${SMARTMONTOOLS_PKG_VER}
- name: FreeBSD 13 build
run: |
tar -xvf artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz &&
cd smartmontools-${SMARTMONTOOLS_PKG_VER} &&
mkdir build && cd build &&
export TARGET="-target x86_64-unknown-freebsd13 --sysroot=/opt/cross-freebsd-13/" &&
TARGET="$TARGET -isystem /opt/cross-freebsd-13/usr/include/c++/v1" &&
../configure --host=x86_64-pc-freebsd13 --with-build-info='(GHA Build)' --enable-static-link \
CC="clang $TARGET" CXX="clang++ $TARGET" SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check &&
mkdir -p ${GITHUB_WORKSPACE}/artifacts &&
make bin-dist bin_distfile="${GITHUB_WORKSPACE}/artifacts/smartmontools-freebsd-13-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: freebsd13
path: artifacts/smartmontools-freebsd-13-${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}.tar.gz
retention-days: 1
compile-windows:
name: Creating Windows binary
needs: make-src-tgz
runs-on: ubuntu-latest
# windows cross-compilation, also running using our build container
# based on Debian 12. Probably could be migrated to normal ubuntu runner
# need to test this
container:
image: ghcr.io/smartmontools/docker-build:master
env:
SOURCE_DATE_EPOCH: ${{ needs.make-src-tgz.outputs.SOURCE_DATE_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
steps:
- uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.make-src-tgz.outputs.artficact-id }}
- name: Windows build
run: |
tar -xvf artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz &&
cd smartmontools-${SMARTMONTOOLS_PKG_VER} &&
mkdir build && cd build &&
../configure --build=$(../config.guess) --host=i686-w64-mingw32 \
--with-build-info='(GHA Build)' --enable-static-link \
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check && make distdir-win32 &&
cd .. && mkdir build64 && cd build64 &&
../configure --build=$(../config.guess) --host=x86_64-w64-mingw32 \
--with-build-info='(GHA Build)' --enable-static-link \
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check && make distdir-win32 &&
cd ../build &&
dest="smartmontools-win32-setup-${SMARTMONTOOLS_GIT_VER_FNAME}.exe" && \
make builddir_win64=../../build64/src distinst_win32="$dest" installer-win32 &&
mkdir -p inst ${GITHUB_WORKSPACE}/artifacts && make DESTDIR="$(pwd)/inst" install &&
mv ./src/smartmontools-win32-setup-${SMARTMONTOOLS_GIT_VER_FNAME}.exe ${GITHUB_WORKSPACE}/artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows
path: artifacts/smartmontools-win32-setup-${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}.exe
retention-days: 1
compile-cygwin:
name: Creating Cygwin binaries
needs: make-src-tgz
runs-on: ubuntu-latest
# Cross build on Fedora is faster than the native build done by 'cygwin.yml'.
# The recipes below are partly borrowed from Cygwin's own CI build
container: fedora:latest
env:
SOURCE_DATE_EPOCH: ${{ needs.make-src-tgz.outputs.SOURCE_DATE_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
steps:
- name: Install build tools
run: |
dnf install -y make
- name: Enable 'dnf copr'
run: |
dnf install -y dnf-plugins-core
- name: Install cross-cygwin toolchain
run: |
dnf copr enable -y yselkowitz/cygwin
dnf install -y cygwin64-gcc-c++
- uses: actions/download-artifact@v4
with:
artifact-ids: ${{ needs.make-src-tgz.outputs.artficact-id }}
- name: Cygwin build
run: |
tar -xvf artifacts/smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz &&
cd smartmontools-${SMARTMONTOOLS_PKG_VER} && mkdir build && cd build &&
../configure --build=$(../config.guess) --host=x86_64-pc-cygwin \
--with-build-info='(GHA Build)' SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} &&
make -j && make check &&
mkdir -p ${GITHUB_WORKSPACE}/artifacts &&
make bin-dist bin_distfile="${GITHUB_WORKSPACE}/artifacts/smartmontools-cygwin-${SMARTMONTOOLS_GIT_VER_FNAME}.tar.gz"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: cygwin
path: artifacts/smartmontools-cygwin-${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}.tar.gz
retention-days: 1
publish-artifacts:
# finally we are publishing all artifacts to the smartmontools/smartmontools-builds
# git repository on releases page
# Publishing should be performed only from main branch of upstream repository
if: ${{ github.repository == 'smartmontools/smartmontools' && github.ref == 'refs/heads/main' }}
env:
SOURCE_DATE_EPOCH: ${{ needs.make-src-tgz.outputs.SOURCE_DATE_EPOCH }}
SMARTMONTOOLS_PKG_VER: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_PKG_VER }}
SMARTMONTOOLS_GIT_VER_FNAME: ${{ needs.make-src-tgz.outputs.SMARTMONTOOLS_GIT_VER_FNAME }}
name: publish-artifacts
# we need to check how to make it conditional, to not fail if any of these
# failed
needs:
- make-src-tgz
- compile-linux-static-x86_64
- compile-linux-static-i386
- compile-darwin
- compile-freebsd
- compile-windows
- compile-cygwin
runs-on: ubuntu-latest
# we are using environment to store APP_ID/PRIVATE_KEY
environment:
name: mainbranch
url: https://github.com/smartmontools/smartmontools-builds
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
path: artifacts
- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: smartmontools
repositories: smartmontools-builds
- name: gh create delete (clenup)
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
# cleanup release with the same name
run: |
gh release delete "smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}" --repo smartmontools/smartmontools-builds \
--yes --cleanup-tag || true
- name: gh create release
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh release create "smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}" \
artifacts/* \
--repo smartmontools/smartmontools-builds \
--notes "Smartmontools CI build: [smartmontools-${SMARTMONTOOLS_GIT_VER_FNAME}](https://github.com/smartmontools/smartmontools/tree/${GITHUB_SHA})" \
--prerelease
- name: Clean old builds
# Leave only last 50 builds and delete everything else
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh -R smartmontools/smartmontools-builds release list \
-L 100 --json tagName -q '.[50:][]|.tagName' | \
xargs -n1 --no-run-if-empty \
gh -R smartmontools/smartmontools-builds release delete --cleanup-tag --yes