Skip to content

Update

Update #23

Workflow file for this run

name: Update
env:
IMAGE_NAME: activemq-artemis-broker
on:
workflow_dispatch:
inputs:
version:
description: 'Version, i.e. 1.0.0'
required: false
default: '*.*.+'
type: string
update_version:
description: 'Update version'
required: true
default: true
type: boolean
update_related_images:
description: 'Update related images'
required: true
default: true
type: boolean
trigger_release:
description: 'Trigger release'
required: false
default: true
type: boolean
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21.11'
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up the repo
run: |
git config user.name 'artemiscloud-bot'
git config user.email '[email protected]'
git push
- name: Update version
if: ${{ inputs.update_version }}
run: |
CURRENT_VERSION=$(grep -m 1 -oP '(?<=Version = ")[^"]+' version/version.go)
IFS=. read CURRENT_VERSION_MAJOR CURRENT_VERSION_MINOR CURRENT_VERSION_PATCH <<< ${CURRENT_VERSION}
IFS=. read VERSION_MAJOR VERSION_MINOR VERSION_PATCH <<< ${{ inputs.version }}
VERSION_MAJOR=${VERSION_MAJOR/\*/${CURRENT_VERSION_MAJOR}} && VERSION_MAJOR=${VERSION_MAJOR/+/$((CURRENT_VERSION_MAJOR+1))}
VERSION_MINOR=${VERSION_MINOR/\*/${CURRENT_VERSION_MINOR}} && VERSION_MINOR=${VERSION_MINOR/+/$((CURRENT_VERSION_MINOR+1))}
VERSION_PATCH=${VERSION_PATCH/\*/${CURRENT_VERSION_PATCH}} && VERSION_PATCH=${VERSION_PATCH/+/$((CURRENT_VERSION_PATCH+1))}
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
sed -i "s~Version = \"${CURRENT_VERSION}\"~Version = \"${VERSION}\"~" version/version.go
sed -i "s~^VERSION ?=.*~VERSION ?= ${VERSION}~" Makefile
sed -i "s~^OPERATOR_VERSION :=.*~OPERATOR_VERSION := ${VERSION}~" Makefile
sed -i "s~^LABEL version=.*~LABEL version=\"${VERSION}\"~g" Dockerfile
make build && make generate-deploy && make bundle && git status
git commit --all --message "Update version to ${VERSION}" || echo "nothing to commit"
- name: Update related images
if: ${{ inputs.update_related_images }}
run: |
set -e
QUOTE_CHAR='"'
NEWLINE=$(echo 'XG4K' | base64 -d)
VERSION_FILE='version/version.go'
RELATED_IMAGES_FILE='config/manager/activemq_artemis_manager_related_images.yaml'
for ACTIVEMQ_ARTEMIS_BROKER_TAG in $(skopeo list-tags docker://quay.io/artemiscloud/activemq-artemis-broker-kubernetes | jq -r '[.Tags[] | select(. | startswith("artemis."))] | .[-5:] | .[]'); do
echo "ACTIVEMQ_ARTEMIS_BROKER_TAG: ${ACTIVEMQ_ARTEMIS_BROKER_TAG}"
ACTIVEMQ_ARTEMIS_VERSION="${ACTIVEMQ_ARTEMIS_BROKER_TAG/artemis./}"
ACTIVEMQ_ARTEMIS_COMPACT_VERSION=${ACTIVEMQ_ARTEMIS_VERSION//./}
ACTIVEMQ_ARTEMIS_BROKER_INIT_DIGEST="$(skopeo inspect docker://quay.io/artemiscloud/activemq-artemis-broker-init:${ACTIVEMQ_ARTEMIS_BROKER_TAG} | jq -r '.Digest')"
ACTIVEMQ_ARTEMIS_BROKER_KUBERNETES_DIGEST="$(skopeo inspect docker://quay.io/artemiscloud/activemq-artemis-broker-kubernetes:${ACTIVEMQ_ARTEMIS_BROKER_TAG} | jq -r '.Digest')"
if ! grep "${ACTIVEMQ_ARTEMIS_VERSION}" ${VERSION_FILE}; then
YACFG_BROKER_PROFILE="${ACTIVEMQ_ARTEMIS_VERSION}"
ACTIVEMQ_ARTEMIS_BROKER_INIT_VERSION="$(skopeo inspect docker://quay.io/artemiscloud/activemq-artemis-broker-init@${ACTIVEMQ_ARTEMIS_BROKER_INIT_DIGEST} | jq -r '.Labels.version')"
INIT_IMAGE_TAG="$(git ls-remote --tags https://github.com/artemiscloud/activemq-artemis-broker-init-image.git | grep -Po "(?<=refs/tags/)${ACTIVEMQ_ARTEMIS_BROKER_INIT_VERSION}[^^]*$" | head -1)"
INIT_IMAGE_DOCKERFILE="$(curl -L https://raw.githubusercontent.com/artemiscloud/activemq-artemis-broker-init-image/${INIT_IMAGE_TAG}/Dockerfile)"
REMOTE_SOURCE_REF="$(echo "${INIT_IMAGE_DOCKERFILE}" | grep -Po '(?<=REMOTE_SOURCE_REF=).*')"
REMOTE_SOURCE_REP="$(echo "${INIT_IMAGE_DOCKERFILE}" | grep -Po '(?<=REMOTE_SOURCE_REP=https://github.com/).*(?=.git)')"
YACFG_BROKER_PROFILES="$(curl -L https://raw.githubusercontent.com/${REMOTE_SOURCE_REP}/${REMOTE_SOURCE_REF}/setup.py | grep -Po '(?<=artemis/)[0-9.]+' | sort -rV | uniq)"
if ! echo "${YACFG_BROKER_PROFILES}" | grep "^${ACTIVEMQ_ARTEMIS_VERSION}$"; then
YACFG_BROKER_PROFILE="$(echo "${YACFG_BROKER_PROFILES}" | head -n1)"
fi
sed -i "/LatestVersion / s/${QUOTE_CHAR}.*${QUOTE_CHAR}/${QUOTE_CHAR}${ACTIVEMQ_ARTEMIS_VERSION}${QUOTE_CHAR}/" ${VERSION_FILE}
sed -i "/CompactLatestVersion / s/${QUOTE_CHAR}.*${QUOTE_CHAR}/${QUOTE_CHAR}${ACTIVEMQ_ARTEMIS_COMPACT_VERSION}${QUOTE_CHAR}/" ${VERSION_FILE}
sed -i "/var FullVersionFromCompactVersion/,/}/ s/}/ ${QUOTE_CHAR}${ACTIVEMQ_ARTEMIS_COMPACT_VERSION}${QUOTE_CHAR}: ${QUOTE_CHAR}${ACTIVEMQ_ARTEMIS_VERSION}${QUOTE_CHAR},${NEWLINE}}/" ${VERSION_FILE}
sed -i "/var YacfgProfileVersionFromFullVersion/,/}/ s/}/ ${QUOTE_CHAR}${ACTIVEMQ_ARTEMIS_VERSION}${QUOTE_CHAR}: ${QUOTE_CHAR}${YACFG_BROKER_PROFILE}${QUOTE_CHAR},${NEWLINE}}/" ${VERSION_FILE}
sed -i "/var SupportedActiveMQArtemisVersions/,/}/ s/}/ ${QUOTE_CHAR}${ACTIVEMQ_ARTEMIS_VERSION}${QUOTE_CHAR},${NEWLINE}}/" ${VERSION_FILE}
echo "" >> ${RELATED_IMAGES_FILE}
echo " # ${ACTIVEMQ_ARTEMIS_VERSION}" >> ${RELATED_IMAGES_FILE}
echo " - name: RELATED_IMAGE_ActiveMQ_Artemis_Broker_Init_${ACTIVEMQ_ARTEMIS_COMPACT_VERSION}" >> ${RELATED_IMAGES_FILE}
echo " value: quay.io/artemiscloud/activemq-artemis-broker-init@${ACTIVEMQ_ARTEMIS_BROKER_INIT_DIGEST}" >> ${RELATED_IMAGES_FILE}
echo " - name: RELATED_IMAGE_ActiveMQ_Artemis_Broker_Kubernetes_${ACTIVEMQ_ARTEMIS_COMPACT_VERSION}" >> ${RELATED_IMAGES_FILE}
echo " value: quay.io/artemiscloud/activemq-artemis-broker-kubernetes@${ACTIVEMQ_ARTEMIS_BROKER_KUBERNETES_DIGEST}" >> ${RELATED_IMAGES_FILE}
else
sed -i "/RELATED_IMAGE_ActiveMQ_Artemis_Broker_Init_${ACTIVEMQ_ARTEMIS_COMPACT_VERSION}/,/value:/ s~value:.*~value: quay.io/artemiscloud/activemq-artemis-broker-init@${ACTIVEMQ_ARTEMIS_BROKER_INIT_DIGEST}~" ${RELATED_IMAGES_FILE}
sed -i "/RELATED_IMAGE_ActiveMQ_Artemis_Broker_Kubernetes_${ACTIVEMQ_ARTEMIS_COMPACT_VERSION}/,/value:/ s~value:.*~value: quay.io/artemiscloud/activemq-artemis-broker-kubernetes@${ACTIVEMQ_ARTEMIS_BROKER_KUBERNETES_DIGEST}~" ${RELATED_IMAGES_FILE}
fi
done
make build && make generate-deploy && make bundle && git status
git commit --all --message "Update related images to ${ACTIVEMQ_ARTEMIS_VERSION}" || echo "nothing to commit"
- name: Push commits
run: |
git push
- name: Trigger release
if: ${{ inputs.trigger_release }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'release.yml',
ref: context.ref,
});