-
-
Notifications
You must be signed in to change notification settings - Fork 17
325 lines (299 loc) · 12.6 KB
/
build-images.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
# Original: https://github.com/guysoft/OctoPi-Klipper-CustomPiOS/blob/6a88c12f562be4668e26fe89a445e761be1481ac/LICENSE
# License: GPL-3.0
name: build images
on:
push:
branches:
- "build-*"
tags:
- "v*"
jobs:
# first, prepare the sources by moving the 'latest' tag to the current SHA
prepare:
runs-on: ubuntu-24.04
steps:
# check the sources out in the 'expected place' for the following step that tags them
- name: Checkout Project Repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Check Python Code
run: |
cd src/modules/adsb-feeder/filesystem/root/opt/adsb/adsb-setup
python3 -m py_compile *.py
- name: tag current version as latest (regardless of other tags)
uses: rickstaa/action-create-tag@v1
with:
tag: "latest"
tag_exists_error: false
force_push_tag: true
message: "latest commit"
# next run all the board builds
build:
needs: prepare
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
name: [lepotato, nanopi-neo3-dietpi, orangepi-3lts-dietpi, orangepi-5plus-dietpi, orangepi-zero3-dietpi, raspberrypi64-pi-2-3-4-5, raspberrypi64-dietpi-pi-2-3-4, raspberrypi64-dietpi-pi-5, x86-64-native, x86-64-vm]
include:
- name: lepotato
base_arch: arm64
variant: armbian
url: https://test.adsb.im/downloads/Armbian-unofficial_23.11.0-trunk_Lepotato_bookworm_current_6.1.63_minimal.img.xz
magic_path: "repository/src/image-armbian/le-potato.img.xz"
- name: nanopi-neo3-dietpi
variant: dietpi-fat-2
base_arch: arm64
dietpi_machine: 56
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_NanoPiNEO3-ARMv8-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_NanoPiNEO3-ARMv8-Bookworm.img.xz"
- name: orangepi-3LTS-dietpi
variant: dietpi-fat-2
base_arch: arm64
dietpi_machine: 89
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_OrangePi3LTS-ARMv8-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_OrangePi3LTS-ARMv8-Bookworm.img.xz"
- name: orangepi-5plus-dietpi
variant: dietpi-fat-2
base_arch: arm64
dietpi_machine: 82
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_OrangePi5Plus-ARMv8-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_OrangePi5Plus-ARMv8-Bookworm.img.xz"
- name: orangepi-zero3-dietpi
variant: dietpi-fat-2
base_arch: arm64
dietpi_machine: 83
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_OrangePiZero3-ARMv8-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_OrangePiZero3-ARMv8-Bookworm.img.xz"
- name: raspberrypi64-pi-2-3-4-5
base_arch: arm64
variant: default
url: https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-10-28/2024-10-22-raspios-bookworm-arm64-lite.img.xz
magic_path: "repository/src/image/2024-03-15-raspios-bookworm-arm64-lite.img.xz"
- name: raspberrypi64-dietpi-pi-2-3-4
base_arch: arm64
variant: dietpi-fat-1
dietpi_machine: 4
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_RPi234-ARMv8-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_RPi-ARMv8-Bookworm.img.xz"
- name: raspberrypi64-dietpi-pi-5
base_arch: arm64
variant: dietpi-fat-1
dietpi_machine: 5
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_RPi5-ARMv8-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_RPi5-ARMv8-Bookworm.img.xz"
- name: x86-64-native
variant: dietpi-root-only
base_arch: x86_64
dietpi_machine: 21
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_NativePC-BIOS-x86_64-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_NativePC-BIOS-x86_64-Bookworm.img.xz"
- name: x86-64-vm
variant: dietpi-root-only
base_arch: x86_64
dietpi_machine: 20
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_VM-x86_64-Bookworm.img.xz
magic_path: "repository/src/image-dietpi/DietPi_VM-x86_64-Bookworm.img.xz"
env:
IMG_NAME: ${{ matrix.name }}
BASE_ARCH: ${{ matrix.base_arch }}
VARIANT: ${{ matrix.variant }}
IMAGE_URL: ${{ matrix.url }}
MAGIC_PATH: ${{ matrix.magic_path }}
DIETPI_MACHINE: ${{ matrix.dietpi_machine }}
steps:
- name: mask secrets
run: |
echo "::add-mask::${{ secrets.USER_PASSWORD }}"
echo "::add-mask::${{ secrets.ROOT_PASSWORD }}"
echo "::add-mask::${{ secrets.SSH_KEY }}"
- name: Checkout Project Repository again with the new tag - and make sure we have the full history for the version code
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
path: repository
- name: Install Dependencies
run: |
sudo rm -f /var/lib/man-db/auto-update
sudo apt update
sudo apt-get install -y coreutils p7zip-full qemu-user-static qemu-utils lz4
- name: Checkout CustomPiOS
uses: actions/checkout@v4
with:
repository: 'dirkhh/CustomPiOS'
ref: 'adsbim'
show-progress: false
path: CustomPiOS
- name: Checkout DietPi
uses: actions/checkout@v4
if: ${{ startsWith(env.VARIANT, 'dietpi') }}
with:
repository: dirkhh/DietPi
ref: adsbim
show-progress: false
path: DietPi
- name: Update CustomPiOS Paths and create image directories
run: |
cd repository/src
../../CustomPiOS/src/update-custompios-paths
mkdir -p image image-armbian image-dietpi
- name: Download image
run: |
MAGIC_DIR=$(dirname "${MAGIC_PATH}")
mkdir -p "${MAGIC_DIR}"
wget -qO "${MAGIC_PATH}" "$IMAGE_URL"
- name: create a reasonable tag for this run - either a short sha or the tag we were called with
id: tag
run: |
export tag=""
export is_release="test"
if [ "${{ github.ref_type }}" = "tag" ] ; then tag="${{ github.ref_name }}" ; else tag="${{ github.sha }}" ; fi
if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then is_release="release" ; fi
if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta ]] ; then is_release="beta" ; fi
export better_tag=$(echo $tag | sed -r 's/^(.{8}).{32}$/g-\1/')
echo "tag=${better_tag}" >> $GITHUB_OUTPUT
echo "is_release=${is_release}" >> $GITHUB_OUTPUT
- name: Build Image
id: build
run: |
if [[ ${IMG_NAME} == *x86-64-vm* ]] ; then
# this is where we run out of space. Bugger.
echo "remaining space before cleanup $(df -h .)"
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/local/lib/android
sudo rm -f /var/lib/man-db/auto-update
sudo apt-get autoremove -y >/dev/null 2>&1 || true
sudo apt-get autoclean -y >/dev/null 2>&1 || true
echo "remaining space now $(df -h .)"
fi
sudo modprobe loop
cd repository/src
# if BASE_ARCH is set, add it to config
if [ -n "${BASE_ARCH}" ]; then
echo "export BASE_ARCH=${BASE_ARCH}" >> config
fi
feeder_image_name="adsb-im-${IMG_NAME}-${{ steps.tag.outputs.tag }}.img"
echo "export BASE_USER_PASSWORD=${{ secrets.USER_PASSWORD }}" >> config
echo "export ROOT_PWD=${{ secrets.ROOT_PASSWORD }}" >> config
echo "export SSH_PUB_KEY='${{ secrets.SSH_KEY }}'" >> config
echo "export FEEDER_IMAGE_NAME=${feeder_image_name}" >> config
echo "feeder_image_name=${feeder_image_name}" >> $GITHUB_OUTPUT
# make raspberry pi image as small as we can
if [[ ${IMG_NAME} == raspberrypi64-pi-2-3-4-5 ]] ; then
echo "export BASE_IMAGE_ENLARGEROOT=0" >> config
echo "export BASE_IMAGE_RESIZEROOT=10" >> config
fi
# finally, try one more time to have ALL the tags - to avoid weird errors in the code
# creating the version name - and also update `latest` in case that was wrong as well
git fetch --tags --force
sudo GH_REF_TYPE=${{ github.ref_type }} GH_TRGT_REF=${{ github.ref_name }} bash -x ./build_dist "${VARIANT}"
- name: Release Image
env:
BASE_RELEASE_COMPRESS: no
run: |
if [[ "${VARIANT}" = *"dietpi"* ]] ; then
echo "this doesn't do anything"
else
cd repository/src
# CUSTOM_PI_OS_PATH is needed, its set in build_dist. Setting here manually
export CUSTOM_PI_OS_PATH="$(realpath ../../CustomPiOS/src/)"
source config
sudo --preserve-env ../../CustomPiOS/src/release "${VARIANT}"
fi
- name: Copy output
id: copy
run: |
mkdir -p uploads
CURRENT_IMAGE_NAME="$(basename $MAGIC_PATH)"
echo "${CURRENT_IMAGE_NAME}"
IMAGE="${{ steps.build.outputs.feeder_image_name }}"
if [ "${VARIANT}" = "default" ]; then
WORKSPACE="repository/src/workspace"
elif [[ "${VARIANT}" = *"dietpi"* ]] ; then
WORKSPACE="repository/src/image-dietpi"
else
WORKSPACE="repository/src/workspace-${VARIANT}"
fi
ls -l "$WORKSPACE"
BUILT_IMAGE="$(find $WORKSPACE -name "*.img" | head -n 1)"
sudo mv -v "${BUILT_IMAGE}" uploads/"${IMAGE}"
if [[ ${IMG_NAME} == *x86-64-vm* ]] ; then
for img in $(find $WORKSPACE -name "DietPi_*.xz") ; do
base_name=$(basename "$img")
nodiet=${base_name#DietPi_}
nobookworm=${nodiet/-Bookworm/}
noarch=${nobookworm/-X86_64/}
echo "$img -> $nodiet -> $nobookworm -> $noarch"
final_name="adsb-im-x86-64-vm-${{ steps.tag.outputs.tag }}-${noarch}"
sudo mv -v "$img" uploads/"${final_name}"
done
fi
if [[ ${MAGIC_PATH} == *NativePC* ]] ; then
BUILT_ISO="$(find $WORKSPACE -name "*.iso" | head -n 1)"
sudo mv -v "${BUILT_ISO}" uploads/"${IMAGE%.img}.iso"
fi
- name: Compress img
id: compress
run: |
cd uploads
export IMAGE="${{ steps.build.outputs.feeder_image_name }}"
case ${IMAGE} in
*-x86-64-vm*)
NAME=${IMAGE%.img}
echo "name: ${NAME}"
cp ../repository/src/tools/pve-vmcreate.sh .
qemu-img convert -f raw ${IMAGE} -O qcow2 ${NAME}.qcow2
XZ_OPT="-T0 --fast" tar cJf ${NAME}-proxmox.tar.xz ${NAME}.qcow2 pve-vmcreate.sh
echo "created tar file ${NAME}-proxmox.tar.xz"
ls -l ${NAME}-proxmox.tar.xz
sudo rm -f ${NAME}.qcow2 pve-vmcreate.sh
qemu-img convert -f raw "${IMAGE}" -O vmdk ${NAME}.vmdk
lz4 --fast --favor-decSpeed ${NAME}.vmdk ${NAME}.vmdk.lz4
rm -f ${NAME}.vmdk
rm -f ${IMAGE}
ls -l ${NAME}*
echo "image=${NAME}*" >> $GITHUB_OUTPUT
;;
*)
echo "simply compress ${IMAGE}"
sudo xz -z -1 -T0 "${IMAGE}"
if [ -f ${IMAGE%.img}.iso ] ; then
sudo xz -z -1 -T0 ${IMAGE%.img}.iso
echo "image=${IMAGE%.img}.iso.xz" >> $GITHUB_OUTPUT
fi
echo "image=${IMAGE}.xz" >> $GITHUB_OUTPUT
;;
esac
ls -lh .
- name: Upload to GitHub as release
uses: softprops/action-gh-release@v2
if: ${{ steps.tag.outputs.is_release == 'release' }}
with:
token: ${{ secrets.PAT_GITHUB_TOKEN }}
generate_release_notes: true
body_path: repository/release-notes.md
files: uploads/*
- name: Upload to GitHub as beta release
uses: softprops/action-gh-release@v2
if: ${{ steps.tag.outputs.is_release == 'beta' }}
with:
token: ${{ secrets.PAT_GITHUB_TOKEN }}
generate_release_notes: true
body_path: repository/release-notes.md
prerelease: true
files: uploads/*
- name: Upload non-release artifacts
uses: softprops/action-gh-release@v2
if: ${{ steps.tag.outputs.is_release == 'test' }}
with:
token: ${{ secrets.PAT_GITHUB_TOKEN }}
generate_release_notes: true
prerelease: true
tag_name: latest
name: testbuild-${{ steps.tag.outputs.tag }}
files: uploads/*