Skip to content

Commit 0b8e4a5

Browse files
committed
Multiarch for Ron
Signed off by: G.R. Emlin <[email protected]>
1 parent a5f263c commit 0b8e4a5

File tree

6 files changed

+797
-224
lines changed

6 files changed

+797
-224
lines changed

.github/workflows/build.yml

Lines changed: 207 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ on:
1616
description: 'Release tag (e.g., v1.0.0)'
1717
required: false
1818
type: string
19+
architectures:
20+
description: 'Architectures to build (comma-separated: aarch64,x86_64)'
21+
required: false
22+
default: 'aarch64,x86_64'
23+
type: string
1924
schedule:
2025
# Run weekly on Sundays at 00:00 UTC to check for new cpu releases
2126
- cron: '0 0 * * 0'
@@ -27,6 +32,10 @@ jobs:
2732
contents: write
2833
packages: write
2934

35+
strategy:
36+
matrix:
37+
arch: [aarch64, x86_64]
38+
3039
steps:
3140
- name: Checkout repository
3241
uses: actions/checkout@v4
@@ -38,29 +47,29 @@ jobs:
3847

3948
- name: Build everything using Makefile
4049
run: |
41-
echo "Building CPU binaries and initramfs using Makefile..."
42-
make all
43-
echo "Build completed successfully!"
50+
echo "Building CPU binaries and initramfs for ${{ matrix.arch }} using Makefile..."
51+
make ARCH=${{ matrix.arch }} all
52+
echo "Build completed successfully for ${{ matrix.arch }}!"
4453
4554
- name: Show build summary
4655
run: |
47-
echo "=== Build Summary ==="
48-
ls -la build/binaries/
56+
echo "=== Build Summary for ${{ matrix.arch }} ==="
57+
ls -la build/binaries/${{ matrix.arch }}/
4958
echo ""
5059
echo "Binary info:"
51-
file build/binaries/cpu build/binaries/cpud
60+
file build/binaries/${{ matrix.arch }}/cpu build/binaries/${{ matrix.arch }}/cpud
5261
echo ""
5362
echo "SSH keys:"
54-
ls -la build/binaries/identity*
63+
ls -la build/binaries/${{ matrix.arch }}/identity*
5564
echo ""
5665
echo "Initramfs:"
57-
ls -la build/initramfs/
66+
ls -la build/initramfs/${{ matrix.arch }}/
5867
echo ""
5968
echo "Sizes:"
60-
du -h build/binaries/* build/initramfs/*
69+
du -h build/binaries/${{ matrix.arch }}/* build/initramfs/${{ matrix.arch }}/*
6170
echo ""
6271
echo "Build info:"
63-
cat build/binaries/BUILD_INFO.txt
72+
cat build/binaries/${{ matrix.arch }}/BUILD_INFO.txt
6473
6574
- name: Get CPU version for release naming
6675
run: |
@@ -70,100 +79,234 @@ jobs:
7079
7180
- name: Create checksums
7281
run: |
73-
cd build/binaries
74-
echo "Creating checksums..."
82+
cd build/binaries/${{ matrix.arch }}
83+
echo "Creating checksums for ${{ matrix.arch }}..."
7584
sha256sum cpu > cpu.sha256
7685
sha256sum cpud > cpud.sha256
7786
sha256sum identity > identity.sha256
7887
sha256sum identity.pub > identity.pub.sha256
7988
sha256sum BUILD_INFO.txt > BUILD_INFO.txt.sha256
80-
cd ../initramfs
89+
cd ../../initramfs/${{ matrix.arch }}
8190
sha256sum cpud-initramfs.cpio.gz > cpud-initramfs.cpio.gz.sha256
82-
cd ../binaries
91+
cd ../../binaries/${{ matrix.arch }}
8392
echo "Checksums created:"
8493
cat *.sha256
8594
echo "Initramfs checksum:"
86-
cat ../initramfs/*.sha256
95+
cat ../../initramfs/${{ matrix.arch }}/*.sha256
8796
8897
- name: Create tarball
8998
run: |
90-
cd build/binaries
91-
cp ../initramfs/cpud-initramfs.cpio.gz .
92-
cp ../initramfs/cpud-initramfs.cpio.gz.sha256 .
93-
tar -czf ../../cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz *
94-
cd ../..
99+
cd build/binaries/${{ matrix.arch }}
100+
cp ../../initramfs/${{ matrix.arch }}/cpud-initramfs.cpio.gz .
101+
cp ../../initramfs/${{ matrix.arch }}/cpud-initramfs.cpio.gz.sha256 .
102+
tar -czf ../../../cpu-binaries-${{ matrix.arch }}-${{ env.CPU_VERSION }}.tar.gz *
103+
cd ../../..
95104
echo "Tarball created:"
96-
ls -la cpu-binaries-aarch64-*.tar.gz
97-
sha256sum cpu-binaries-aarch64-*.tar.gz > cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz.sha256
105+
ls -la cpu-binaries-${{ matrix.arch }}-*.tar.gz
106+
sha256sum cpu-binaries-${{ matrix.arch }}-*.tar.gz > cpu-binaries-${{ matrix.arch }}-${{ env.CPU_VERSION }}.tar.gz.sha256
98107
99108
- name: Upload binaries as artifact
100109
uses: actions/upload-artifact@v4
101110
with:
102-
name: cpu-binaries-aarch64-${{ env.CPU_VERSION }}
111+
name: cpu-binaries-${{ matrix.arch }}-${{ env.CPU_VERSION }}
103112
path: |
104-
build/binaries/
105-
build/initramfs/
106-
cpu-binaries-aarch64-*.tar.gz
107-
cpu-binaries-aarch64-*.tar.gz.sha256
113+
build/binaries/${{ matrix.arch }}/
114+
build/initramfs/${{ matrix.arch }}/
115+
cpu-binaries-${{ matrix.arch }}-*.tar.gz
116+
cpu-binaries-${{ matrix.arch }}-*.tar.gz.sha256
108117
retention-days: 90
118+
119+
release:
120+
needs: build
121+
runs-on: ubuntu-latest
122+
permissions:
123+
contents: write
124+
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true'
125+
126+
steps:
127+
- name: Download artifacts
128+
uses: actions/download-artifact@v4
129+
with:
130+
pattern: cpu-binaries-*
131+
merge-multiple: false
132+
133+
- name: Get CPU version for release naming
134+
run: |
135+
# Extract version from any artifact directory
136+
for dir in cpu-binaries-*; do
137+
if [ -d "$dir" ]; then
138+
version=$(echo "$dir" | sed 's/cpu-binaries-[^-]*-//')
139+
echo "CPU_VERSION=$version" >> $GITHUB_ENV
140+
break
141+
fi
142+
done
143+
echo "Detected CPU_VERSION: ${{ env.CPU_VERSION }}"
144+
145+
- name: Prepare release files for all architectures
146+
run: |
147+
echo "Preparing release files for all architectures..."
148+
149+
# Create release structure
150+
mkdir -p release-files
151+
152+
# Process each architecture
153+
for arch in aarch64 x86_64; do
154+
echo "Processing $arch..."
155+
artifact_dir="cpu-binaries-$arch-${{ env.CPU_VERSION }}"
156+
157+
if [ -d "$artifact_dir" ]; then
158+
echo "Found artifact directory: $artifact_dir"
159+
160+
# Copy binaries with arch suffix to avoid conflicts
161+
if [ -d "$artifact_dir/build/binaries/$arch" ]; then
162+
mkdir -p "release-files/$arch"
163+
cp -r "$artifact_dir/build/binaries/$arch"/* "release-files/$arch/"
164+
165+
# Create symlinks for architecture-specific binaries in root
166+
cd release-files
167+
ln -sf "$arch/cpu" "cpu-$arch"
168+
ln -sf "$arch/cpud" "cpud-$arch"
169+
ln -sf "$arch/identity" "identity-$arch"
170+
ln -sf "$arch/identity.pub" "identity.pub-$arch"
171+
ln -sf "$arch/BUILD_INFO.txt" "BUILD_INFO-$arch.txt"
172+
ln -sf "$arch/cpu.sha256" "cpu-$arch.sha256"
173+
ln -sf "$arch/cpud.sha256" "cpud-$arch.sha256"
174+
ln -sf "$arch/identity.sha256" "identity-$arch.sha256"
175+
ln -sf "$arch/identity.pub.sha256" "identity.pub-$arch.sha256"
176+
ln -sf "$arch/BUILD_INFO.txt.sha256" "BUILD_INFO-$arch.txt.sha256"
177+
cd ..
178+
fi
179+
180+
# Copy initramfs with arch suffix
181+
if [ -d "$artifact_dir/build/initramfs/$arch" ]; then
182+
cp "$artifact_dir/build/initramfs/$arch"/* "release-files/$arch/"
183+
cd release-files
184+
ln -sf "$arch/cpud-initramfs.cpio.gz" "cpud-initramfs-$arch.cpio.gz"
185+
ln -sf "$arch/cpud-initramfs.cpio.gz.sha256" "cpud-initramfs-$arch.cpio.gz.sha256"
186+
cd ..
187+
fi
188+
189+
# Copy tarball
190+
if [ -f "$artifact_dir/cpu-binaries-$arch-${{ env.CPU_VERSION }}.tar.gz" ]; then
191+
cp "$artifact_dir/cpu-binaries-$arch-${{ env.CPU_VERSION }}.tar.gz" release-files/
192+
cp "$artifact_dir/cpu-binaries-$arch-${{ env.CPU_VERSION }}.tar.gz.sha256" release-files/
193+
fi
194+
else
195+
echo "Warning: Artifact directory $artifact_dir not found"
196+
fi
197+
done
198+
199+
echo "Release files prepared:"
200+
find release-files/ -type f | sort
109201
110202
- name: Create release (manual or on tag)
111-
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true'
112203
uses: softprops/action-gh-release@v2
113204
with:
114205
tag_name: ${{ github.event.inputs.release_tag || github.ref_name }}
115206
name: CPU Binaries ${{ github.event.inputs.release_tag || github.ref_name }}
116207
files: |
117-
build/binaries/cpu
118-
build/binaries/cpud
119-
build/binaries/identity
120-
build/binaries/identity.pub
121-
build/binaries/BUILD_INFO.txt
122-
build/binaries/cpu.sha256
123-
build/binaries/cpud.sha256
124-
build/binaries/identity.sha256
125-
build/binaries/identity.pub.sha256
126-
build/binaries/BUILD_INFO.txt.sha256
127-
build/binaries/cpud-initramfs.cpio.gz
128-
build/binaries/cpud-initramfs.cpio.gz.sha256
129-
cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz
130-
cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz.sha256
208+
release-files/cpu-aarch64
209+
release-files/cpud-aarch64
210+
release-files/cpu-x86_64
211+
release-files/cpud-x86_64
212+
release-files/identity-aarch64
213+
release-files/identity.pub-aarch64
214+
release-files/identity-x86_64
215+
release-files/identity.pub-x86_64
216+
release-files/BUILD_INFO-aarch64.txt
217+
release-files/BUILD_INFO-x86_64.txt
218+
release-files/cpu-aarch64.sha256
219+
release-files/cpud-aarch64.sha256
220+
release-files/cpu-x86_64.sha256
221+
release-files/cpud-x86_64.sha256
222+
release-files/identity-aarch64.sha256
223+
release-files/identity.pub-aarch64.sha256
224+
release-files/identity-x86_64.sha256
225+
release-files/identity.pub-x86_64.sha256
226+
release-files/BUILD_INFO-aarch64.txt.sha256
227+
release-files/BUILD_INFO-x86_64.txt.sha256
228+
release-files/cpud-initramfs-aarch64.cpio.gz
229+
release-files/cpud-initramfs-aarch64.cpio.gz.sha256
230+
release-files/cpud-initramfs-x86_64.cpio.gz
231+
release-files/cpud-initramfs-x86_64.cpio.gz.sha256
232+
release-files/cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz
233+
release-files/cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz.sha256
234+
release-files/cpu-binaries-x86_64-${{ env.CPU_VERSION }}.tar.gz
235+
release-files/cpu-binaries-x86_64-${{ env.CPU_VERSION }}.tar.gz.sha256
131236
body: |
132-
# CPU Binaries for aarch64 (ARM64)
237+
# CPU Binaries for Multiple Architectures
133238
134239
Built from [u-root/cpu](https://github.com/u-root/cpu) version: `${{ env.CPU_VERSION }}`
135240
241+
## Supported Architectures
242+
243+
- **aarch64** (ARM64) - For Raspberry Pi, Apple Silicon, AWS Graviton, etc.
244+
- **x86_64** (AMD64) - For Intel/AMD x86-64 systems
245+
136246
## Files
137247
138-
### Individual Binaries
139-
- `cpu` - CPU client binary for aarch64
140-
- `cpud` - CPU daemon binary for aarch64
141-
- `BUILD_INFO.txt` - Build information and usage notes
142-
- `*.sha256` - SHA256 checksums for verification
248+
### Architecture-Specific Binaries
249+
Download the binaries for your target architecture:
143250
144-
### SSH Keys
145-
- `identity` - Default SSH private key
146-
- `identity.pub` - Default SSH public key (also embedded in initramfs)
147-
- `identity.sha256` - Private key checksum
148-
- `identity.pub.sha256` - Public key checksum
251+
#### aarch64 (ARM64)
252+
- `cpu-aarch64` - CPU client binary for aarch64
253+
- `cpud-aarch64` - CPU daemon binary for aarch64
254+
- `cpud-initramfs-aarch64.cpio.gz` - U-root initramfs for aarch64
255+
- `cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz` - Complete archive for aarch64
149256
150-
**⚠️ WARNING**: These are default keys for convenience. Generate your own keys for production use!
257+
#### x86_64 (AMD64)
258+
- `cpu-x86_64` - CPU client binary for x86_64
259+
- `cpud-x86_64` - CPU daemon binary for x86_64
260+
- `cpud-initramfs-x86_64.cpio.gz` - U-root initramfs for x86_64
261+
- `cpu-binaries-x86_64-${{ env.CPU_VERSION }}.tar.gz` - Complete archive for x86_64
151262
152-
### Initramfs
153-
- `cpud-initramfs.cpio.gz` - U-root initramfs with cpud as init
154-
- `cpud-initramfs.cpio.gz.sha256` - Initramfs checksum
263+
### SSH Keys (per architecture)
264+
- `identity-<arch>` - Default SSH private key
265+
- `identity.pub-<arch>` - Default SSH public key (also embedded in initramfs)
266+
- `identity-<arch>.sha256` - Private key checksum
267+
- `identity.pub-<arch>.sha256` - Public key checksum
155268
156-
The initramfs includes the SSH public key at `/etc/identity.pub` and cpud automatically uses it for authentication.
269+
**⚠️ WARNING**: These are default keys for convenience. Generate your own keys for production use!
157270
158-
### Archive
159-
- `cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz` - Complete archive with all binaries
160-
- `cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz.sha256` - Archive checksum
271+
### Build Information
272+
- `BUILD_INFO-<arch>.txt` - Build information and usage notes (per architecture)
273+
- `*-<arch>.sha256` - SHA256 checksums for verification
161274
162275
## Usage
163276
164-
Download and use the complete archive, or individual binaries as needed.
165-
Use the initramfs with Linux kernel (boot parameters: init=/init).
166-
SSH public key is embedded at /etc/identity.pub for automatic authentication.
277+
1. **Download** the appropriate binaries for your target architecture
278+
2. **Rename** to remove architecture suffix: `mv cpu-aarch64 cpu`
279+
3. **Verify** checksums with `sha256sum -c <file>.sha256`
280+
4. **Make executable** with `chmod +x cpu cpud`
281+
5. **Use initramfs** with Linux kernel (boot parameters: `init=/init`)
282+
283+
## Multi-Architecture Support
284+
285+
This release includes binaries for multiple architectures built from the same source code.
286+
Choose the appropriate architecture for your target system:
287+
288+
- **aarch64**: Raspberry Pi, Apple Silicon Macs, AWS Graviton instances
289+
- **x86_64**: Intel/AMD desktop/server systems, most cloud instances
290+
291+
SSH public keys are embedded in each architecture's initramfs at `/etc/identity.pub` for automatic authentication.
292+
293+
## Quick Start
294+
295+
### For aarch64 systems:
296+
```bash
297+
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpu-aarch64
298+
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpud-aarch64
299+
mv cpu-aarch64 cpu && mv cpud-aarch64 cpud
300+
chmod +x cpu cpud
301+
```
302+
303+
### For x86_64 systems:
304+
```bash
305+
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpu-x86_64
306+
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpud-x86_64
307+
mv cpu-x86_64 cpu && mv cpud-x86_64 cpud
308+
chmod +x cpu cpud
309+
```
167310
draft: false
168311
prerelease: false
169312
make_latest: true

0 commit comments

Comments
 (0)