forked from hzyitc/armbian-onecloud
-
Notifications
You must be signed in to change notification settings - Fork 0
326 lines (281 loc) · 11.4 KB
/
ci.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
name: CI
on:
workflow_dispatch:
push:
branches:
- readme
paths:
- .github/workflows/ci.yml
env:
SCRIPT_REPO: ${{ github.repository }}
SCRIPT_REF: ${{ github.ref_name }}
UBOOT_REPO: hzyitc/u-boot-onecloud
UBOOT_RELEASE: latest
UBOOT_BURNIMG: eMMC.burn.img
ARMBIAN_REPO: armbian/build
ARMBIAN_REF: main
PATCHES: 4077,5076,5082
jobs:
prepare:
name: Prepare
runs-on: ubuntu-22.04
outputs:
env: ${{ steps.get.outputs.env }}
steps:
- id: get
name: Get repositories information
run: |
TIME="$(curl https://api.github.com/repos/${SCRIPT_REPO}/actions/runs/${GITHUB_RUN_ID} | jq -r .created_at)"
SCRIPT_SHA=$(curl https://api.github.com/repos/${SCRIPT_REPO}/commits/${SCRIPT_REF} | jq -r .sha)
UBOOT_TAG=$(curl https://api.github.com/repos/${UBOOT_REPO}/releases/${UBOOT_RELEASE} | jq -r .tag_name)
ARMBIAN_SHA=$(curl https://api.github.com/repos/${ARMBIAN_REPO}/commits/${ARMBIAN_REF} | jq -r .sha)
cat <<EOF | sed -E 's/^ //' >>$GITHUB_ENV
TIME=$TIME
SCRIPT_SHA=$SCRIPT_SHA
UBOOT_TAG=$UBOOT_TAG
ARMBIAN_SHA=$ARMBIAN_SHA
EOF
echo "env=$(cat $GITHUB_ENV | base64 -w 0)" >>$GITHUB_OUTPUT
- name: Show repositories information
run: |
C_RESET="\e[0m"
C_BLACK="\e[30m"
C_RED="\e[31m"
C_GREEN="\e[32m"
C_YELLOW="\e[33m"
C_BLUE="\e[34m"
C_MAGENTA="\e[35m"
C_CYAN="\e[36m"
C_GRAY="\e[37m"
echo -e "$(cat <<EOF | sed -E 's/^ //'
TIME: ${C_GREEN}$(date -d "$TIME" +'%Y-%m-%d %H:%M:%S %Z(%:z)')${C_RESET}
Script: ${C_BLUE}${SCRIPT_REPO}${C_RESET}@${C_MAGENTA}${SCRIPT_REF}${C_RESET}(https://github.com/${SCRIPT_REPO}/tree/${SCRIPT_REF})
${C_YELLOW}${SCRIPT_SHA}${C_RESET}(https://github.com/${SCRIPT_REPO}/tree/${SCRIPT_SHA})
U-Boot: ${C_BLUE}${UBOOT_REPO}${C_RESET}@${C_MAGENTA}${UBOOT_RELEASE}${C_RESET}(https://github.com/${UBOOT_REPO}/releases/tag/${UBOOT_RELEASE})
${C_MAGENTA}${UBOOT_TAG}${C_RESET}(https://github.com/${UBOOT_REPO}/releases/tag/${UBOOT_TAG})
Armbian: ${C_BLUE}${ARMBIAN_REPO}${C_RESET}@${C_MAGENTA}${ARMBIAN_REF}${C_RESET}(https://github.com/${ARMBIAN_REPO}/tree/${ARMBIAN_REF})
${C_YELLOW}${ARMBIAN_SHA}${C_RESET}(https://github.com/${ARMBIAN_REPO}/tree/${ARMBIAN_SHA})
EOF
)"
if [[ -n "${PATCHES}" ]]; then
echo -e "\nPatches:"
while read -r id; do
echo -e " ${C_BLUE}armbian/build${C_RESET}#${C_MAGENTA}${id}${C_RESET}(http://github.com/armbian/build/pull/${id})"
done < <(echo -e "${PATCHES}" | tr ',' '\n')
fi
cat <<EOF | sed -E 's/^ //' >>$GITHUB_STEP_SUMMARY
# $(date -d "$TIME" +'%Y-%m-%d %H:%M:%S %Z(%:z)')
## Sources
Script: [${SCRIPT_REPO}@${SCRIPT_REF}](https://github.com/${SCRIPT_REPO}/tree/${SCRIPT_REF}) ([\`${SCRIPT_SHA}\`](https://github.com/${SCRIPT_REPO}/tree/${SCRIPT_SHA}))
U-Boot: [${UBOOT_REPO}@${UBOOT_RELEASE}](https://github.com/${UBOOT_REPO}/releases/tag/${UBOOT_RELEASE}) ([\`${UBOOT_TAG}\`](https://github.com/${UBOOT_REPO}/releases/tag/${UBOOT_TAG}))
Armbian: [${ARMBIAN_REPO}@${ARMBIAN_REF}](https://github.com/${ARMBIAN_REPO}/tree/${ARMBIAN_REF}) ([\`${ARMBIAN_SHA}\`](https://github.com/${ARMBIAN_REPO}/tree/${ARMBIAN_SHA}))
${PATCHES:+$(
echo "## Patches"
echo "${PATCHES}" | tr ',' '\n' | sed -E 's|(.*)|[armbian/build#\1](http://github.com/armbian/build/pull/\1)|'
)}
EOF
build-debs:
name: Build ${{ matrix.BRANCH }}
needs: prepare
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
BRANCH:
- edge
- current
steps:
- name: Import env
run: |
echo "$(echo "${{ needs.prepare.outputs.env }}" | base64 -d)" >>$GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
repository: ${{ env.ARMBIAN_REPO }}
ref: ${{ env.ARMBIAN_SHA }}
- name: "Apply patch ${{ env.PATCHES }}"
if: ${{ env.PATCHES }}
run: |
curl -L -O "https://github.com/armbian/build/pull/{${PATCHES}}.patch"
for file in *.patch; do
patch --batch -p1 -N <"$file"
done
- name: Build
run: |
# Don't update remote cache
export GITHUB_ACTIONS=false
sudo --preserve-env \
./compile.sh kernel \
ALLOW_ROOT=yes \
BOARD=onecloud \
BRANCH=${{ matrix.BRANCH }} \
EXPERT=yes \
USE_CCACHE=no
sudo chown $(id -u):$(id -g) -R output/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: debs-${{ matrix.BRANCH }}
path: output/debs/*
build:
name: Build ${{ matrix.RELEASE }}-${{ matrix.BRANCH }}-${{ matrix.TYPE == 'desktop' && matrix.DESKTOP_ENVIRONMENT || matrix.TYPE }}
needs: [ prepare, build-debs ]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
BRANCH:
- edge
- current
RELEASE:
# - focal # Ubuntu 20.04 LTS
# - jammy # Ubuntu 22.04 LTS
# - lunar # Ubuntu 23.04
# - buster # Debian 10
# - bullseye # Debian 11
- bookworm # Debian 12
- trixie Debian 13
# - sid # Debian unstable
TYPE:
- minimal
- cli
steps:
- name: Import env
run: |
echo "$(echo "${{ needs.prepare.outputs.env }}" | base64 -d)" >>$GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
repository: ${{ env.ARMBIAN_REPO }}
ref: ${{ env.ARMBIAN_SHA }}
- name: "Apply patch ${{ env.PATCHES }}"
if: ${{ env.PATCHES }}
run: |
curl -L -O "https://github.com/armbian/build/pull/{${PATCHES}}.patch"
for file in *.patch; do
patch --batch -p1 -N <"$file"
done
- name: Download debs
uses: actions/download-artifact@v3
with:
name: debs-${{ matrix.BRANCH }}
path: output/debs/
- name: Build
run: |
# Don't update remote cache
export GITHUB_ACTIONS=false
sudo --preserve-env \
./compile.sh build \
ALLOW_ROOT=yes \
BOARD=onecloud \
BRANCH=${{ matrix.BRANCH }} \
RELEASE=${{ matrix.RELEASE }} \
KERNEL_CONFIGURE=no \
BUILD_MINIMAL=${{ matrix.TYPE == 'minimal' && 'yes' || 'no' }} \
BUILD_DESKTOP=${{ matrix.TYPE == 'desktop' && 'yes' || 'no' }} \
DESKTOP_ENVIRONMENT=${{ matrix.DESKTOP_ENVIRONMENT }} \
DESKTOP_ENVIRONMENT_CONFIG_NAME=${{ matrix.DESKTOP_ENVIRONMENT_CONFIG_NAME }} \
DESKTOP_APPGROUPS_SELECTED=${{ matrix.DESKTOP_APPGROUPS_SELECTED }} \
EXPERT=yes \
SKIP_EXTERNAL_TOOLCHAINS=yes \
CLEAN_LEVEL= \
USE_CCACHE=no \
COMPRESS_OUTPUTIMAGE=img
sudo chown $(id -u):$(id -g) -R output/
- name: Install Dependents
run: |
sudo apt install img2simg
ver="v0.3.1"
curl -L -o ./AmlImg https://github.com/hzyitc/AmlImg/releases/download/$ver/AmlImg_${ver}_linux_amd64
chmod +x ./AmlImg
- name: Download and unpack the latest u-boot
run: |
echo "::group::Download"
curl -L -o ./uboot.img https://github.com/${UBOOT_REPO}/releases/download/${UBOOT_TAG}/${UBOOT_BURNIMG}
echo "::endgroup::"
echo "::group::Unpack"
./AmlImg unpack ./uboot.img burn/
echo "::endgroup::"
- name: Extract boot and rootfs partitions
run: |
diskimg=$(ls output/images/*.img)
loop=$(sudo losetup --find --show --partscan $diskimg)
sudo img2simg ${loop}p1 burn/boot.simg
sudo img2simg ${loop}p2 burn/rootfs.simg
sudo losetup -d $loop
sudo chown $(id -u):$(id -g) -R burn/
- name: Generate burn image
run: |
echo -n "sha1sum $(sha1sum burn/boot.simg | awk '{print $1}')" >burn/boot.VERIFY
echo -n "sha1sum $(sha1sum burn/rootfs.simg | awk '{print $1}')" >burn/rootfs.VERIFY
cat <<EOF >>burn/commands.txt
PARTITION:boot:sparse:boot.simg
VERIFY:boot:normal:boot.VERIFY
PARTITION:rootfs:sparse:rootfs.simg
VERIFY:rootfs:normal:rootfs.VERIFY
EOF
prefix=$(ls output/images/*.img | sed 's/\.img$//')
burnimg=${prefix}.burn.img
./AmlImg pack $burnimg burn/
- name: Hash and compress images
run: |
for f in output/images/*.img; do
sha256sum "$f" >"${f}.sha"
xz --threads=0 --compress "$f"
done
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.RELEASE }}-${{ matrix.BRANCH }}-${{ matrix.TYPE == 'desktop' && matrix.DESKTOP_ENVIRONMENT || matrix.TYPE }}
path: output/images/*
release:
needs: [ prepare, build ]
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Import env
run: |
echo "$(echo "${{ needs.prepare.outputs.env }}" | base64 -d)" >>$GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts/
- name: Generate sha256sum
run: |
touch sha256sum
for a in artifacts/*/*.sha; do
cat "$a" >>sha256sum
rm -f "$a"
done
- name: Show sha256sum
run: |
cat sha256sum
cat <<EOF | sed -E 's/^ //' >>$GITHUB_STEP_SUMMARY
# SHA256
$(cat sha256sum | awk '{printf "%s: `%s`\n", $2, $1}')
EOF
- name: Release
run: |
cat <<EOF | sed -E 's/^ //' >Release.md
CI $(date -d "$TIME" +'%Y-%m-%d %H:%M:%S %Z(%:z)')
# Sources
Script: [${SCRIPT_REPO}@${SCRIPT_REF}](https://github.com/${SCRIPT_REPO}/tree/${SCRIPT_REF}) ([\`${SCRIPT_SHA}\`](https://github.com/${SCRIPT_REPO}/tree/${SCRIPT_SHA}))
U-Boot: [${UBOOT_REPO}@${UBOOT_RELEASE}](https://github.com/${UBOOT_REPO}/releases/tag/${UBOOT_RELEASE}) ([\`${UBOOT_TAG}\`](https://github.com/${UBOOT_REPO}/releases/tag/${UBOOT_TAG}))
Armbian: [${ARMBIAN_REPO}@${ARMBIAN_REF}](https://github.com/${ARMBIAN_REPO}/tree/${ARMBIAN_REF}) ([\`${ARMBIAN_SHA}\`](https://github.com/${ARMBIAN_REPO}/tree/${ARMBIAN_SHA}))
${PATCHES:+$(
echo "# Patches"
echo "${PATCHES}" | tr ',' '\n' | sed -E 's|(.*)|[armbian/build#\1](http://github.com/armbian/build/pull/\1)|'
)}
# SHA256
$(cat sha256sum | awk '{printf "%s: `%s`\n", $2, $1}')
EOF
tag="ci-$(date -d "$TIME" -u +'%Y%m%d-%H%M%S-%Z')"
hub release create -t "$GITHUB_SHA" "$tag" -F Release.md \
-a sha256sum \
$(for a in artifacts/*/Armbian_*; do echo -a $a; done) \
$(for a in artifacts/*/linux-{image,headers,dtb}-*; do echo -a $a; done)
env:
GITHUB_TOKEN: ${{ github.token }}