Skip to content

Commit 07ff155

Browse files
authored
feat: add options for build-chunked-oci (#106)
1 parent 9c9c416 commit 07ff155

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

action.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,25 @@ inputs:
5959
Example: `ublue-os`
6060
required: false
6161
default: ${{ github.repository_owner }}
62+
build_chunked_oci:
63+
description: |
64+
Uses `rpm-ostree compose build-chunked-oci` to rechunk the image, allowing for smaller images and smaller updates.
65+
66+
This will increase the build-time and take up more space during build-time.
67+
required: false
68+
default: "false"
69+
max_layers:
70+
description: |
71+
Maximum number of layers to use when rechunking with `build-chunked-oci`.
72+
required: false
73+
default: 128
6274
rechunk:
6375
description: |
6476
Rechunk the ostree-based result images with [github.com/hhd-dev/rechunk](https://github.com/hhd-dev/rechunk) for more efficient diffs and updates. (lower image size, better download speed, better update resuming)
6577
6678
Will make your builds considerably slower. This is an experimental option, as it can cause issues with file permissions in some scenarios, so enable on your own risk.
6779
68-
Internally builds squashed images with podman to further reduce the image size.
80+
*Warning*: This option will be deprecated in the future.
6981
required: false
7082
default: "false"
7183
use_cache:
@@ -116,7 +128,9 @@ runs:
116128
- name: Validate inputs
117129
shell: bash
118130
env:
119-
SQUASH_INPUT_VALUE: ${{ inputs.squash }}
131+
INPUT_BUILD_CHUNKED_OCI: ${{ inputs.build_chunked_oci }}
132+
INPUT_RECHUNK: ${{ inputs.build_chunked_oci }}
133+
INPUT_SQUASH: ${{ inputs.squash }}
120134
BUILD_OPTS: ${{ inputs.build_opts }}
121135
github_action_path: ${{ github.action_path }}
122136
run: |
@@ -130,7 +144,7 @@ runs:
130144

131145
- name: Set up Docker Buildx
132146
uses: docker/setup-buildx-action@18ce135bb5112fa8ce4ed6c17ab05699d7f3a5e0 # v3.11.0
133-
if: ${{ inputs.squash != 'true' && inputs.rechunk != 'true' }}
147+
if: ${{ inputs.squash != 'true' && inputs.build_chunked_oci != 'true' && inputs.rechunk != 'true' }}
134148
with:
135149
install: true
136150
driver: docker-container
@@ -146,7 +160,7 @@ runs:
146160
147161
# that is compatible with BlueBuild
148162
- name: Setup Podman
149-
if: ${{ (inputs.squash == 'true' || inputs.rechunk == 'true') && steps.ubuntu_version.outputs.version == '22.04' }}
163+
if: ${{ (inputs.squash == 'true' || inputs.build_chunked_oci == 'true' || inputs.rechunk == 'true') && steps.ubuntu_version.outputs.version == '22.04' }}
150164
shell: bash
151165
run: |
152166
# from https://askubuntu.com/questions/1414446/whats-the-recommended-way-of-installing-podman-4-in-ubuntu-22-04
@@ -288,6 +302,8 @@ runs:
288302
BB_CACHE_LAYERS: ${{ inputs.use_cache }}
289303
BB_RETRY_PUSH_COUNT: ${{ inputs.retry_push_count }}
290304
BB_SQUASH: ${{ inputs.squash }}
305+
BB_BUILD_CHUNKED_OCI: ${{ inputs.build_chunked_oci }}
306+
BB_BUILD_CHUNKED_OCI_MAX_LAYERS: ${{ inputs.max_layers }}
291307
BB_RECHUNK: ${{ inputs.rechunk }}
292308
RECIPE_PATH: ${{ steps.build_vars.outputs.recipe_path }}
293309
RUST_LOG_STYLE: always
@@ -299,6 +315,10 @@ runs:
299315
BUILD_OPTS+=("--build-driver" "podman" "--squash")
300316
fi
301317
318+
if [ "${BB_BUILD_CHUNKED_OCI}" = "false" ]; then
319+
unset BB_BUILD_CHUNKED_OCI_MAX_LAYERS
320+
fi
321+
302322
RUN_SUDO=""
303323
if [ "${BB_RECHUNK}" = "true" ]; then
304324
RUN_SUDO=1

build_opts_check.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
set -euo pipefail
33

44
# Expected env vars:
5-
# SQUASH_INPUT_VALUE
65
# BUILD_OPTS
6+
# INPUT_BUILD_CHUNKED_OCI
7+
# INPUT_RECHUNK
8+
# INPUT_SQUASH
79

810
# check_build_opts "option1" "option2" "error_message"
911
# If you have only 1 option to provide, provide '---' string as 2nd placeholder option
@@ -26,7 +28,19 @@ check_build_opts() {
2628
fi
2729
}
2830

29-
if [[ "${SQUASH_INPUT_VALUE}" == "true" ]]; then
31+
if [[ "${INPUT_BUILD_CHUNKED_OCI}" == 'true' ]]; then
32+
if [[ "${INPUT_RECHUNK}" == 'true' ]]; then
33+
echo "Cannot set both 'build_chunked_oci' and 'rechunk' to true."
34+
exit 1
35+
fi
36+
check_build_opts "--build-chunked-oci" "---" "Cannot provide '--build-chunked-oci' in build_opts while 'build_chunked_oci' is set to true."
37+
fi
38+
39+
if [[ "${INPUT_RECHUNK}" == 'true' ]]; then
40+
check_build_opts "--rechunk" "---" "Cannot provide '--rechunk' in build_opts while 'rechunk' is set to true."
41+
fi
42+
43+
if [[ "${INPUT_SQUASH}" == "true" ]]; then
3044
check_build_opts "-B" "--build-driver" "Cannot provide '--build-driver' in build_opts while 'squash' is set to true."
3145
check_build_opts "-s" "--squash" "Cannot provide '--squash' in build_opts while 'squash' is set to true."
3246
fi

0 commit comments

Comments
 (0)