Skip to content

Commit 779eb64

Browse files
bschwedlerianpittwood
authored andcommitted
Add image-version and dev-stream inputs to build workflows
Dispatches from product repos need to narrow the matrix to a specific image version and release stream. bakery build and bakery run dgoss already accept --image-version and --dev-stream; this wires those through as workflow_call inputs on bakery-build-native.yml and bakery-build.yml, and adds --image-version to bakery ci matrix so the matrix generation filters as well (otherwise every version schedules a runner that filters to a no-op). Inputs default to empty and are only appended when set, so existing callers are unaffected.
1 parent 2d0c6cf commit 779eb64

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

.github/workflows/bakery-build-native.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ on:
2727
default: "exclude"
2828
required: false
2929
type: string
30+
image-version:
31+
description: "Filter to a specific image version (e.g. product version from upstream dispatch)"
32+
default: ""
33+
required: false
34+
type: string
35+
dev-stream:
36+
description: "Filter dev versions to a specific release stream (e.g. 'daily', 'preview')"
37+
default: ""
38+
required: false
39+
type: string
3040
push:
3141
description: "Whether to push images to registries [default: false]"
3242
default: false
@@ -105,17 +115,27 @@ jobs:
105115
env:
106116
DEV_VERSIONS: ${{ inputs.dev-versions }}
107117
MATRIX_VERSIONS: ${{ inputs.matrix-versions }}
118+
IMAGE_VERSION: ${{ inputs.image-version }}
119+
DEV_STREAM: ${{ inputs.dev-stream }}
108120
CONTEXT: ${{ inputs.context }}
109121
run: |
110-
echo "platform_matrix=$(bakery ci matrix --quiet --dev-versions "$DEV_VERSIONS" --matrix-versions "$MATRIX_VERSIONS" --context "$CONTEXT" | jq --compact-output .)" >> $GITHUB_OUTPUT
122+
ARGS=(--quiet --dev-versions "$DEV_VERSIONS" --matrix-versions "$MATRIX_VERSIONS" --context "$CONTEXT")
123+
[[ -n "$IMAGE_VERSION" ]] && ARGS+=(--image-version "$IMAGE_VERSION")
124+
[[ -n "$DEV_STREAM" ]] && ARGS+=(--dev-stream "$DEV_STREAM")
125+
echo "platform_matrix=$(bakery ci matrix "${ARGS[@]}" | jq --compact-output .)" >> $GITHUB_OUTPUT
111126
- name: Images by Version
112127
id: images-by-version
113128
env:
114129
DEV_VERSIONS: ${{ inputs.dev-versions }}
115130
MATRIX_VERSIONS: ${{ inputs.matrix-versions }}
131+
IMAGE_VERSION: ${{ inputs.image-version }}
132+
DEV_STREAM: ${{ inputs.dev-stream }}
116133
CONTEXT: ${{ inputs.context }}
117134
run: |
118-
echo "versions_matrix=$(bakery ci matrix --quiet --dev-versions "$DEV_VERSIONS" --matrix-versions "$MATRIX_VERSIONS" --exclude platform --context "$CONTEXT" | jq --compact-output .)" >> $GITHUB_OUTPUT
135+
ARGS=(--quiet --dev-versions "$DEV_VERSIONS" --matrix-versions "$MATRIX_VERSIONS" --exclude platform --context "$CONTEXT")
136+
[[ -n "$IMAGE_VERSION" ]] && ARGS+=(--image-version "$IMAGE_VERSION")
137+
[[ -n "$DEV_STREAM" ]] && ARGS+=(--dev-stream "$DEV_STREAM")
138+
echo "versions_matrix=$(bakery ci matrix "${ARGS[@]}" | jq --compact-output .)" >> $GITHUB_OUTPUT
119139
120140
build-test:
121141
name: "Build/Test ${{ matrix.img.image }}:${{ matrix.img.version }} (${{ matrix.img.platform }})"

.github/workflows/bakery-build.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ on:
2828
default: "exclude"
2929
required: false
3030
type: string
31+
image-version:
32+
description: "Filter to a specific image version (e.g. product version from upstream dispatch)"
33+
default: ""
34+
required: false
35+
type: string
36+
dev-stream:
37+
description: "Filter dev versions to a specific release stream (e.g. 'daily', 'preview')"
38+
default: ""
39+
required: false
40+
type: string
3141
push:
3242
description: "Whether to push images to registries [default: false]"
3343
default: false
@@ -95,9 +105,14 @@ jobs:
95105
env:
96106
DEV_VERSIONS: ${{ inputs.dev-versions }}
97107
MATRIX_VERSIONS: ${{ inputs.matrix-versions }}
108+
IMAGE_VERSION: ${{ inputs.image-version }}
109+
DEV_STREAM: ${{ inputs.dev-stream }}
98110
CONTEXT: ${{ inputs.context }}
99111
run: |
100-
echo "matrix=$(bakery ci matrix --quiet --dev-versions "$DEV_VERSIONS" --matrix-versions "$MATRIX_VERSIONS" --context "$CONTEXT" | jq --compact-output .)" >> $GITHUB_OUTPUT
112+
ARGS=(--quiet --dev-versions "$DEV_VERSIONS" --matrix-versions "$MATRIX_VERSIONS" --context "$CONTEXT")
113+
[[ -n "$IMAGE_VERSION" ]] && ARGS+=(--image-version "$IMAGE_VERSION")
114+
[[ -n "$DEV_STREAM" ]] && ARGS+=(--dev-stream "$DEV_STREAM")
115+
echo "matrix=$(bakery ci matrix "${ARGS[@]}" | jq --compact-output .)" >> $GITHUB_OUTPUT
101116
102117
build:
103118
name: "${{ matrix.img.image }}:${{ matrix.img.version }}"

posit-bakery/posit_bakery/cli/ci.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ def matrix(
5757
rich_help_panel=RichHelpPanelEnum.FILTERS,
5858
),
5959
] = MatrixVersionInclusionEnum.EXCLUDE,
60+
image_version: Annotated[
61+
Optional[str],
62+
typer.Option(
63+
show_default=False,
64+
help="The image version to filter to.",
65+
rich_help_panel=RichHelpPanelEnum.FILTERS,
66+
),
67+
] = None,
6068
exclude: Annotated[
6169
Optional[list[BakeryCIMatrixFieldEnum]],
6270
typer.Option(help="Fields to exclude splitting the matrix by."),
@@ -121,6 +129,8 @@ def matrix(
121129
if dev_stream is not None and ver.isDevelopmentVersion:
122130
if ver.metadata.get("release_stream") != dev_stream:
123131
continue
132+
if image_version is not None and ver.name != image_version:
133+
continue
124134

125135
if BakeryCIMatrixFieldEnum.VERSION not in exclude:
126136
entry["version"] = ver.name

0 commit comments

Comments
 (0)