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#
1521set -euo pipefail
@@ -21,6 +27,7 @@ EMBED_COMMON="@red-hat-developer-hub/backstage-plugin-x2a-common"
2127EMBED_NODE=" @red-hat-developer-hub/backstage-plugin-x2a-node"
2228IMAGE_REGISTRY=" quay.io/x2ansible"
2329PUSH_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
124137push_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
139159parse_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