Skip to content

Commit 9562690

Browse files
feat(build-product-image): Add extra-tag-data input (#23)
* feat(build-product-image): Add extra-tag-data input Co-authored-by: Nick Larsen <[email protected]> * feat(build-product-image): Verify validity of image manifest tag * ci(smoke-test): Add extra-tag-data to smoke test workflow * feat(build-product-image): Add suggested-image-index-manifest-tag output --------- Co-authored-by: Nick Larsen <[email protected]>
1 parent a6da884 commit 9562690

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.github/workflows/pr_actions-smoke-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
product-version: ${{ matrix.versions }}
5656
build-cache-password: ${{ secrets.BUILD_CACHE_NEXUS_PASSWORD }}
5757
bake-config-file: smoke/conf.py
58+
extra-tag-data: pr-321
5859

5960
- name: Publish Container Image on oci.stackable.tech
6061
uses: ./publish-image

build-product-image/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ localhost/kafka:3.4.1-stackable0.0.0-dev-amd64
4848
- `build-cache-password` (required) <!-- TODO: make the cache optional -->
4949
- `bake-config-file` (defaults to `./conf.py`)
5050
- `sdp-version` (defaults to: `0.0.0-dev`)
51+
- `extra-tag-data` (optional, eg. `pr321`)
5152

5253
### Outputs
5354

5455
- `image-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev-amd64`)
56+
- `suggested-image-index-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev`)
5557

5658
[build-product-image]: ./action.yml

build-product-image/action.yml

+25-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ inputs:
2424
description: |
2525
Stackable Data Platform version (eg: `24.7.0`)
2626
default: 0.0.0-dev
27+
extra-tag-data:
28+
description: |
29+
Extra data to include in the final image manifest tag (eg: `pr321`)
2730
outputs:
2831
image-manifest-tag:
2932
description: |
3033
Human-readable tag (usually the version) with architecture information,
3134
for example: `3.4.1-stackable0.0.0-dev-amd64`
3235
value: ${{ steps.image_info.outputs.IMAGE_MANIFEST_TAG }}
36+
suggested-image-index-manifest-tag:
37+
description: |
38+
Human-readable tag (usually the version) without architecture information,
39+
for example: `3.4.1-stackable0.0.0-dev`
40+
value: ${{ steps.image_info.outputs.IMAGE_INDEX_MANIFEST_TAG }}
3341
runs:
3442
using: composite
3543
steps:
@@ -61,16 +69,30 @@ runs:
6169
BAKE_PRODUCT_VERSION: ${{ inputs.product-version }}
6270
BAKE_CONFIG_FILE: ${{ inputs.bake-config-file }}
6371
IMAGE_REPOSITORY: ${{ inputs.product-name }}
72+
EXTRA_TAG_DATA: ${{ inputs.extra-tag-data }}
6473
SDP_VERSION: ${{ inputs.sdp-version }}
6574
shell: bash
6675
run: |
6776
set -euo pipefail
6877
IMAGE_ARCH=$("$GITHUB_ACTION_PATH/../.scripts/get_architecture.sh")
6978
79+
# Will be either:
80+
# - 3.9.2-stackable0.0.0-dev-arm64 or
81+
# - 3.9.2-stackable0.0.0-dev-pr321-arm64
82+
IMAGE_INDEX_MANIFEST_TAG="${SDP_VERSION}${EXTRA_TAG_DATA:+-$EXTRA_TAG_DATA}-${IMAGE_ARCH}"
83+
echo "IMAGE_INDEX_MANIFEST_TAG=$IMAGE_INDEX_MANIFEST_TAG" | tee -a "$GITHUB_ENV"
84+
85+
# Validate that final tag is valid according to
86+
# https://github.com/distribution/reference/blob/8c942b0459dfdcc5b6685581dd0a5a470f615bff/regexp.go#L68
87+
if ! echo "$IMAGE_INDEX_MANIFEST_TAG" | grep --perl-regexp --quiet '^[\w][\w.-]{1,127}$'; then
88+
>&2 echo "Encountered invalid image manifest tag: $IMAGE_INDEX_MANIFEST_TAG"
89+
exit 1
90+
fi
91+
7092
echo "::group::bake"
7193
bake \
7294
--product "$IMAGE_REPOSITORY=$BAKE_PRODUCT_VERSION" \
73-
--image-version "${SDP_VERSION}-${IMAGE_ARCH}" \
95+
--image-version "$IMAGE_INDEX_MANIFEST_TAG" \
7496
--architecture "linux/${IMAGE_ARCH}" \
7597
--export-tags-file bake-target-tags \
7698
--configuration "$BAKE_CONFIG_FILE" \
@@ -102,7 +124,9 @@ runs:
102124
# Extract the image manifest tag from the bake-target-tags file
103125
IMAGE_MANIFEST_TAG=$(cut -d : -f 2 < bake-target-tags)
104126
[[ -n "$IMAGE_MANIFEST_TAG" ]]
127+
[[ -n "$IMAGE_INDEX_MANIFEST_TAG" ]]
105128
106129
# Add the contents of the env variables to the GitHub output, so that it
107130
# can be used as action outputs
108131
echo "IMAGE_MANIFEST_TAG=$IMAGE_MANIFEST_TAG" | tee -a "$GITHUB_OUTPUT"
132+
echo "IMAGE_INDEX_MANIFEST_TAG=$IMAGE_INDEX_MANIFEST_TAG" | tee -a "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)