Skip to content

Commit 3d39f31

Browse files
authored
Add better arch support + support ARM runners (#178)
1 parent 8eae99d commit 3d39f31

8 files changed

Lines changed: 485 additions & 114 deletions

File tree

.github/workflows/matrix.yml

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,24 @@ jobs:
4040
compression-level: 0
4141
- name: capture matrix
4242
id: capture-matrix
43-
run: >
44-
echo "matrix=$(cat matrix.json)" >> "${GITHUB_OUTPUT}"
43+
run: |
44+
# Split matrix.json into two strategy-matrix-shaped outputs: one keyed
45+
# on `builds` (per-arch build jobs) and one on `merges` (per
46+
# (version, flavor) manifest-list assembly jobs). Each iteration of the
47+
# build job sees matrix.builds.* and each merge sees matrix.merges.*.
48+
BUILDS=$(jq -c '{builds: .builds}' matrix.json)
49+
MERGES=$(jq -c '{merges: .merges}' matrix.json)
50+
echo "builds=${BUILDS}" >> "${GITHUB_OUTPUT}"
51+
echo "merges=${MERGES}" >> "${GITHUB_OUTPUT}"
4552
outputs:
46-
matrix: "${{ steps.capture-matrix.outputs.matrix }}"
53+
builds: "${{ steps.capture-matrix.outputs.builds }}"
54+
merges: "${{ steps.capture-matrix.outputs.merges }}"
4755
build:
48-
name: "build ${{ matrix.builds.version }} ${{ matrix.builds.flavor }}"
56+
name: "build ${{ matrix.builds.version }} ${{ matrix.builds.flavor }} ${{ matrix.builds.arch }}"
4957
needs: matrix
5058
strategy:
5159
fail-fast: false
52-
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
60+
matrix: ${{ fromJSON(needs.matrix.outputs.builds) }}
5361
runs-on: "${{ matrix.builds.runner }}"
5462
env:
5563
KERNEL_PUBLISH: "${{ inputs.publish }}"
@@ -59,7 +67,7 @@ jobs:
5967
FIRMWARE_SIG_URL: "${{ matrix.builds.firmware_sig_url }}"
6068
KERNEL_FLAVOR: "${{ matrix.builds.flavor }}"
6169
KERNEL_TAGS: "${{ join(matrix.builds.tags, ',') }}"
62-
KERNEL_ARCHITECTURES: "${{ join(matrix.builds.architectures, ',') }}"
70+
KERNEL_ARCH: "${{ matrix.builds.arch }}"
6371
steps:
6472
- name: Harden the runner (Audit all outbound calls)
6573
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
@@ -91,24 +99,87 @@ jobs:
9199
# restore-keys is important here - it lets us restore the most recent cache key,
92100
# *ignoring* the specific run ID, as a fuzzy match. So we can use previous build's
93101
# caches for this flavor/arch even if the runid is not the same
94-
key: "ccache-${{ matrix.builds.flavor }}-${{ join(matrix.builds.architectures, '-') }}-${{ github.run_id }}"
102+
key: "ccache-${{ matrix.builds.flavor }}-${{ matrix.builds.arch }}-${{ github.run_id }}"
95103
restore-keys: |
96-
ccache-${{ matrix.builds.flavor }}-${{ join(matrix.builds.architectures, '-') }}-
104+
ccache-${{ matrix.builds.flavor }}-${{ matrix.builds.arch }}-
97105
- name: generate docker script
98106
run: "./hack/build/generate-docker-script.sh"
99107
- name: upload docker script
100108
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
101109
with:
102-
name: "build-${{ matrix.builds.version }}-${{ matrix.builds.flavor }}.sh"
110+
name: "build-${{ matrix.builds.version }}-${{ matrix.builds.flavor }}-${{ matrix.builds.arch }}.sh"
103111
path: "docker.sh"
104112
compression-level: 0
105113
- name: run docker script
106114
run: sh -x docker.sh
115+
- name: upload digests
116+
# Only produced when publishing — push-by-digest path writes digests.json.
117+
if: ${{ inputs.publish }}
118+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
119+
with:
120+
name: "digests-${{ matrix.builds.version }}-${{ matrix.builds.flavor }}-${{ matrix.builds.arch }}"
121+
path: "digests.json"
122+
if-no-files-found: error
123+
compression-level: 0
124+
retention-days: 1
107125
- name: save ccache
108126
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.2
109127
with:
110128
path: ~/.cache/kernel-ccache
111129
# The run_id here is just for write-key uniqueness, as GH doesn't allow overwriting
112130
# existing cache keys - the `restore` action will fuzzy-match and ignore the run_id
113131
# for subsequent runs.
114-
key: "ccache-${{ matrix.builds.flavor }}-${{ join(matrix.builds.architectures, '-') }}-${{ github.run_id }}"
132+
key: "ccache-${{ matrix.builds.flavor }}-${{ matrix.builds.arch }}-${{ github.run_id }}"
133+
merge:
134+
# Stitch the per-arch single-platform pushes from `build` into multi-arch
135+
# manifest lists. Only runs when publishing; no-op when nothing was pushed.
136+
name: "merge ${{ matrix.merges.version }} ${{ matrix.merges.flavor }}"
137+
needs: [matrix, build]
138+
if: ${{ inputs.publish && needs.matrix.outputs.merges != '' }}
139+
strategy:
140+
fail-fast: false
141+
matrix: ${{ fromJSON(needs.matrix.outputs.merges) }}
142+
runs-on: ubuntu-latest
143+
env:
144+
KERNEL_PUBLISH: "${{ inputs.publish }}"
145+
KERNEL_VERSION: "${{ matrix.merges.version }}"
146+
KERNEL_FLAVOR: "${{ matrix.merges.flavor }}"
147+
KERNEL_PRODUCES: "${{ join(matrix.merges.produces, ',') }}"
148+
DIGESTS_DIR: digests
149+
steps:
150+
- name: Harden the runner (Audit all outbound calls)
151+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
152+
with:
153+
egress-policy: audit
154+
- name: checkout repository
155+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
156+
- name: install cosign
157+
uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.1
158+
- name: docker setup buildx
159+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
160+
- name: docker login ghcr.io
161+
uses: Wandalen/wretry.action@e68c23e6309f2871ca8ae4763e7629b9c258e1ea # v3.8.0
162+
with:
163+
action: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
164+
with: |
165+
registry: ghcr.io
166+
username: "${{github.actor}}"
167+
password: "${{secrets.GITHUB_TOKEN}}"
168+
- name: download digest artifacts
169+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
170+
with:
171+
# Each per-arch build uploads its digests under a uniquely-named
172+
# artifact; pattern + default merge-multiple=false drops each artifact
173+
# into its own subdirectory under digests/.
174+
pattern: "digests-${{ matrix.merges.version }}-${{ matrix.merges.flavor }}-*"
175+
path: digests
176+
- name: generate merge script
177+
run: python3 ./hack/build/generate-merge-script.py
178+
- name: upload merge script
179+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
180+
with:
181+
name: "merge-${{ matrix.merges.version }}-${{ matrix.merges.flavor }}.sh"
182+
path: "merge.sh"
183+
compression-level: 0
184+
- name: run merge script
185+
run: sh -x merge.sh

config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
imageNameFormat: "ghcr.io/edera-dev/[image]:[tag]"
2+
# Default set of architectures applied to any flavor that does not override it.
23
architectures:
34
- x86_64
45
flavors:
56
- name: zone
7+
# zone is the only flavor we currently publish for aarch64. Other flavors fall
8+
# back to the global `architectures` list above; add an `architectures:` entry
9+
# here to opt them in.
10+
architectures:
11+
- x86_64
12+
- aarch64
613
constraints:
714
lower: '6.1'
815
- name: zone-amdgpu
@@ -103,9 +110,14 @@ images:
103110
name: "[flavor]-kernel-sdk"
104111
format: kernel.sdk
105112
runners:
113+
# Match order matters: first runner whose constraints match wins.
114+
- name: ubuntu-24.04-arm
115+
arch: aarch64
106116
- name: edera-large
117+
arch: x86_64
107118
flavors:
108119
- host
109120
- zone-amdgpu
110121
- zone-nvidiagpu
111122
- name: ubuntu-latest
123+
arch: x86_64

0 commit comments

Comments
 (0)