Skip to content

Commit df14b59

Browse files
committed
ci: using koci merge for multi arch
1 parent 0ffe995 commit df14b59

2 files changed

Lines changed: 33 additions & 43 deletions

File tree

‎.github/workflows/build.yaml‎

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ jobs:
3535
runner: ubuntu-24.04-arm
3636
runs-on: ${{ matrix.runner }}
3737
steps:
38-
- name: Free disk space
39-
run: |
40-
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
41-
sudo docker system prune -af
42-
df -h
43-
4438
- uses: actions/checkout@v6
4539
with:
4640
fetch-depth: 0
@@ -70,16 +64,9 @@ jobs:
7064
CONTAINER_RUNTIME=docker \
7165
ARCH=${{ matrix.arch }} \
7266
PUSH=true \
73-
LATEST=${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.latest) }} \
74-
TAG=${{ steps.tag.outputs.tag }} \
67+
TAG=ci \
7568
just oci
7669
77-
- name: Build summary
78-
run: |
79-
echo "### stub (${{ matrix.arch }}) Built" >> "$GITHUB_STEP_SUMMARY"
80-
echo "- **Tag:** \`${{ steps.tag.outputs.tag }}\`" >> "$GITHUB_STEP_SUMMARY"
81-
echo "- **Image:** \`${{ env.REGISTRY }}/stub:${{ steps.tag.outputs.tag }}-${{ matrix.arch }}\`" >> "$GITHUB_STEP_SUMMARY"
82-
8370
manifest:
8471
name: Combine multi-arch manifest
8572
needs: build
@@ -89,18 +76,14 @@ jobs:
8976
runs-on: ubuntu-latest
9077
env:
9178
REGISTRY: ghcr.io/muak-os
79+
CONTAINER_RUNTIME: docker
80+
TOOLS: ghcr.io/muak-os/tools:latest
9281
steps:
9382
- uses: actions/checkout@v6
9483
with:
9584
fetch-depth: 0
9685

97-
- uses: docker/setup-buildx-action@v4
98-
99-
- uses: docker/login-action@v4
100-
with:
101-
registry: ghcr.io
102-
username: ${{ github.actor }}
103-
password: ${{ secrets.GITHUB_TOKEN }}
86+
- uses: taiki-e/install-action@just
10487

10588
- name: Determine tag
10689
id: tag
@@ -115,24 +98,15 @@ jobs:
11598
env:
11699
TAG: ${{ steps.tag.outputs.tag }}
117100
LATEST: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.latest) }}
101+
KOCI_REGISTRY_USERNAME: ${{ github.actor }}
102+
KOCI_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
118103
run: |
119-
docker buildx imagetools create \
120-
--tag "${REGISTRY}/stub:${TAG}" \
121-
"${REGISTRY}/stub:${TAG}-amd64" \
122-
"${REGISTRY}/stub:${TAG}-arm64"
123-
124-
if [ "${LATEST}" = "true" ]; then
125-
docker buildx imagetools create \
126-
--tag "${REGISTRY}/stub:latest" \
127-
"${REGISTRY}/stub:latest-amd64" \
128-
"${REGISTRY}/stub:latest-arm64"
129-
fi
104+
just merge amd64=ci-amd64 arm64=ci-arm64
130105
131106
- name: Build summary
132107
run: |
133108
echo "### Multi-arch manifest created" >> "$GITHUB_STEP_SUMMARY"
134-
echo "- **Tag:** \`${{ env.REGISTRY }}/stub:${{ steps.tag.outputs.tag }}\`" >> "$GITHUB_STEP_SUMMARY"
135-
echo "- **Sources:** \`${{ env.REGISTRY }}/stub:${{ steps.tag.outputs.tag }}-amd64\`, \`${{ env.REGISTRY }}/stub:${{ steps.tag.outputs.tag }}-arm64\`" >> "$GITHUB_STEP_SUMMARY"
109+
echo "- **Tag:** \`${REGISTRY}/stub:${{ steps.tag.outputs.tag }}\`" >> "$GITHUB_STEP_SUMMARY"
136110
if [[ "${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.latest) }}" == "true" ]]; then
137-
echo "- **Latest:** \`${{ env.REGISTRY }}/stub:latest\`" >> "$GITHUB_STEP_SUMMARY"
111+
echo "- **Latest:** \`${REGISTRY}/stub:latest\`" >> "$GITHUB_STEP_SUMMARY"
138112
fi

‎Justfile‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Muak UEFI boot stub
22
#
3-
# Prerequisites: rustup, docker/podman
3+
# Prerequisites: rustup, docker/podman, git
44
# Run `just --list` for available recipes
55

66
set positional-arguments := true
@@ -17,8 +17,10 @@ alpine_version := "3.24"
1717
rust_version := `grep -oP 'rust-version\s*=\s*"\K[^"]+' Cargo.toml`
1818
registry := env_var_or_default("REGISTRY", "ghcr.io/muak-os")
1919
tag := env_var_or_default("TAG", "latest")
20+
tools := env_var_or_default("TOOLS", "ghcr.io/muak-os/tools:latest")
2021
push := env_var_or_default("PUSH", "false")
2122
latest := env_var_or_default("LATEST", "false")
23+
push_arg := if container_runtime == "podman" { "" } else { if push == "true" { "--push" } else { "" } }
2224
out := `test -f .git && realpath -m "$(git rev-parse --git-common-dir)/../_out" || realpath -m _out`
2325

2426
# Architecture
@@ -53,6 +55,10 @@ build release="":
5355
CARGO_BUILD_SBOM=true cargo build {{ release }} -Z sbom --target {{ arch }}-unknown-uefi --features uefi
5456
printf "{{ green }}Stub built successfully!{{ reset }}\n"
5557

58+
# ─────────────────────────────────────────────────────────────────────────────
59+
# OCI Images
60+
# ─────────────────────────────────────────────────────────────────────────────
61+
5662
# Build (and optionally push) the stub OCI image
5763
[script]
5864
oci:
@@ -64,14 +70,8 @@ oci:
6470

6571
if [ "{{ container_runtime }}" = "podman" ]; then
6672
cmd="podman build"
67-
push_flags=""
6873
else
6974
cmd="docker buildx build --provenance=false"
70-
if [ "{{ push }}" = "true" ]; then
71-
push_flags="--push"
72-
else
73-
push_flags=""
74-
fi
7575
fi
7676

7777
printf "{{ cyan }}Building stub image: {{ registry }}/stub (push={{ push }}, latest={{ latest }}){{ reset }}\n"
@@ -81,7 +81,7 @@ oci:
8181
--build-arg ALPINE_VERSION={{ alpine_version }} \
8282
--build-arg RUST_VERSION={{ rust_version }} \
8383
--build-arg SOURCE_DATE_EPOCH=0 \
84-
${push_flags} \
84+
{{ push_arg }} \
8585
$(just _cache-from stub) $(just _cache-to stub) \
8686
${tags} \
8787
--file Dockerfile \
@@ -92,6 +92,22 @@ oci:
9292
if [ "{{ latest }}" = "true" ]; then {{ container_runtime }} push "{{ registry }}/stub:latest{{ oci_suffix }}"; fi
9393
fi
9494

95+
# Merge per-platform images into a multi-arch OCI index
96+
[script]
97+
merge *sources:
98+
tags=""
99+
if [ "{{ latest }}" = "true" ]; then
100+
tags="--tag latest"
101+
fi
102+
{{ container_runtime }} run --rm --network=host \
103+
-e KOCI_REGISTRY_USERNAME -e KOCI_REGISTRY_PASSWORD \
104+
{{ tools }} \
105+
/koci merge \
106+
--image "{{ registry }}/stub" \
107+
--tag "{{ tag }}" \
108+
${tags} \
109+
{{ sources }}
110+
95111
# ─────────────────────────────────────────────────────────────────────────────
96112
# Testing
97113
# ─────────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)