-
-
Notifications
You must be signed in to change notification settings - Fork 208
170 lines (158 loc) · 5.27 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
name: Build, Test, Deploy
on:
push:
branches:
- '**'
pull_request:
release:
types: [published]
jobs:
smoke-tests:
if: |
github.event_name == 'push'
|| github.event_name == 'release'
|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
outputs:
GIT_TAG: ${{ steps.variables.outputs.GIT_TAG }}
GIT_BRANCH: ${{ steps.variables.outputs.GIT_BRANCH }}
OUTPUT_DIR: ${{ steps.variables.outputs.OUTPUT_DIR }}
runs-on: ubuntu-latest
steps:
-
name: Checkout code
uses: actions/[email protected]
-
name: "Calculate required variables"
id: variables
run: |
GIT_TAG=${{ github.event.release.tag_name }}
# If GIT_TAG is set then GIT BRANCH should be "master", else set it from GITHUB_REF
GIT_BRANCH=$([ -n "${GIT_TAG}" ] && echo "master" || echo "${GITHUB_REF#refs/*/}")
echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_OUTPUT
echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT
echo "OUTPUT_DIR=${GIT_TAG:-${GIT_BRANCH}}" >> $GITHUB_OUTPUT
-
name: "Check git branch name depth"
env:
GIT_BRANCH: ${{ steps.variables.outputs.GIT_BRANCH }}
run: |
IFS='/';
read -r -a branch <<<"${GIT_BRANCH}";
if [[ "${#branch[@]}" -gt 2 ]]; then echo "Error: Your branch name contains more than one subdir, which will cause issues with the build process." && FAIL=1; fi;
unset IFS;
# If FAIL is 1 then we fail.
[[ $FAIL == 1 ]] && exit 1 || echo "Branch name depth check passed."
shell: bash
build:
runs-on: ubuntu-latest
needs: smoke-tests
container: ghcr.io/pi-hole/ftl-build:v1.26-${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
bin_name: pihole-FTL-linux-x86_64
- arch: x86_64
arch_extra: _full
bin_name: pihole-FTL-linux-x86_64_full
- arch: x86_64-musl
bin_name: pihole-FTL-musl-linux-x86_64
- arch: x86_32
bin_name: pihole-FTL-linux-x86_32
- arch: armv4t
bin_name: pihole-FTL-armv4-linux-gnueabi
- arch: armv5te
bin_name: pihole-FTL-armv5-linux-gnueabi
- arch: armv6hf
bin_name: pihole-FTL-armv6-linux-gnueabihf
- arch: armv7hf
bin_name: pihole-FTL-armv7-linux-gnueabihf
- arch: armv8a
bin_name: pihole-FTL-armv8-linux-gnueabihf
- arch: aarch64
bin_name: pihole-FTL-aarch64-linux-gnu
- arch: riscv64
bin_name: pihole-FTL-riscv64-linux-gnu
env:
CI_ARCH: ${{ matrix.arch }}${{ matrix.arch_extra }}
steps:
-
name: Checkout code
uses: actions/[email protected]
-
name: "Fix ownership of repository"
run: chown -R root .
-
name: "Fix ownership of repository"
run: chown -R root .
-
name: "Build"
env:
GIT_BRANCH: ${{ needs.smoke-tests.outputs.GIT_BRANCH }}
GIT_TAG: ${{ needs.smoke-tests.outputs.GIT_TAG }}
run: |
bash build.sh "-DSTATIC=${STATIC}"
-
name: "Binary checks"
run: |
bash test/arch_test.sh
-
name: "Test x86_32/64 binaries"
if: matrix.arch == 'x86_64' || matrix.arch == 'x86_64-musl' || matrix.arch == 'x86_32'
run: |
bash test/run.sh
-
name: "Generate checksum file"
run: |
mv pihole-FTL "${{ matrix.bin_name }}"
sha1sum pihole-FTL-* > ${{ matrix.bin_name }}.sha1
-
name: Upload artifacts to job for later processing
if: github.event_name != 'pull_request'
uses: actions/[email protected]
with:
name: tmp-binary-storage
path: '${{ matrix.bin_name }}*'
deploy:
if: github.event_name != 'pull_request'
needs: [smoke-tests, build]
runs-on: ubuntu-latest
steps:
-
name: Checkout code
uses: actions/[email protected]
-
name: Get Binaries built in previous jobs
uses: actions/[email protected]
id: download
with:
name: tmp-binary-storage
path: ftl-builds/
-
name: Display structure of downloaded files
run: ls -R
working-directory: ${{steps.download.outputs.download-path}}
-
name: Install SSH Key
uses: benoitchantre/[email protected]
with:
private-key: ${{ secrets.SSH_KEY }}
known-hosts: ${{ secrets.KNOWN_HOSTS }}
-
name: Transfer Builds to Pi-hole server for pihole checkout
if: github.actor != 'dependabot[bot]'
env:
USER: ${{ secrets.SSH_USER }}
HOST: ${{ secrets.SSH_HOST }}
TARGET_DIR: ${{ needs.smoke-tests.outputs.OUTPUT_DIR }}
SOURCE_DIR: ${{ steps.download.outputs.download-path }}
run: |
bash ./deploy.sh
-
name: Attach binaries to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
${{ steps.download.outputs.download-path }}/*