-
Notifications
You must be signed in to change notification settings - Fork 0
501 lines (428 loc) · 15.5 KB
/
build.yml
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
name: Build and Upload
on:
#schedule:
# - cron: "0 0 * * *"
# @TODO when v6 is released this should be uncommented
push:
#branches-ignore:
# - 'master'
# @TODO when v6 is released this should be uncommented
pull_request:
release:
types: [published]
workflow_dispatch:
env:
#CORE_HASH:
#WEB_HASH:
#FTL_HASH:
CORE_BRANCH: development-v6
WEB_BRANCH: development-v6
FTL_BRANCH: development-v6
# @TODO when v6 is released *_HASH should be set to release commit hashes and *_BRANCH to release branches
jobs:
globals:
concurrency: globals-${{ github.ref_name || github.run_id }}
runs-on: ubuntu-latest
if: ${{ !contains(github.head_ref, 'gh-pages') }}
outputs:
VERSION: ${{ steps.globals.outputs.VERSION }}
CORE_REF: ${{ steps.globals.outputs.CORE_REF }}
WEB_REF: ${{ steps.globals.outputs.WEB_REF }}
FTL_REF: ${{ steps.globals.outputs.FTL_REF }}
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Set outputs
id: globals
run: bash ./scripts/globals.sh
build-core:
concurrency: build-core-${{ github.ref_name || github.run_id }}
needs: [globals]
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.OUTPUT }}
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Checkout pi-hole/pi-hole repository
uses: actions/checkout@v4
with:
repository: pi-hole/pi-hole
ref: ${{ needs.globals.outputs.CORE_REF }}
path: ./stage
- name: Cache result
id: cache
uses: ./.github/actions/cache
with:
key_prefix: core-
patches_prefix: core
- name: Apply patches
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/patch
with:
patches_prefix: core
- name: Save repository version infos
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/version
- name: Remove .git directory
run: rm -fr ./stage/.git
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: core
path: ./stage/*
retention-days: 1
build-web:
concurrency: build-web-${{ github.ref_name || github.run_id }}
needs: [globals]
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.OUTPUT }}
steps:
- name: Checkout own repository
uses: actions/checkout@v4
- name: Checkout pi-hole/web repository
uses: actions/checkout@v4
with:
repository: pi-hole/web
ref: ${{ needs.globals.outputs.WEB_REF }}
path: ./stage
- name: Cache result
id: cache
uses: ./.github/actions/cache
with:
key_prefix: web-
patches_prefix: web
- name: Apply patches
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/patch
with:
patches_prefix: web
- name: Save repository version infos
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/version
- name: Remove .git directory
run: rm -fr ./stage/.git
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: web
path: ./stage/*
retention-days: 1
build-binary:
concurrency: build-binary-${{ github.ref_name || github.run_id }}-${{ matrix.arch }}
needs: [globals]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allow-failure }}
outputs:
VERSION: ${{ steps.version.outputs.OUTPUT }}
strategy:
fail-fast: false
matrix:
include:
# - arch: aarch64
# platform: linux/aarch64
# allow-failure: false
# - arch: armv5
# platform: linux/arm/v5 # EOS by Entware team
# allow-failure: true
- arch: armv7
platform: linux/arm/v7
allow-failure: false
# - arch: mipsel
# platform: linux/mipsel # Not supported by Pi-hole
# allow-failure: true
# - arch: mips
# platform: linux/mips # Not supported by Pi-hole
# allow-failure: true
# - arch: amd64
# platform: linux/amd64
# allow-failure: false
# - arch: 386
# platform: linux/386 # EOS by Entware team
# allow-failure: false
steps:
- name: Fail this job
if: ${{ matrix.allow-failure && github.ref_name != 'master' && !startsWith(github.ref, 'refs/tags/') }}
run: exit 1
- name: Checkout own repository
uses: actions/checkout@v4
- name: Checkout pi-hole/FTL repository
uses: actions/checkout@v4
with:
repository: pi-hole/FTL
ref: ${{ needs.globals.outputs.FTL_REF }}
path: ./stage
- name: Cache result
id: cache
uses: ./.github/actions/cache
with:
key_prefix: binary-${{ matrix.arch }}-
patches_prefix: FTL
files: |
./stage/pihole-FTL
./stage/.version
- name: Apply patches
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/patch
with:
patches_prefix: FTL
- name: Save repository version infos
if: steps.cache.outputs.cache-hit != 'true'
uses: ./.github/actions/version
- name: Fetch pi-hole/FTL repository infos
if: steps.cache.outputs.cache-hit != 'true'
id: version_infos
working-directory: ./stage
run: |
echo "GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
echo "GIT_TAG=$(git describe --tags --always 2> /dev/null)" >> $GITHUB_OUTPUT
echo "GIT_HASH=$(git rev-parse --short=8 HEAD)" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v3
- name: Build and test FTL
if: steps.cache.outputs.cache-hit != 'true'
uses: docker/build-push-action@v5
with:
platforms: ${{ matrix.platform }}
pull: true
push: false
context: ./stage
target: result
file: ./stage/.github/Dockerfile
outputs: |
type=tar,dest=stage/build.tar
build-args: |
"CI_ARCH=${{ matrix.platform }}"
"GIT_BRANCH=${{ steps.version_infos.outputs.GIT_BRANCH }}"
"GIT_TAG=${{ steps.version_infos.outputs.GIT_TAG }}"
- name: Extract FTL binary and generate checksum file
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ./stage
run: |
tar -xf ./build.tar pihole-FTL
sha1sum pihole-FTL > pihole-FTL.sha1
- name: Remove .git directory
run: rm -fr ./stage/.git
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.arch }}
path: |
./stage/pihole-FTL
./stage/.version
retention-days: 1
build-package:
concurrency: build-package-${{ github.ref_name || github.run_id }}-${{ matrix.arch }}
needs: [globals, build-core, build-web, build-binary]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allow-failure }}
strategy:
fail-fast: false
matrix:
include:
#- arch: aarch64
# entware_arch: aarch64-3.10
# allow-failure: false
#- arch: armv5
# entware_arch: armv5-3.2 # EOS by Entware team
# allow-failure: true
#- arch: armv7
# entware_arch: armv7-2.6 # EOS by Entware team
# allow-failure: true
- arch: armv7
entware_arch: armv7-3.2
allow-failure: false
#- arch: mipsel
# entware_arch: mipselsf-3.4 # Not supported by Pi-hole
# allow-failure: true
#- arch: mips
# entware_arch: mipssf-3.4 # Not supported by Pi-hole
# allow-failure: true
#- arch: amd64
# entware_arch: x64-3.2
# allow-failure: false
#- arch: 386
# entware_arch: x86-2.6 # EOS by Entware team
# allow-failure: false
outputs:
IPK_VERSION: ${{ steps.versions.outputs.IPK }}
CORE_VERSION: ${{ steps.versions.outputs.CORE }}
WEB_VERSION: ${{ steps.versions.outputs.WEB }}
FTL_VERSION: ${{ steps.versions.outputs.FTL }}
steps:
- name: Fail this job
if: ${{ matrix.allow-failure && github.ref_name != 'master' && !startsWith(github.ref, 'refs/tags/') }}
run: exit 1
- name: Checkout own repository
uses: actions/checkout@v4
- name: Download core artifact
uses: actions/download-artifact@v4
with:
name: core
path: ./artifacts/core
- name: Download web artifact
uses: actions/download-artifact@v4
with:
name: web
path: ./artifacts/web
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: binary-${{ matrix.arch }}
path: ./artifacts/binary
- name: Add -dev postfix to package name
if: ${{ github.ref_name == 'develop' }}
run: sed '/^Package:/ s/$/-dev/' ./files/CONTROL/control
- name: Build package
run: |
mkdir -pv ./build ./packages
bash ./scripts/build.sh ./build
bash ./scripts/ipk.sh ./build "${{ needs.globals.outputs.VERSION }}" ${{ matrix.entware_arch }}
mv -fv ./*.ipk ./packages
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ipk-${{ matrix.entware_arch }}
path: ./packages/*
- name: Set versions
id: versions
run: |
echo "IPK=${{ needs.globals.outputs.VERSION }}" >> $GITHUB_OUTPUT
. ./artifacts/core/.version
echo "CORE=$VERSION" >> $GITHUB_OUTPUT
. ./artifacts/web/.version
echo "WEB=$VERSION" >> $GITHUB_OUTPUT
. ./artifacts/binary/.version
echo "FTL=$VERSION" >> $GITHUB_OUTPUT
release:
concurrency: release-${{ github.ref_name || github.run_id }}
needs: [build-package]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ipk-*
path: ./artifacts
- name: Create changelog file
env:
CORE_VERSION: ${{ needs.build-package.outputs.CORE_VERSION }}
WEB_VERSION: ${{ needs.build-package.outputs.WEB_VERSION }}
FTL_VERSION: ${{ needs.build-package.outputs.FTL_VERSION }}
run: |
CORE_VERSION_OUT="[$CORE_VERSION](https://github.com/pi-hole/pi-hole/releases/tag/$CORE_VERSION)"
WEB_VERSION_OUT="[$WEB_VERSION](https://github.com/pi-hole/web/releases/tag/$WEB_VERSION)"
FTL_VERSION_OUT="[$FTL_VERSION](https://github.com/pi-hole/FTL/releases/tag/$FTL_VERSION)"
[ "$(echo "$CORE_VERSION" | cut -c1)" != "v" ] && CORE_VERSION_OUT="[$CORE_VERSION](https://github.com/pi-hole/pi-hole/commit/$CORE_VERSION)"
[ "$(echo "$WEB_VERSION" | cut -c1)" != "v" ] && WEB_VERSION_OUT="[$WEB_VERSION](https://github.com/pi-hole/web/commit/$WEB_VERSION)"
[ "$(echo "$FTL_VERSION" | cut -c1)" != "v" ] && FTL_VERSION_OUT="[$FTL_VERSION](https://github.com/pi-hole/FTL/commit/$FTL_VERSION)"
echo "Core version: $CORE_VERSION_OUT " >> changelog.md
echo "Web version: $WEB_VERSION_OUT " >> changelog.md
echo "FTL version: $FTL_VERSION_OUT " >> changelog.md
- name: Create or Edit a release
uses: softprops/action-gh-release@v2
with:
files: ./artifacts/*/*.ipk
tag_name: ${{ needs.build-package.outputs.IPK_VERSION }}
body_path: changelog.md
append_body: true
generate_release_notes: true
upload:
concurrency: upload
needs: [build-package]
if: ${{ startsWith(github.ref, 'refs/tags/') || github.ref_name == 'develop' || github.ref_name == 'master' }}
# @TODO when v6 is released master should not trigger this job
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup dependencies
run: |
sudo apt-get update
sudo apt-get install rename
- name: Checkout own repository
uses: actions/checkout@v4
with:
fetch-depth: 0
sparse-checkout: /.github/*
sparse-checkout-cone-mode: false
- name: Checkout gh-pages branch
uses: actions/checkout@v4
continue-on-error: true
with:
ref: gh-pages
path: ./gh-pages
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ipk-*
path: ./artifacts
- name: Collect new packages
run: |
rename 's/ipk-//' ./artifacts/ipk-*/
mkdir -p ./gh-pages
find ./artifacts -mindepth 1 -maxdepth 1 -type d -name "*-*" -exec bash -c '
ARCH=$(basename "$1")
echo "Collecting new packages for $ARCH"
if [ "$(find "$1" -maxdepth 1 -type f -name "*-dev_*.ipk" -print -quit)" ]; then
find "./gh-pages/$ARCH" -maxdepth 2 -type f -name "*-dev_*.ipk" -delete -print
else
find "./gh-pages/$ARCH" -maxdepth 2 -type f \( -name "*.ipk" ! -name "*-dev_*.ipk" \) -delete -print
fi
' bash {} \;
cp -r ./artifacts/* ./gh-pages
- name: Checkout Entware/ipk-html-indexer repository
uses: actions/checkout@v4
with:
repository: Entware/ipk-html-indexer
path: ./ipk-html-indexer
- name: Run ipk-html-indexer
run: |
sudo ln -sv "$(readlink -f ./ipk-html-indexer/mkindex.py)" /usr/local/bin/mkindex.py
sudo ln -sv "$(readlink -f ./ipk-html-indexer/mkhtml.py)" /usr/local/bin/mkhtml.py
find ./gh-pages -mindepth 1 -maxdepth 1 -type d -name "*-*" -exec bash -c '
bash ./ipk-html-indexer/index_feed.sh -h -f "$1"
sed 's#href="/css#href="css#' -i "$1/Packages.html"
cp -frv ./ipk-html-indexer/css "$1"
' bash {} \;
- name: List files
uses: ./.github/actions/list
with:
paths: . ./gh-pages
- name: Create directory listings
uses: ./.github/actions/index
with:
path: ./gh-pages
- name: List files
uses: ./.github/actions/list
with:
paths: . ./gh-pages
- name: Cleanup working directory
run: |
find . -mindepth 1 -maxdepth 1 \( ! -name "gh-pages" -type d -exec rm -frv "{}" \; \) -o \( -type f -exec rm -fv "{}" \; \)
cp -r ./gh-pages/. .
rm -fr ./gh-pages
find . -mindepth 1 -maxdepth 1 -type d ! -name "*-*" -exec rm -frv "{}" \;
- name: Rename gh-pages branch
continue-on-error: true
run: git branch -m gh-pages gh-pages.old
- name: Upload packages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: .
commit-message: Upload
single-commit: true
force: true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: upload
path: |
./index.html
./*-*/*