-
Notifications
You must be signed in to change notification settings - Fork 12
256 lines (225 loc) · 7.85 KB
/
BuildTrain.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
name: Build Train
on:
# on every monday at 3:30
schedule:
- cron: '30 3 * * 1'
# build a new release on push a new config file
push:
branches:
- "master"
paths:
- "configs/*"
# enable manual start of this workflow
workflow_dispatch:
# Allow to stop obsolete workflows
concurrency:
group: ci-buildtrain-release-${{ github.ref }}-1
cancel-in-progress: true
jobs:
setup:
name: Create Matrix
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Matrix Armbian
id: set-matrix-armbian
run: |
JSON=$(find ${{ github.workspace }}/configs -type f -name "board-*.conf" -printf '%f\n' | sed 's#board-##;s#.conf##' | jq -R -s -c 'split("\n")[:-1]')
echo "configfiles=${JSON}" >> $GITHUB_OUTPUT
echo "::group::Matrix Armbian"
echo "${JSON}"
echo "::endgroup::"
- name: Create Matrix OrangePi
id: set-matrix-orangepi
run: |
JSON=$(find ${{ github.workspace }}/configs-orangepi -type f -name "board-*.conf" -printf '%f\n' | sed 's#board-##;s#.conf##' | jq -R -s -c 'split("\n")[:-1]')
echo "configfiles=${JSON}" >> $GITHUB_OUTPUT
echo "::group::Matrix OrangePi"
echo "${JSON}"
echo "::endgroup::"
outputs:
configfiles-armbian: ${{ steps.set-matrix-armbian.outputs.configfiles }}
configfiles-orangepi: ${{ steps.set-matrix-orangepi.outputs.configfiles }}
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
id: ${{ steps.release.outputs.id }}
tag_name: ${{ steps.time.outputs.time }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: build-configs
fetch-depth: 0
- name: Read configs
id: config
shell: bash
run: |
source ./build-configs/configs/config-default.conf
echo "armbian_repository=${ARMBIAN_REPOSITORY}" >> $GITHUB_OUTPUT
echo "armbian_branch=${ARMBIAN_BRANCH}" >> $GITHUB_OUTPUT
- name: Checkout armbian Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ steps.config.outputs.armbian_repository }}
ref: ${{ steps.config.outputs.armbian_branch }}
path: build
- name: Get armbian version
id: armbian-version
run: |
sed -i 's/-trunk//' ./build/VERSION
VERSION=$(cat ./build/VERSION)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Get time
id: time
uses: nanzm/[email protected]
with:
format: 'YYYYMMDD-HHmm'
- name: Create empty release
id: release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.armbian-version.outputs.version }}-${{ steps.time.outputs.time }}
tag_name: ${{ steps.time.outputs.time }}
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
build-armbian:
name: Armbian
needs: [setup, release]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
configfile: ${{ fromJson(needs.setup.outputs.configfiles-armbian) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: build-configs
- name: Build image
uses: ./build-configs/actions/build-image
with:
configfile: ${{ matrix.configfile }}
- name: Rename Files
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/build/output/images/
mv *.img armbian-${{ matrix.configfile }}.img
mv *.txt armbian-${{ matrix.configfile }}.txt
- name: Compressing Image
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/build/output/images/
xz -efkvz armbian-${{ matrix.configfile }}.img || true
- name: Calculating checksums
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/build/output/images/
sha256sum armbian-${{ matrix.configfile }}.img > armbian-${{ matrix.configfile }}.img.sha256
sha256sum armbian-${{ matrix.configfile }}.img.xz > armbian-${{ matrix.configfile }}.img.xz.sha256
- name: Upload Image to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./build/output/images/*.img.xz
draft: true
- name: Upload Checksum to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./build/output/images/*.sha256
draft: true
- name: Upload Config to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./build/output/images/*.txt
draft: true
build-orangepi:
name: Orangepi
needs: [ setup, release ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
configfile: ${{ fromJson(needs.setup.outputs.configfiles-orangepi) }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
path: build-configs
- name: Build image
uses: ./build-configs/actions/build-orangepi-image
with:
configfile: ${{ matrix.configfile }}
- name: Rename Files
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/build/output/images/
mv */*.img ./orangepi-${{ matrix.configfile }}.img
- name: Compressing Image
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/build/output/images/
xz -efkvz orangepi-${{ matrix.configfile }}.img || true
- name: Calculating checksums
run: |
WORKSPACE=$(echo ${{ github.workspace }})
cd $WORKSPACE/build/output/images/
sha256sum orangepi-${{ matrix.configfile }}.img > orangepi-${{ matrix.configfile }}.img.sha256
sha256sum orangepi-${{ matrix.configfile }}.img.xz > orangepi-${{ matrix.configfile }}.img.xz.sha256
- name: Upload Image to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./build/output/images/*.img.xz
draft: true
- name: Upload Checksum to Release
if: needs.release.outputs.id != ''
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
file: ./build/output/images/*.sha256
draft: true
finish:
name: Finish BuildTrain
needs: [release, build-armbian, build-orangepi]
runs-on: ubuntu-latest
steps:
- name: Publish Release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.release.outputs.id }}
cleanup:
name: Cleanup BuildTrain
needs: [release, build-armbian, build-orangepi]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Delete drafts
uses: hugo19941994/[email protected]
with:
threshold: 2d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}