-
Notifications
You must be signed in to change notification settings - Fork 65
292 lines (239 loc) · 12 KB
/
create_raspbian_pi-gen.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
name: Create Raspbian Homebridge Image using pi-gen
run-name: Create Raspbian Homebridge Image ${{ github.ref }}
on:
release:
types: [released]
jobs:
tag:
name: Verify Release Tag
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get Release Tag
id: get_version
uses: jannemattila/get-version-from-tag@v3
- name: Tag Info
run: |
echo "Release Tag: ${{github.ref}}"
echo "Latest Tag: ${{ steps.get_version.outputs.version }}"
- name: Tag Info Matches
if: endsWith(github.ref, steps.get_version.outputs.version )
run: |
echo Latest Tag matches Release tag
- name: Tag Info Doesn't Match
if: ${{ !endsWith(github.ref, steps.get_version.outputs.version ) }}
run: |
echo Latest Tag does not matches Release tag
exit 1
build_images:
name: Build RPI Homebridge (${{ matrix.name }}) Image ${{ needs.tag.outputs.version }}
needs: tag
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
name: [
64bit,
32bit
]
include:
- pi-gen-version: arm64
release: bookworm
name: 64bit
devices: '["pi5-64bit", "pi4-64bit", "pi3-64bit"]'
- pi-gen-version: master
release: bookworm
name: 32bit
devices: '["pi5-32bit", "pi4-32bit", "pi3-32bit", "pi2-32bit", "pi1-32bit"]'
# The build
steps:
- uses: actions/checkout@v4
# https://stackoverflow.com/questions/72444103/what-does-running-the-multiarch-qemu-user-static-does-before-building-a-containe
# - name: Setup Dependencies
# run: |
# sudo apt-get update
# sudo apt-get --yes --no-install-recommends install binfmt-support qemu-user-static
# docker run --rm --privileged multiarch/qemu-user-static:register --reset
# f022813 aka 1.7.0
- uses: usimd/pi-gen-action@f022813e54a67d9f8fe8a6a6d620a5da3739a632
name: Run pi-gen ( get some popcorn this will take awhile )
id: build
with:
# Compression to apply on final image (either "none", "zip", "xz" or "gz").
compression: zip
# Compression level to be used. From 0 to 9 (refer to the tool man page for more
# information on this. Usually 0 is no compression but very fast, up to 9 with the
# best compression but very slow).
compression-level: 6
# Disable the renaming of the first user during the first boot. This make it so
# 'username' stays activated. 'username' must be set for this to work. Please be
# aware of the implied security risk of defining a default username and password
# for your devices.
disable-first-boot-user-rename: 1
# Additional options to include in PIGEN_DOCKER_OPTS
# '--env IMG_DATE=Raspbian'
docker-opts: '--env BUILD_VERSION="${{ github.repository }}-${{ needs.tag.outputs.version }}-\(${{ matrix.name }}\)"'
# Set whether a NOOBS image should be built as well. If enabled, the output
# directory containing the NOOBS files will be saved as output variable
# 'image-noobs-path'.
enable-noobs: false
# Enable SSH access to Pi.
enable-ssh: 1
# If this feature is enabled, the action will configure pi-gen to not export any
# stage as image but the last one defined in property 'stage-list'. This is
# helpful when building a single image flavor (in contrast to building a
# lite/server and full-blown desktop image), since it speeds up the build process
# significantly.
export-last-stage-only: true
# Comma or whitespace separated list of additional packages to install on host
# before running pi-gen. Use this list to add any packages your custom stages may
# require. Note that this is not affecting the final image. In order to add
# additional packages, you need to add a respective 'XX-packages' file in your
# custom stage.
extra-host-dependencies: ''
# Comma or whitespace separated list of additional modules to load on host before
# running pi-gen. If your custom stage requires additional software or kernel
# modules to be loaded, add them here. Note that this is not meant to configure
# modules to be loaded in the target image.
extra-host-modules: ''
# Token to use for checking out pi-gen repo.
github-token: ${{ github.token }}
# Host name of the image.
hostname: homebridge
# Final image name.
image-name: 'Homebridge-${{ matrix.release }}-${{ matrix.name }}'
# Default keyboard keymap.
keyboard-keymap: gb
# Default keyboard layout.
keyboard-layout: English (UK)
# Default locale of the system image.
locale: en_GB.UTF-8
# Password of the intial user account, locked if empty.
password: 'raspberry'
# Path where selected pi-gen ref will be checked out to. If the path does not yet
# exist, it will be created (including its parents).
pi-gen-dir: pi-gen
# GitHub repository to fetch pi-gen from, must be a fork from RPi-Distro/pi-gen.
pi-gen-repository: RPi-Distro/pi-gen
# Release version of pi-gen to use. This can both be a branch or tag name known in
# the pi-gen repository.
pi-gen-version: ${{ matrix.pi-gen-version }}
# The release version to build images against. Valid values are jessie, stretch,
# buster, bullseye, bookworm, and testing.
release: ${{ matrix.release }}
# Setting to `1` will prevent pi-gen from dropping the "capabilities" feature.
# Generating the root filesystem with capabilities enabled and running it from a
# filesystem that does not support capabilities (like NFS) can cause issues. Only
# enable this if you understand what it is.
setfcap: ''
# List of stage name to execute in given order. Relative and absolute paths to
# custom stage directories are allowed here. Note that by default pi-gen exports
# images in stage2 (lite), stage4 and stage5. You probably want to hook in custom
# stages before one of the exported stages. Otherwise, the action will make sure
# any custom stage will include an image export directive.
stage-list: stage0 stage1 stage2 ./stage3_homebridge
# System timezone.
timezone: Europe/London
# Use qcow2 images to reduce space and runtime requirements.
use-qcow2: 0
# Name of the initial user account.
username: pi
# Print all output from pi-gen.
verbose-output: false
# Wifi country code of default network to connect to.
wpa-country: ''
# SSID of a default wifi network to connect to.
wpa-essid: ''
# Password of default wifi network to connect to.
wpa-password: ''
# This is not currently used
- name: Calculate Image Checksum
id: get_sha256_checksum
run: |
export IMGFILENAME=`basename ${{ steps.build.outputs.image-path }}`
echo "IMGFILENAME=${IMGFILENAME}" >> $GITHUB_ENV
export IMAGE_SHA256_CHECKSUM=$(shasum -a 256 ${{ steps.build.outputs.image-path }} | awk '{print $1}')
echo "$IMAGE_SHA256_CHECKSUM ${{ steps.build.outputs.image-path }}"
echo "::notice::IMAGE_SHA256_CHECKSUM ${IMGFILENAME} ==> ${IMAGE_SHA256_CHECKSUM}"
- name: Upload Image to release v${{ needs.tag.outputs.version }}
uses: AButler/[email protected]
with:
files: '${{ steps.build.outputs.image-path }}'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ needs.tag.outputs.version }}
- name: Generate rpi-image-repo.json
id: generate_rpi-image-repo
run: |
export RPI_IMAGER_NAME="Homebridge ${{ matrix.release }} (${{ matrix.name }})"
export RPI_IMAGER_DESCRIPTION="Official Homebridge Raspberry Pi Image ${{ matrix.release }} (${{ matrix.name }})"
export RPI_IMAGER_ICON="https://user-images.githubusercontent.com/3979615/116509191-3c35f880-a906-11eb-9a7f-7cad7c2aa641.png"
export RPI_IMAGER_WEBSITE="https://github.com/homebridge/homebridge-raspbian-image/wiki/Getting-Started"
export RPI_IMAGER_IMAGE_URL="https://github.com/${{ github.repository }}/releases/download/v${{ needs.tag.outputs.version }}/${{ env.IMGFILENAME }}"
export RPI_IMAGER_DEVICES='${{ matrix.devices }}'
./make_rpi-imager-snipplet.py --rpi_imager_url ${RPI_IMAGER_IMAGE_URL}
- name: Rename rpi-image-repo to ./rpi-image-repo-${{ matrix.name }}.json
run: |
mv pi-gen/deploy/rpi-image-repo.json ./rpi-image-repo-${{ matrix.name }}.json
- name: Upload Info to release ${{ needs.tag.outputs.version }}
uses: AButler/[email protected]
with:
files: './*.json'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ needs.tag.outputs.version }}
finalize_info:
name: Prep ${{ needs.tag.outputs.version }} Info file
needs: [tag, build_images]
runs-on: [ubuntu-latest]
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
repositories: 'homebridge.io'
owner: 'homebridge'
- uses: actions/checkout@v4
# with:
# token: ${{ steps.app-token.outputs.token }}
- uses: robinraju/[email protected]
name: Downloard image info files from release ${{ needs.tag.outputs.version }}
with:
# The github tag. e.g: v1.0.1
# Download assets from a specific tag/version
tag: v${{ needs.tag.outputs.version }}
# The name of the file to download.
# Use this field only to specify filenames other than tarball or zipball, if any.
# Supports wildcard pattern (eg: '*', '*.deb', '*.zip' etc..)
fileName: "*.json"
- name: Combine rpi-image-repo JSON's
run: |
./combine-rpi-imager-snipplet.py
- name: Upload combined rpi-image-repo to release ${{ needs.tag.outputs.version }}
uses: AButler/[email protected]
with:
files: 'rpi-image-repo.json'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ needs.tag.outputs.version }}
- name: Push ${{ needs.tag.outputs.version }} Image to Homebridge Registry
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ steps.app-token.outputs.token }}
with:
source_file: 'rpi-image-repo.json'
destination_repo: 'homebridge/homebridge.io'
destination_branch: 'source'
destination_folder: 'src/public/'
user_email: 'github-actions[bot]@users.noreply.github.com'
user_name: 'github-actions[bot]'
commit_message: 'New Homebridge Image Release ${{ needs.tag.outputs.version }}'
github-releases-to-discord:
needs: [tag, build_images, finalize_info]
uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest
with:
title: "Homebridge Raspbian Image Release"
description: |
Version `v${{ needs.tag.outputs.version }}`
url: "https://github.com/homebridge/homebridge-raspbian-image/releases/tag/v${{ needs.tag.outputs.version }}"
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }}