-
Notifications
You must be signed in to change notification settings - Fork 10
398 lines (350 loc) · 15.6 KB
/
makefile.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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
name: u-boot-ingenic
on:
schedule:
# 00:15 PST / Nightly
- cron: '00 7 * * *'
workflow_dispatch:
inputs:
tg_disabled:
type: boolean
description: 'Disable Telegram notifications'
required: false
default: false
tg_scratch:
type: boolean
description: 'Use TG scratch channel'
required: false
default: false
t31x_only:
type: boolean
description: 'Only build T31X profile '
required: false
default: false
debug_enabled:
type: boolean
description: 'Debug: Generate dummy image files'
required: false
default: false
env:
TAG_NAME: uboot-xb1
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TERM: linux
TG_TOKEN: ${{secrets.TELEGRAM_TOKEN_BOT_THINGINO}}
TG_CHANNEL: ${{secrets.TELEGRAM_CHANNEL_THINGINO_BUILD}}
TG_TOPIC: ${{secrets.TELEGRAM_TOPIC_THINGINO_BUILD}}
TG_CHANNEL_SCRATCH: ${{secrets.TELEGRAM_CHANNEL_THINGINO_SCRATCH}}
TZ: America/Los_Angeles
jobs:
notify-begin:
runs-on: ubuntu-24.04
outputs:
start_time: ${{ steps.set_output.outputs.time }}
tg_disabled: ${{ steps.set_env.outputs.tg_disabled }}
steps:
- name: Set timezone
run: |
sudo timedatectl set-timezone ${{ env.TZ }}
- name: Save workflow start time to ENV
id: set_output
run: echo "time=$(date +%s)" >> $GITHUB_OUTPUT
- name: Configure Environment Variables
run: |
echo "TG_DISABLED=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_ENV
echo "tg_disabled=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_OUTPUT
TAG_NAME="$TAG_NAME-$(date +'%Y-%m-%d')"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: "master"
fetch-depth: "1"
- name: Create release tag
continue-on-error: true
run: |
TAG_NAME="${{ env.TAG_NAME }}"
if ! gh api repos/${{ github.repository }}/git/ref/tags/$TAG_NAME &>/dev/null; then
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
else
echo "Tag $TAG_NAME already exists."
fi
- name: Create release
continue-on-error: true
run: |
TAG_NAME="${{ env.TAG_NAME }}"
if ! gh release view "$TAG_NAME" --repo "${{ github.repository }}" &>/dev/null; then
echo "Release $TAG_NAME does not exist. Creating pre-release."
gh release create "$TAG_NAME" --repo "${{ github.repository }}" --title "$TAG_NAME" --notes "pre-release: \`\`\`$TAG_NAME\`\`\` is currently being built, please wait..." --prerelease
else
echo "Release $TAG_NAME already exists."
fi
- name: Download TG-Notify script
run: |
curl -o .github/scripts/tg-notify.sh https://raw.githubusercontent.com/themactep/thingino-firmware/master/.github/scripts/tg-notify.sh
chmod +x .github/scripts/tg-notify.sh
- name: Send build start notifcation via Telegram
if: env.TG_DISABLED == 'false'
run: |
if [[ "${{ github.event.inputs.tg_scratch }}" == 'true' ]]; then
TG_CHANNEL=${{ env.TG_CHANNEL_SCRATCH }}
export TG_TOPIC=""
fi
.github/scripts/tg-notify.sh -s $TG_TOKEN $TG_CHANNEL $TG_TOPIC start ${{ github.workflow }} ${{ github.run_id }} ${{ github.repository }}
generate-matrix:
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set timezone
run: |
sudo timedatectl set-timezone ${{ env.TZ }}
- name: Configure GH workspace
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: "master"
fetch-depth: "1"
- name: Generate device matrix
id: set-matrix
run: |
if [[ "${{ github.event.inputs.t31x_only }}" == 'true' ]]; then
CONFIGS=$(cat boards.cfg | grep isvp | awk '{print $1}' | grep isvp_t31_sfcnor_ddr128M)
else
CONFIGS=$(cat boards.cfg | grep isvp | awk '{print $1}' | grep -v -e nand)
fi
JSON_MATRIX="{\"u-boot-version\": ["
for CONFIG in $CONFIGS; do
JSON_MATRIX+="\"${CONFIG}\","
done
JSON_MATRIX="${JSON_MATRIX%,}]}"
echo "Matrix: $JSON_MATRIX"
echo "matrix=$JSON_MATRIX" >> $GITHUB_OUTPUT
build:
name: ${{ matrix.u-boot-version }}
needs: [generate-matrix, notify-begin]
runs-on: ubuntu-24.04
outputs:
# Feed the hash of the commit we are building into the notify-completion release-notes step
GIT_HASH: ${{ steps.env.outputs.git_hash }}
TAG_NAME: ${{ steps.env.outputs.tag_name }}
defaults:
run:
shell: bash
container:
image: debian:bookworm
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
steps:
- name: Install GitHub CLI to container
run: |
apt-get update
apt-get install -y curl
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
- name: Update package manager sources
run: |
apt-get update
- name: Install build dependencies
run: |
apt-get install -y --no-install-recommends --no-install-suggests 7zip build-essential bc ccache cpio curl ca-certificates file git gh jq make gawk lzop procps rsync tzdata u-boot-tools unzip
- name: Set timezone
run: |
ln -sf /usr/share/zoneinfo/${{ env.TZ }} /etc/localtime
echo ${{ env.TZ }} > /etc/timezone
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure -f noninteractive tzdata
- name: Setup gh workspace to container
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout repository source
uses: actions/checkout@v4
with:
ref: "master"
fetch-depth: "1"
- name: Configure environment variables
id: env
run: |
echo "WEEK_NUMBER=$(date +%U)" >> $GITHUB_ENV
echo "CURRENT_YEAR=$(date +%Y)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "TG_DISABLED=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_ENV
TAG_NAME="$TAG_NAME-$(date +'%Y-%m-%d')"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_OUTPUT
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT
- name: Download TG-Notify script
run: |
curl -o .github/scripts/tg-notify.sh https://raw.githubusercontent.com/themactep/thingino-firmware/master/.github/scripts/tg-notify.sh
chmod +x .github/scripts/tg-notify.sh
- name: Setup cache directories
run: |
mkdir -p /github/home/.ccache
- name: Restore build cache
uses: actions/cache@v4
if: always()
with:
path: /github/home/.ccache
key: ${{ runner.os }}-ccache-${{ matrix.u-boot-version }}-${{ env.CURRENT_YEAR }}-week-${{ env.WEEK_NUMBER }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-ccache-${{ matrix.u-boot-version }}-${{ env.CURRENT_YEAR }}-week-${{ env.WEEK_NUMBER }}
${{ runner.os }}-ccache-${{ matrix.u-boot-version }}-${{ env.CURRENT_YEAR }}-week-
${{ runner.os }}-ccache-${{ matrix.u-boot-version }}-
${{ runner.os }}-ccache-shared-v1-${{ env.CURRENT_YEAR }}-week-${{ env.WEEK_NUMBER }}
${{ runner.os }}-ccache-shared-v1-${{ env.CURRENT_YEAR }}-week-
- name: Download toolchain
run: |
curl -L https://github.com/themactep/thingino-firmware/releases/download/toolchain/thingino-toolchain_xburst1_musl_gcc14-linux-mipsel.tar.gz -o ~/thingino-toolchain_xburst1_musl_gcc14-linux-mipsel.tar.gz
tar -xf ~/thingino-toolchain_xburst1_musl_gcc14-linux-mipsel.tar.gz -C ~/
~/mipsel-thingino-linux-musl_sdk-buildroot/relocate-sdk.sh
- name: u-boot-ingenic Build
if: ${{ github.event.inputs.debug_enabled != 'true' }}
shell: bash
run: |
export CCACHE_DIR=/github/home/.ccache
export PATH="/usr/lib/ccache:$PATH"
export PATH="/github/home/mipsel-thingino-linux-musl_sdk-buildroot/bin:$PATH"
ccache -M 4G
CROSS_COMPILE="ccache mipsel-linux-" bash build.sh ${{ matrix.u-boot-version }}
TIME=$(date -d @${SECONDS} +%M:%S)
echo "TIME=${TIME}" >> ${GITHUB_ENV}
- name: Generate debug dummy uboot for workflow testing
if: ${{ github.event.inputs.debug_enabled == 'true' }}
run: |
mkdir -p ./uboot_build
echo "debug" > ./uboot_build/u-boot-${{ matrix.u-boot-version }}.bin
echo "TIME=7:77" >> ${GITHUB_ENV}
- name: Check if compiled u-boot exists
run: |
FILE=./uboot_build/u-boot-${{ matrix.u-boot-version }}.bin
if [ ! -f "$FILE" ]; then
echo "File not found exit"
exit 1
fi
echo "Found file: $FILE"
echo "UBOOTFW=$FILE" >> $GITHUB_ENV
- name: Generate checksum file
run: |
sha256sum "${{ env.UBOOTFW }}" | awk -v filename="$(basename "${{ env.UBOOTFW }}")" '{print $1, filename}' > ./uboot_build/u-boot-${{ matrix.u-boot-version }}.bin.sha256sum
echo "UBOOTFW_SHA=./uboot_build/u-boot-${{ matrix.u-boot-version }}.bin.sha256sum" >> $GITHUB_ENV
- name: Upload firmware as artifact
uses: actions/upload-artifact@v4
with:
name: u-boot-${{ matrix.u-boot-version }}.bin
path: |
${{ env.UBOOTFW }}
${{ env.UBOOTFW_SHA }}
- name: Upload ${{ matrix.u-boot-version }} to release
uses: softprops/action-gh-release@v2.1.0
with:
tag_name: ${{ env.TAG_NAME }}
make_latest: false
prerelease: true
files: |
${{ env.UBOOTFW }}
${{ env.UBOOTFW_SHA }}
- name: Package binaries for notify
run: |
7zz a -t7z -mx=9 -mmt=on /tmp/u-boot-${{ matrix.u-boot-version }}.7z ${{ env.UBOOTFW }} ${{ env.UBOOTFW_SHA }}
- name: Send uboot completion notifications with attachment
if: ${{ env.TG_DISABLED == 'false' && (env.UBOOTFW) }}
run: |
if [[ "${{ github.event.inputs.tg_scratch }}" == 'true' ]]; then
TG_CHANNEL=${{ env.TG_CHANNEL_SCRATCH }}
export TG_TOPIC=""
fi
if [ -n "${{ env.UBOOTFW }}" ]; then
.github/scripts/tg-notify.sh -s $TG_TOKEN $TG_CHANNEL $TG_TOPIC completed $TAG_NAME ${{ github.run_id }} ${{ github.repository }} ${GIT_HASH} ${GIT_BRANCH} ${TAG_NAME} ${TIME} ${{ matrix.u-boot-version }} /tmp/u-boot-${{ matrix.u-boot-version }}.7z
fi
- name: Send error notification
if: ${{ env.TG_DISABLED == 'false' && failure() }}
run: |
if [[ "${{ github.event.inputs.tg_scratch }}" == 'true' ]]; then
TG_CHANNEL=${{ env.TG_CHANNEL_SCRATCH }}
export TG_TOPIC=""
fi
.github/scripts/tg-notify.sh -s $TG_TOKEN $TG_CHANNEL $TG_TOPIC error $TAG_NAME ${{ github.run_id }} ${{ github.repository }}
notify-completion:
needs: [build, notify-begin]
runs-on: ubuntu-24.04
if: always()
steps:
- name: Set timezone
run: |
sudo timedatectl set-timezone ${{ env.TZ }}
- name: Configure Environment
run: |
echo "TG_DISABLED=${{ github.event.inputs.tg_disabled || 'false' }}" >> $GITHUB_ENV
echo "GIT_HASH=${{ needs.build.outputs.git_hash }}" >> $GITHUB_ENV
echo "TAG_NAME=${{ needs.build.outputs.tag_name }}" >> $GITHUB_ENV
- name: Checkout repository source
uses: actions/checkout@v4
with:
submodules: 'false'
ref: "master"
- name: Download TG-Notify script
run: |
curl -o .github/scripts/tg-notify.sh https://raw.githubusercontent.com/themactep/thingino-firmware/master/.github/scripts/tg-notify.sh
chmod +x .github/scripts/tg-notify.sh
- name: Generate release notes
id: release_notes
run: |
LAST_RELEASE_TAG=$(gh release list --limit 2 --json tagName -q '.[1].tagName')
if [ -z "$LAST_RELEASE_TAG" ]; then
echo "No previous release found. Skipping release notes generation."
echo "RELEASE_NOTES_FILE=$(pwd)/release_notes.md" >> $GITHUB_ENV
exit 0
else
echo "Latest release so far is $LAST_RELEASE_TAG"
fi
COMMITS=$(gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/${{ github.repository }}/compare/$LAST_RELEASE_TAG...$GIT_HASH \
-q '.commits | sort_by(.commit.author.date) | reverse | .[] | "\(.sha[0:7]) \(.commit.message | gsub("\n"; " "))"')
if [ -z "$COMMITS" ]; then
echo "### No changes, nightly rebuild" > release_notes.md
else
RELEASE_NOTES="### Changes in this release:\n"
while IFS= read -r commit; do
if [ -n "$commit" ]; then
RELEASE_NOTES="${RELEASE_NOTES}- ${commit}\n"
fi
done <<< "$COMMITS"
echo -e "$RELEASE_NOTES" > release_notes.md
fi
echo "RELEASE_NOTES_FILE=$(pwd)/release_notes.md" >> $GITHUB_ENV
- name: Get release ID and Mark as Latest
run: |
echo "Environment variables:"
echo "TAG_NAME: ${{ env.TAG_NAME }}"
echo "Checking GH authentication status..."
gh auth status
echo "Attempting to fetch release URL for tag ${TAG_NAME}..."
RELEASE_URL=$(gh release view ${{ env.TAG_NAME }} --json url -q ".url")
echo "RELEASE_URL: $RELEASE_URL"
if [[ -n "$RELEASE_URL" ]]; then
echo "Release URL found, attempting to mark as latest..."
if [[ -f "${{ env.RELEASE_NOTES_FILE }}" ]]; then
echo "Release notes file exists, including --notes-file..."
gh release edit ${{ env.TAG_NAME }} --latest --prerelease=false --notes-file "${{ env.RELEASE_NOTES_FILE }}"
else
echo "Release notes file does not exist, skipping --notes-file..."
gh release edit ${{ env.TAG_NAME }} --latest --prerelease=false --notes ""
fi
echo "Release marked as latest"
else
echo "Release not found, skipping latest release update"
fi
- name: Send notify completion summary
if: ${{ env.TG_DISABLED == 'false' }}
run: |
if [[ "${{ github.event.inputs.tg_scratch }}" == 'true' ]]; then
TG_CHANNEL=${{ env.TG_CHANNEL_SCRATCH }}
export TG_TOPIC=""
fi
START_TIME=${{ needs.notify-begin.outputs.start_time }}
END_TIME=$(date -u +%s)
ELAPSED=$((END_TIME - START_TIME))
ELAPSED_MIN=$((ELAPSED / 60))
ELAPSED_SEC=$((ELAPSED % 60))
.github/scripts/tg-notify.sh -s $TG_TOKEN $TG_CHANNEL $TG_TOPIC finish ${{ github.workflow }} "${ELAPSED_MIN}m ${ELAPSED_SEC}s" ${{ github.run_id }} ${{ github.repository }}