Skip to content

Commit d1f9b07

Browse files
authored
feat(x2a): added nightly images on the script (#2864)
As internally discussed. FIX FLPATH-4086 Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
1 parent 4501d35 commit d1f9b07

1 file changed

Lines changed: 41 additions & 7 deletions

File tree

workspaces/x2a/scripts/build-dynamic-plugins.sh

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
#
33
# Build x2a dynamic plugins and package them as OCI images.
44
#
5-
# Usage: ./scripts/build-dynamic-plugins.sh [--push]
5+
# Usage: ./scripts/build-dynamic-plugins.sh [--push] [--tag <tag>]
66
#
77
# Options:
8-
# --push Push built images to the registry after packaging
8+
# --push Push built images to the registry after packaging
9+
# --tag <tag> Additional tag to apply to images (e.g., nightly, latest)
910
#
1011
# Produces OCI images:
1112
# quay.io/x2ansible/red-hat-developer-hub-backstage-plugin-x2a:<version>
1213
# quay.io/x2ansible/red-hat-developer-hub-backstage-plugin-x2a-backend:<version>
14+
# quay.io/x2ansible/red-hat-developer-hub-backstage-plugin-x2a-dcr:<version>
15+
# quay.io/x2ansible/red-hat-developer-hub-backstage-plugin-x2a-mcp-extras:<version>
16+
# quay.io/x2ansible/red-hat-developer-hub-backstage-plugin-scaffolder-backend-module-x2a:<version>
17+
#
18+
# And optionally with custom tag if --tag is specified
1319
#
1420
#
1521
set -euo pipefail
@@ -21,6 +27,7 @@ EMBED_COMMON="@red-hat-developer-hub/backstage-plugin-x2a-common"
2127
EMBED_NODE="@red-hat-developer-hub/backstage-plugin-x2a-node"
2228
IMAGE_REGISTRY="quay.io/x2ansible"
2329
PUSH_IMAGES=false
30+
CUSTOM_TAG=""
2431

2532
# Per-plugin embed packages. Plugins that depend on x2a-node (workspace dep)
2633
# must embed it alongside x2a-common so the RHDH CLI moves shared deps to
@@ -119,15 +126,28 @@ package_plugin() {
119126
log "Packaging plugin image: ${image_tag}"
120127
(cd "$plugin_path" && npx "@red-hat-developer-hub/cli@${RHDH_CLI_VERSION}" plugin package \
121128
-t "$image_tag")
129+
130+
if [[ -n "$CUSTOM_TAG" ]]; then
131+
local custom_image_tag="${IMAGE_REGISTRY}/${image_name}:${CUSTOM_TAG}"
132+
log "Tagging image with custom tag: ${custom_image_tag}"
133+
podman tag "$image_tag" "$custom_image_tag"
134+
fi
122135
}
123136

124137
push_plugin() {
125138
local plugin_dir="$1"
126139
local image_name="${PLUGIN_IMAGES[$plugin_dir]}"
127140
local version
128141
version="$(get_plugin_version "$plugin_dir")"
129-
local image_tag="${IMAGE_REGISTRY}/${image_name}:${version}"
130142

143+
if [[ -n "$CUSTOM_TAG" ]]; then
144+
local custom_image_tag="${IMAGE_REGISTRY}/${image_name}:${CUSTOM_TAG}"
145+
log "Pushing image with custom tag: ${custom_image_tag}"
146+
podman push "$custom_image_tag"
147+
return
148+
fi
149+
150+
local image_tag="${IMAGE_REGISTRY}/${image_name}:${version}"
131151
log "Pushing image: ${image_tag}"
132152
podman push "$image_tag"
133153
}
@@ -137,10 +157,24 @@ push_plugin() {
137157
# ---------------------------------------------------------------------------
138158

139159
parse_args() {
140-
for arg in "$@"; do
141-
case "$arg" in
142-
--push) PUSH_IMAGES=true ;;
143-
*) echo "ERROR: unknown argument: $arg" >&2; exit 1 ;;
160+
while [[ $# -gt 0 ]]; do
161+
case "$1" in
162+
--push)
163+
PUSH_IMAGES=true
164+
shift
165+
;;
166+
--tag)
167+
if [[ -z "${2:-}" ]]; then
168+
echo "ERROR: --tag requires a value" >&2
169+
exit 1
170+
fi
171+
CUSTOM_TAG="$2"
172+
shift 2
173+
;;
174+
*)
175+
echo "ERROR: unknown argument: $1" >&2
176+
exit 1
177+
;;
144178
esac
145179
done
146180
}

0 commit comments

Comments
 (0)