Skip to content

Commit 0015a6c

Browse files
committed
Get actions to just use Makefile
1 parent 62947c5 commit 0015a6c

File tree

2 files changed

+41
-294
lines changed

2 files changed

+41
-294
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 241 deletions
Original file line numberDiff line numberDiff line change
@@ -36,136 +36,37 @@ jobs:
3636
with:
3737
go-version: '1.21'
3838

39-
- name: Clone u-root/cpu repository
39+
- name: Build everything using Makefile
4040
run: |
41-
mkdir -p build/repos
42-
git clone https://github.com/u-root/cpu.git build/repos/cpu
43-
cd build/repos/cpu
44-
echo "CPU_VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
45-
echo "Building u-root/cpu version: $(git describe --tags --always)"
46-
47-
- name: Clone u-root/u-root repository
48-
run: |
49-
git clone https://github.com/u-root/u-root.git build/repos/u-root
50-
51-
- name: Set up Go workspace
52-
run: |
53-
cat > build/go.work << EOF
54-
go 1.24.0
55-
56-
use ./repos/cpu
57-
use ./repos/u-root
58-
EOF
41+
echo "Building CPU binaries and initramfs using Makefile..."
42+
make all
43+
echo "Build completed successfully!"
5944
60-
- name: Install dependencies
61-
run: |
62-
cd build/repos/cpu
63-
go mod download
64-
# Build u-root from source
65-
echo "Building u-root from source..."
66-
cd ../u-root
67-
go build -o ../../u-root-bin ./
68-
cd ../cpu
69-
70-
- name: Generate SSH keys
71-
run: |
72-
mkdir -p build/binaries
73-
echo "Generating default SSH keys for CPU..."
74-
ssh-keygen -t rsa -b 4096 -f build/binaries/identity -N "" -C "cpu-default-key"
75-
echo "SSH keys generated:"
76-
echo " Private key: build/binaries/identity"
77-
echo " Public key: build/binaries/identity.pub"
78-
ls -la build/binaries/identity*
79-
80-
- name: Build cpu binary for aarch64
45+
- name: Show build summary
8146
run: |
82-
cd build/repos/cpu
83-
mkdir -p ../../binaries
84-
echo "Building cpu binary..."
85-
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ../../binaries/cpu ./cmds/cpu
86-
echo "cpu binary built successfully"
87-
file ../../binaries/cpu
88-
89-
- name: Build cpud binary for aarch64
90-
run: |
91-
cd build/repos/cpu
92-
echo "Building cpud binary..."
93-
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ../../binaries/cpud ./cmds/cpud
94-
echo "cpud binary built successfully"
95-
file ../../binaries/cpud
96-
97-
- name: Create u-root initramfs with cpud
98-
run: |
99-
cd build/repos/cpu
100-
echo "Creating u-root initramfs with cpud as init..."
101-
mkdir -p ../../initramfs
102-
103-
# Build the initramfs with cpud bundled in as init and include SSH public key
104-
echo "Building initramfs with u-root..."
105-
GOOS=linux GOARCH=arm64 ../../u-root-bin -format=cpio -o ../../initramfs/cpud-initramfs.cpio \
106-
-files "../../binaries/identity.pub:etc/identity.pub" \
107-
-initcmd="cpud" \
108-
./cmds/cpud \
109-
../u-root/cmds/core/ls \
110-
../u-root/cmds/core/ip \
111-
../u-root/cmds/core/mount \
112-
../u-root/cmds/core/mkdir \
113-
../u-root/cmds/core/gosh
114-
115-
echo "Compressing initramfs..."
116-
gzip -9 ../../initramfs/cpud-initramfs.cpio
117-
118-
echo "Initramfs created successfully:"
119-
ls -la ../../initramfs/
120-
file ../../initramfs/cpud-initramfs.cpio.gz
121-
122-
- name: Verify binaries
123-
run: |
124-
echo "Verifying built binaries..."
47+
echo "=== Build Summary ==="
12548
ls -la build/binaries/
126-
echo "CPU binary info:"
127-
file build/binaries/cpu
128-
echo "CPUD binary info:"
129-
file build/binaries/cpud
130-
echo "Binary sizes:"
131-
du -h build/binaries/*
132-
echo
133-
echo "Initramfs info:"
49+
echo ""
50+
echo "Binary info:"
51+
file build/binaries/cpu build/binaries/cpud
52+
echo ""
53+
echo "SSH keys:"
54+
ls -la build/binaries/identity*
55+
echo ""
56+
echo "Initramfs:"
13457
ls -la build/initramfs/
135-
echo "Initramfs size:"
136-
du -h build/initramfs/*
137-
138-
- name: Create build info
58+
echo ""
59+
echo "Sizes:"
60+
du -h build/binaries/* build/initramfs/*
61+
echo ""
62+
echo "Build info:"
63+
cat build/binaries/BUILD_INFO.txt
64+
65+
- name: Get CPU version for release naming
13966
run: |
140-
cd build/binaries
141-
echo "U-Root CPU Binaries for aarch64" > BUILD_INFO.txt
142-
echo "Built on: $(date -u)" >> BUILD_INFO.txt
143-
echo "CPU version: $CPU_VERSION" >> BUILD_INFO.txt
144-
echo "Target architecture: linux/arm64" >> BUILD_INFO.txt
145-
echo "Go version: $(go version)" >> BUILD_INFO.txt
146-
echo "" >> BUILD_INFO.txt
147-
echo "Files in this archive:" >> BUILD_INFO.txt
148-
echo "- cpu: CPU client binary" >> BUILD_INFO.txt
149-
echo "- cpud: CPU daemon binary" >> BUILD_INFO.txt
150-
echo "- identity: Default SSH private key" >> BUILD_INFO.txt
151-
echo "- identity.pub: Default SSH public key" >> BUILD_INFO.txt
152-
echo "- cpud-initramfs.cpio.gz: U-root initramfs with cpud as init" >> BUILD_INFO.txt
153-
echo "" >> BUILD_INFO.txt
154-
echo "Usage:" >> BUILD_INFO.txt
155-
echo " ./cpu -h # Show CPU client help" >> BUILD_INFO.txt
156-
echo " ./cpud -h # Show CPU daemon help" >> BUILD_INFO.txt
157-
echo "" >> BUILD_INFO.txt
158-
echo "SSH Keys:" >> BUILD_INFO.txt
159-
echo " Default SSH keys are provided for convenience" >> BUILD_INFO.txt
160-
echo " Private key: identity" >> BUILD_INFO.txt
161-
echo " Public key: identity.pub (also embedded in initramfs)" >> BUILD_INFO.txt
162-
echo " WARNING: These are default keys - generate your own for production!" >> BUILD_INFO.txt
163-
echo "" >> BUILD_INFO.txt
164-
echo "Initramfs usage:" >> BUILD_INFO.txt
165-
echo " Use cpud-initramfs.cpio.gz as initrd with Linux kernel" >> BUILD_INFO.txt
166-
echo " Boot parameters: init=/init" >> BUILD_INFO.txt
167-
echo " SSH public key is embedded at /etc/identity.pub" >> BUILD_INFO.txt
168-
cat BUILD_INFO.txt
67+
cd build/repos/cpu
68+
echo "CPU_VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
69+
echo "Building u-root/cpu version: $(git describe --tags --always)"
16970
17071
- name: Create checksums
17172
run: |
@@ -206,34 +107,6 @@ jobs:
206107
cpu-binaries-aarch64-*.tar.gz.sha256
207108
retention-days: 90
208109

209-
- name: Debug files for release
210-
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true'
211-
run: |
212-
echo "=== DEBUG: Files that should be in release ==="
213-
echo "Working directory: $(pwd)"
214-
echo "CPU_VERSION: ${{ env.CPU_VERSION }}"
215-
echo "GitHub ref: ${{ github.ref }}"
216-
echo "GitHub ref_name: ${{ github.ref_name }}"
217-
echo "startsWith condition: ${{ startsWith(github.ref, 'refs/tags/') }}"
218-
echo "create_release input: ${{ github.event.inputs.create_release }}"
219-
echo
220-
echo "Binaries directory:"
221-
ls -la build/binaries/ || echo "build/binaries/ directory not found"
222-
echo
223-
echo "Initramfs directory:"
224-
ls -la build/initramfs/ || echo "build/initramfs/ directory not found"
225-
echo
226-
echo "Tarball files:"
227-
ls -la cpu-binaries-aarch64-*.tar.gz || echo "No tarball files found"
228-
ls -la cpu-binaries-aarch64-*.tar.gz.sha256 || echo "No tarball checksum files found"
229-
echo
230-
echo "Checking specific files for release:"
231-
[ -f "build/binaries/cpu" ] && echo "✓ build/binaries/cpu exists" || echo "✗ build/binaries/cpu missing"
232-
[ -f "build/binaries/cpud" ] && echo "✓ build/binaries/cpud exists" || echo "✗ build/binaries/cpud missing"
233-
[ -f "build/binaries/BUILD_INFO.txt" ] && echo "✓ build/binaries/BUILD_INFO.txt exists" || echo "✗ build/binaries/BUILD_INFO.txt missing"
234-
[ -f "build/binaries/cpud-initramfs.cpio.gz" ] && echo "✓ build/binaries/cpud-initramfs.cpio.gz exists" || echo "✗ build/binaries/cpud-initramfs.cpio.gz missing"
235-
[ -f "cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz" ] && echo "✓ tarball exists" || echo "✗ tarball missing"
236-
237110
- name: Create release (manual or on tag)
238111
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.create_release == 'true'
239112
uses: softprops/action-gh-release@v2
@@ -280,102 +153,20 @@ jobs:
280153
- `cpud-initramfs.cpio.gz` - U-root initramfs with cpud as init
281154
- `cpud-initramfs.cpio.gz.sha256` - Initramfs checksum
282155
283-
The initramfs includes the SSH public key at `/etc/identity.pub` for automatic authentication.
156+
The initramfs includes the SSH public key at `/etc/identity.pub` and cpud automatically uses it for authentication.
284157
285158
### Archive
286159
- `cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz` - Complete archive with all binaries
287160
- `cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz.sha256` - Archive checksum
288161
289-
## Installation
290-
291-
### Download individual binaries:
292-
```bash
293-
# Download binaries and keys
294-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpu
295-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpud
296-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/identity
297-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/identity.pub
298-
299-
# Make executable
300-
chmod +x cpu cpud
301-
chmod 600 identity
302-
chmod 644 identity.pub
303-
304-
# Verify (optional)
305-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpu.sha256
306-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpud.sha256
307-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/identity.sha256
308-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/identity.pub.sha256
309-
sha256sum -c cpu.sha256
310-
sha256sum -c cpud.sha256
311-
sha256sum -c identity.sha256
312-
sha256sum -c identity.pub.sha256
313-
```
314-
315-
### Download complete archive:
316-
```bash
317-
# Download and verify archive
318-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz
319-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz.sha256
320-
sha256sum -c cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz.sha256
321-
322-
# Extract
323-
tar -xzf cpu-binaries-aarch64-${{ env.CPU_VERSION }}.tar.gz
324-
chmod +x cpu cpud
325-
```
326-
327-
## Initramfs Usage
328-
329-
Use the initramfs to boot a system with cpud as init:
330-
331-
```bash
332-
# Download initramfs
333-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpud-initramfs.cpio.gz
334-
335-
# Verify checksum
336-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpud-initramfs.cpio.gz.sha256
337-
sha256sum -c cpud-initramfs.cpio.gz.sha256
338-
339-
# Use with kernel (example with qemu)
340-
qemu-system-aarch64 \
341-
-kernel vmlinuz \
342-
-initrd cpud-initramfs.cpio.gz \
343-
-append "init=/init" \
344-
-machine virt \
345-
-cpu cortex-a57 \
346-
-m 1024M
347-
```
348-
349-
## Raspberry Pi Usage
350-
351-
Use the initramfs to boot a Raspberry Pi directly into cpud:
352-
353-
```bash
354-
# Download initramfs to your Pi's boot partition
355-
wget https://github.com/${{ github.repository }}/releases/download/${{ github.event.inputs.release_tag || github.ref_name }}/cpud-initramfs.cpio.gz
356-
sudo cp cpud-initramfs.cpio.gz /boot/firmware/
357-
358-
# Edit config.txt (Pi 4/5) or boot/config.txt (older Pi)
359-
sudo nano /boot/firmware/config.txt
360-
361-
# Add these lines:
362-
initramfs cpud-initramfs.cpio.gz followkernel
363-
364-
# Edit cmdline.txt to set init
365-
sudo nano /boot/firmware/cmdline.txt
366-
# Add: init=/init
367-
# Example: console=serial0,115200 console=tty1 root=PARTUUID=12345678-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/init
368-
369-
# Reboot - Pi will boot directly into cpud
370-
sudo reboot
371-
```
372-
373162
## Usage
374-
```bash
375-
./cpu -h # Show CPU client help
376-
./cpud -h # Show CPU daemon help
377-
```
163+
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.
378167
draft: false
379168
prerelease: false
169+
make_latest: true
170+
generate_release_notes: true
380171
env:
381172
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/package.yml

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -47,78 +47,34 @@ jobs:
4747
4848
- name: Set up Go
4949
uses: actions/setup-go@v5
50-
with:
51-
go-version: '1.21'
5250

53-
- name: Clone u-root/cpu repository
51+
- name: Get CPU version for metadata
5452
run: |
55-
git clone https://github.com/u-root/cpu.git
56-
cd cpu
53+
cd build/repos/cpu
5754
echo "CPU_VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
58-
59-
- name: Generate SSH keys
60-
run: |
61-
mkdir -p binaries
62-
echo "Generating default SSH keys for CPU..."
63-
ssh-keygen -t rsa -b 4096 -f binaries/identity -N "" -C "cpu-default-key"
64-
echo "SSH keys generated:"
65-
ls -la binaries/identity*
66-
67-
- name: Build binaries
68-
run: |
69-
cd cpu
70-
mkdir -p ../binaries
71-
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ../binaries/cpu ./cmds/cpu
72-
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ../binaries/cpud ./cmds/cpud
73-
chmod +x ../binaries/*
7455
7556
- name: Create Dockerfile
7657
run: |
7758
cat > Dockerfile << 'EOF'
7859
FROM scratch
79-
COPY binaries/cpu /usr/local/bin/cpu
80-
COPY binaries/cpud /usr/local/bin/cpud
81-
COPY binaries/identity /etc/identity
82-
COPY binaries/identity.pub /etc/identity.pub
83-
COPY BUILD_INFO.txt /BUILD_INFO.txt
60+
COPY build/binaries/cpu /usr/local/bin/cpu
61+
COPY build/binaries/cpud /usr/local/bin/cpud
62+
COPY build/binaries/identity /etc/identity
63+
COPY build/binaries/identity.pub /etc/identity.pub
64+
COPY build/binaries/BUILD_INFO.txt /BUILD_INFO.txt
65+
COPY build/initramfs/cpud-initramfs.cpio.gz /cpud-initramfs.cpio.gz
8466
LABEL org.opencontainers.image.title="CPU Binaries"
8567
LABEL org.opencontainers.image.description="Prebuilt CPU binaries for aarch64 with SSH keys"
8668
LABEL org.opencontainers.image.source="https://github.com/${{ github.repository }}"
8769
LABEL org.opencontainers.image.version="${{ env.CPU_VERSION }}"
8870
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
8971
EOF
9072
91-
- name: Create build info
92-
run: |
93-
cat > BUILD_INFO.txt << EOF
94-
U-Root CPU Binaries for aarch64 (Container Package)
95-
Built on: $(date -u)
96-
CPU version: ${{ env.CPU_VERSION }}
97-
Target architecture: linux/arm64
98-
Go version: $(go version)
99-
Container registry: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
100-
101-
Files in this package:
102-
- /usr/local/bin/cpu: CPU client binary
103-
- /usr/local/bin/cpud: CPU daemon binary
104-
- /etc/identity: Default SSH private key
105-
- /etc/identity.pub: Default SSH public key
106-
107-
WARNING: These are default keys for convenience - generate your own for production!
108-
109-
Usage:
110-
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest /usr/local/bin/cpu -h
111-
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest /usr/local/bin/cpud -h
112-
113-
Extract SSH keys from container:
114-
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest cat /etc/identity > identity
115-
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest cat /etc/identity.pub > identity.pub
116-
EOF
117-
11873
- name: Build and push Docker image
11974
uses: docker/build-push-action@v5
12075
with:
12176
context: .
77+
file: ./Dockerfile
12278
platforms: linux/arm64
12379
push: true
12480
tags: ${{ steps.meta.outputs.tags }}

0 commit comments

Comments
 (0)