Repository navigation
200 lines (177 loc) · 8.08 KB
/
Copy pathbuild.yml
File metadata and controls
200 lines (177 loc) · 8.08 KB
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
name: Build
on:
push:
branches: [main]
tags:
- 'pab-[0-9]*'
- 'jaj-[0-9]*'
- 'pab-v3-[0-9]*'
pull_request:
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
jobs:
build:
runs-on: ubuntu-24.04
# Kernel build alone is ~70 min on a cold ccache; leave headroom for packaging
# (tar + parallel compress of the rootfs) and the multi-GB release upload.
timeout-minutes: 180
# Only tag builds publish; the environment admits release tags and main, so a PR build must not ask for it
environment: ${{ startsWith(github.ref, 'refs/tags/') && 'downloads' || '' }}
permissions:
contents: read
id-token: write
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
# Above one build's object set (~1 GB) so ccache doesn't evict its own hits;
# the rotating ccache is the natural LRU victim under the repo's 10 GB budget.
CCACHE_MAXSIZE: "2G"
# Fresh checkouts reset mtimes and a few kernel files embed __DATE__/__TIME__;
# ignore those so they don't force misses.
CCACHE_SLOPPINESS: time_macros,include_file_ctime,include_file_mtime
# The cross toolchain is restored from its own cache each run with fresh
# mtimes; ccache's default compiler check is the compiler's mtime, so that alone
# invalidated the entire cache (observed ~1% hit rate). Hash the compiler's
# contents instead so hits survive a toolchain cache restore.
CCACHE_COMPILERCHECK: content
steps:
- name: Parse tag
if: startsWith(github.ref, 'refs/tags/')
id: tag
run: |
TAG="${GITHUB_REF_NAME}"
case "$TAG" in
pab-v3-*) PRODUCT="pab-v3"; VERSION="${TAG#pab-v3-}"; TARGET="PAB_V3" ;;
pab-*) PRODUCT="pab"; VERSION="${TAG#pab-}"; TARGET="PAB" ;;
jaj-*) PRODUCT="jaj"; VERSION="${TAG#jaj-}"; TARGET="JAJ" ;;
*) echo "::error::Unrecognized tag format: $TAG"; exit 1 ;;
esac
echo "product=$PRODUCT" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "target=$TARGET" >> "$GITHUB_OUTPUT"
echo "Parsed tag: product=$PRODUCT version=$VERSION target=$TARGET"
- uses: actions/checkout@v4
# Before the ~70 min build: a release without its changelog section never gets a draft
- name: Extract changelog
if: startsWith(github.ref, 'refs/tags/')
env:
VERSION: ${{ steps.tag.outputs.version }}
CHANGELOG: products/${{ steps.tag.outputs.target }}/CHANGELOG.md
run: |
awk -v version="$VERSION" '/^## /{in_section = ($2 == version)} in_section' "$CHANGELOG" > "$RUNNER_TEMP/CHANGELOG.md"
if [ ! -s "$RUNNER_TEMP/CHANGELOG.md" ]; then
echo "::error::$CHANGELOG has no '## $VERSION - <date>' section"
exit 1
fi
cat "$RUNNER_TEMP/CHANGELOG.md"
- name: Free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
- name: Stage build tree on /mnt
# staging/ (extracted rootfs + massflash images + the multi-GB mfi tarball)
# overran the ~49 GB free on / and crashed the runner with ENOSPC during
# packaging. The ephemeral /mnt has ~65 GB free and is otherwise unused, so
# build there. The final package stays in the workspace on /, where the
# publish step picks it up.
run: |
sudo mkdir -p /mnt/staging
sudo chown "$(id -u):$(id -g)" /mnt/staging
ln -s /mnt/staging staging
- name: Install prerequisites
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get update -qq
sudo -E apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
abootimg binfmt-support binutils ccache cpio cpp curl \
device-tree-compiler dosfstools \
iproute2 iputils-ping lbzip2 libxml2-utils lz4 \
netcat-openbsd nfs-kernel-server openssl \
pigz python3-yaml qemu-user-static rsync sshpass \
udev usbutils uuid-runtime whois xmlstarlet zstd
- name: Resolve cache keys from versions.env
id: cachekeys
run: |
source versions.env
echo "bsp=${EXPECTED_BSP_RELEASE}.${EXPECTED_BSP_REVISION}" >> "$GITHUB_OUTPUT"
echo "toolchain=$(basename "$TOOLCHAIN_URL")" >> "$GITHUB_OUTPUT"
- name: Cache cross toolchain
uses: actions/cache@v4
with:
path: ~/l4t-gcc
key: l4t-gcc-${{ steps.cachekeys.outputs.toolchain }}
# The L4T BSP/rootfs/sources tarballs (~2.7 GB) are pinned by BSP version, so
# cache them on it — setup.sh skips any tarball already present in downloads/.
- name: Cache L4T BSP tarballs
uses: actions/cache@v4
with:
path: downloads/*.tbz2
key: l4t-bsp-${{ steps.cachekeys.outputs.bsp }}
# ccache across runs (kernel C is mostly hits). Rotating per-run key so each
# run saves an updated cache; restore-keys pulls the most recent prior one.
- name: Cache ccache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.ccache
key: ccache-${{ steps.cachekeys.outputs.bsp }}-${{ github.run_id }}
restore-keys: |
ccache-${{ steps.cachekeys.outputs.bsp }}-
- name: Download BSP
run: ./setup.sh --force
- name: Reset ccache stats
run: ccache -z
- name: Build kernel
# Provisioning (ARK-OS + the pinned camera stack) is the build default now;
# tag builds keep --provision explicit for clarity. provision.sh falls back
# loudly to the newest published (pre)release if the pin isn't published. The
# draft ships a flashable, provisioned image; promote.yml releases it with no
# rebuild. PR/main builds only compile-check, so --no-provision skips the
# ~6 min provision and its NVIDIA/GitHub network deps.
run: |
if [ -n "${{ steps.tag.outputs.target }}" ]; then
./build.sh ${{ steps.tag.outputs.target }} --provision
else
./build.sh PAB --no-provision
fi
- name: ccache stats
if: always()
run: ccache -s
- name: Generate flash package
if: startsWith(github.ref, 'refs/tags/')
run: ./packaging/generate_flash_package.sh ${{ steps.tag.outputs.target }}
- uses: actions/checkout@v4
if: startsWith(github.ref, 'refs/tags/')
with:
repository: ARK-Electronics/downloads
path: ark-downloads
- uses: aws-actions/configure-aws-credentials@v4
if: startsWith(github.ref, 'refs/tags/')
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: us-west-1
mask-aws-account-id: true
# Every release is born an unlisted draft; promote.yml releases it after bench validation.
- name: Publish draft
if: startsWith(github.ref, 'refs/tags/')
env:
DOWNLOADS_BUCKET: ${{ vars.DOWNLOADS_BUCKET }}
PRODUCT: ${{ steps.tag.outputs.product }}
VERSION: ${{ steps.tag.outputs.version }}
run: |
mkdir draft
mv ark-*.tar.gz "$RUNNER_TEMP/CHANGELOG.md" draft/
(cd draft && sha256sum -- * > SHA256SUMS)
ark-downloads/downloads.py publish draft "dev/jetson/$PRODUCT/$VERSION"
echo "$VERSION" > "$RUNNER_TEMP/VERSION"
ark-downloads/downloads.py put "$RUNNER_TEMP/VERSION" "dev/jetson/$PRODUCT/draft/VERSION"
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
Draft: https://downloads.arkelectron.com/dev/jetson/$PRODUCT/$VERSION/ark-$PRODUCT-nvme-super.tar.gz
Flash: \`./flash_from_package.sh $GITHUB_REF_NAME\`, then after bench validation: \`gh workflow run promote.yml -f tag=$GITHUB_REF_NAME\`
EOF