-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
288 lines (259 loc) · 10.6 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
name: Build
on:
workflow_dispatch:
inputs:
package:
description: 'Package to build'
required: true
default: 'adminer'
publish:
description: 'Publish to repository'
required: false
default: false
type: boolean
# Add a separator as a non-input description
build_settings_description:
description: 'Build Settings (archs to include):'
required: false
default: ''
type: choice
options:
- '---'
add_noarch_builds:
description: 'Include noarch packages'
required: false
default: true
type: boolean
add_noarch_dsm72_builds:
description: 'Include noarch DSM 7.2 packages'
required: false
default: false
type: boolean
add_dsm72_builds:
description: 'Include DSM 7.2 archs'
required: false
default: false
type: boolean
add_dsm71_builds:
description: 'Include DSM 7.1 archs'
required: false
default: true
type: boolean
add_dsm62_builds:
description: 'Include DSM 6.2 archs'
required: false
default: true
type: boolean
add_dsm52_builds:
description: 'Include DSM 5.2 archs'
required: false
default: false
type: boolean
add_srm12_builds:
description: 'Include SRM 1.2 archs'
required: false
default: false
type: boolean
pull_request:
paths:
- 'spk/**'
- 'cross/**'
- 'native/**'
push:
branches:
- "**"
paths:
- 'spk/**'
- 'cross/**'
- 'native/**'
jobs:
prepare:
name: Prepare for Build
runs-on: ubuntu-latest
# provide results to other jobs
outputs:
arch_packages: ${{ steps.dependencies.outputs.arch_packages }}
noarch_packages: ${{ steps.dependencies.outputs.noarch_packages }}
has_min_dsm72_packages: ${{ steps.dependencies.outputs.has_min_dsm72_packages }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Get changed files for pull request
if: github.event_name == 'pull_request'
id: getfile_pr
run: |
git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | xargs
echo "files=$(git diff --no-commit-id --name-only -r origin/master...${{github.event.pull_request.head.sha}} | xargs)" >> $GITHUB_OUTPUT
- name: Get changed files for push
if: github.event_name == 'push'
id: getfile
run: |
git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | xargs
echo "files=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
- name: Evaluate dependencies
id: dependencies
run: ./.github/actions/prepare.sh
env:
GH_FILES: ${{ steps.getfile.outputs.files }} ${{ steps.getfile_pr.outputs.files }}
SPK_TO_BUILD: ${{ github.event.inputs.package }}
- name: Cache downloaded files
uses: actions/cache@v4
with:
path: distrib
# use run_id in key to cache within workflow only.
key: distrib-${{ github.run_id }}
- name: Download source files
run: ./.github/actions/download.sh
env:
DOWNLOAD_PACKAGES: ${{ steps.dependencies.outputs.download_packages }}
ARCH_PACKAGES: ${{ needs.prepare.outputs.arch_packages }}
NOARCH_PACKAGES: ${{ needs.prepare.outputs.noarch_packages }}
set-defaults:
name: Set Defaults
runs-on: ubuntu-latest
needs: prepare
outputs:
matrix: ${{ steps.defaults.outputs.matrix }}
steps:
- id: defaults
run: |
# Retrieve inputs and package availability
add_noarch_builds=${{ github.event.inputs.add_noarch_builds || 'false' }}
add_noarch_dsm72_builds=${{ github.event.inputs.add_noarch_dsm72_builds || 'false' }}
add_dsm72_builds=${{ github.event.inputs.add_dsm72_builds || 'false' }}
add_dsm71_builds=${{ github.event.inputs.add_dsm71_builds || 'false' }}
add_dsm62_builds=${{ github.event.inputs.add_dsm62_builds || 'false' }}
add_dsm52_builds=${{ github.event.inputs.add_dsm52_builds || 'false' }}
add_srm12_builds=${{ github.event.inputs.add_srm12_builds || 'false' }}
has_noarch_packages=$([ -n "${{ needs.prepare.outputs.noarch_packages }}" ] && echo "true" || echo "false")
has_arch_packages=$([ -n "${{ needs.prepare.outputs.arch_packages }}" ] && echo "true" || echo "false")
has_min_dsm72_packages=${{ needs.prepare.outputs.has_min_dsm72_packages || 'false' }}
# Dynamic logic for automatic builds
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
# Enable noarch builds if noarch packages exist
add_noarch_builds=$([ "$has_noarch_packages" == "true" ] && echo "true" || echo "false")
# Enable noarch DSM 7.2 builds if noarch packages exist and minimum DSM 7.2 requirements are met
add_noarch_dsm72_builds=$([ "$has_noarch_packages" == "true" ] && [ "$has_min_dsm72_packages" == "true" ] && echo "true" || echo "false")
# Enable DSM 7.2 builds if arch packages exist and minimum DSM 7.2 requirements are met
add_dsm72_builds=$([ "$has_arch_packages" == "true" ] && [ "$has_min_dsm72_packages" == "true" ] && echo "true" || echo "false")
# Enable DSM 7.1 builds if arch packages exist
add_dsm71_builds=$([ "$has_arch_packages" == "true" ] && echo "true" || echo "false")
# Enable DSM 6.2 builds if arch packages exist
add_dsm62_builds=$([ "$has_arch_packages" == "true" ] && echo "true" || echo "false")
fi
# Build matrix
matrix=$(jq -n '{"include": []}')
# Helper function to add entries to the matrix
add_to_matrix() {
matrix=$(echo "$matrix" | jq --arg arch "$1" '.include += [{"arch": $arch}]')
}
# Add noarch builds
if [ "$add_noarch_builds" == "true" ] && [ "$has_noarch_packages" == "true" ]; then
add_to_matrix "noarch-1.1"
add_to_matrix "noarch-3.1"
add_to_matrix "noarch-6.1"
add_to_matrix "noarch-7.0"
fi
# Add noarch DSM 7.2 builds
if [ "$add_noarch_dsm72_builds" == "true" ] && [ "$has_noarch_packages" == "true" ]; then
add_to_matrix "noarch-7.2"
fi
# Add DSM 7.2 builds
if [ "$add_dsm72_builds" == "true" ] && [ "$has_arch_packages" == "true" ]; then
add_to_matrix "x64-7.2"
add_to_matrix "aarch64-7.2"
add_to_matrix "armv7-7.2"
fi
# Add DSM 7.1 builds
if [ "$add_dsm71_builds" == "true" ] && [ "$has_arch_packages" == "true" ]; then
add_to_matrix "x64-7.1"
add_to_matrix "aarch64-7.1"
add_to_matrix "evansport-7.1"
add_to_matrix "armv7-7.1"
add_to_matrix "comcerto2k-7.1"
fi
# Add DSM 6.2 builds
if [ "$add_dsm62_builds" == "true" ] && [ "$has_arch_packages" == "true" ]; then
add_to_matrix "x64-6.2.4"
add_to_matrix "aarch64-6.2.4"
add_to_matrix "evansport-6.2.4"
add_to_matrix "armv7-6.2.4"
add_to_matrix "hi3535-6.2.4"
add_to_matrix "88f6281-6.2.4"
add_to_matrix "qoriq-6.2.4"
fi
# Add DSM 5.2 builds
if [ "$add_dsm52_builds" == "true" ] && [ "$has_arch_packages" == "true" ]; then
add_to_matrix "x86-5.2"
add_to_matrix "88f6281-5.2"
add_to_matrix "ppc853x-5.2"
fi
# Add SRM 1.2 builds
if [ "$add_srm12_builds" == "true" ]; then
add_to_matrix "armv7-1.2"
fi
# Output the final matrix
echo "matrix=$(echo $matrix | jq -c)" >> $GITHUB_OUTPUT
build:
name: Build
needs: set-defaults
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.set-defaults.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache toolchains
uses: actions/cache@v4
# Do not cache qoriq toolchain. It must be built every time to install custom rust toolchain
if: ${{ contains(matrix.arch,'qoriq') == false }}
with:
path: toolchain/*/work
key: toolchain-${{ matrix.arch }}-v3-${{ hashFiles(format('toolchain/syno-{0}/digests',matrix.arch)) }}
- name: Use cache of downloaded files
uses: actions/cache@v4
with:
path: distrib
key: distrib-${{ github.run_id }}
- name: Build Package (based on changed files)
# We don't want to stop the build on errors.
# Errors are reported in "Build Status"
continue-on-error: true
uses: docker://ghcr.io/synocommunity/spksrc:latest
with:
entrypoint: ./.github/actions/build.sh
env:
ARCH_PACKAGES: ${{ needs.prepare.outputs.arch_packages }}
NOARCH_PACKAGES: ${{ needs.prepare.outputs.noarch_packages }}
PUBLISH: ${{ github.event.inputs.publish }}
API_KEY: ${{ secrets.PUBLISH_API_KEY }}
PACKAGE_TO_PUBLISH: ${{ github.event.inputs.package }}
# https://github.com/SynoCommunity/spksrc/wiki/Compile-and-build-rules
GH_ARCH: ${{ matrix.arch }}
BUILD_ERROR_FILE: /github/workspace/build_errors.txt
BUILD_ERROR_LOGFILE: /github/workspace/build_log_errors.txt
BUILD_UNSUPPORTED_FILE: /github/workspace/build_unsupported.txt
BUILD_SUCCESS_FILE: /github/workspace/build_success.txt
- name: Build Status
id: build_status
# We need this status since we don't want to stop the build on errors.
# Here we fail on build errors found in the build error file.
uses: docker://ghcr.io/synocommunity/spksrc:latest
with:
entrypoint: ./.github/actions/build_status.sh
env:
BUILD_ERROR_FILE: /github/workspace/build_errors.txt
BUILD_ERROR_LOGFILE: /github/workspace/build_log_errors.txt
BUILD_UNSUPPORTED_FILE: /github/workspace/build_unsupported.txt
BUILD_SUCCESS_FILE: /github/workspace/build_success.txt
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: Packages for ${{ matrix.arch }}
path: packages/*.spk
if-no-files-found: ignore