forked from wazuh/wazuh-docker
Added tag argument for bumper script
This commit is contained in:
@@ -14,6 +14,11 @@ on:
|
|||||||
default: ''
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
tag:
|
||||||
|
description: 'Change branches references to tag-like references (e.g. v4.12.0-alpha7)'
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
issue-link:
|
issue-link:
|
||||||
description: 'Issue link in format https://github.com/wazuh/<REPO>/issues/<ISSUE-NUMBER>'
|
description: 'Issue link in format https://github.com/wazuh/<REPO>/issues/<ISSUE-NUMBER>'
|
||||||
required: true
|
required: true
|
||||||
@@ -72,18 +77,22 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
VERSION: ${{ inputs.version }}
|
VERSION: ${{ inputs.version }}
|
||||||
STAGE: ${{ inputs.stage }}
|
STAGE: ${{ inputs.stage }}
|
||||||
|
TAG: ${{ inputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
script_params=""
|
script_params=""
|
||||||
version=${{ env.VERSION }}
|
version=${{ env.VERSION }}
|
||||||
stage=${{ env.STAGE }}
|
stage=${{ env.STAGE }}
|
||||||
|
tag=${{ env.TAG }}
|
||||||
|
|
||||||
# Both version and stage provided
|
# Both version and stage provided
|
||||||
if [[ -n "$version" && -n "$stage" ]]; then
|
if [[ -n "$version" && -n "$stage" && "$tag" != "true" ]]; then
|
||||||
script_params="--version ${version} --stage ${stage}"
|
script_params="--version ${version} --stage ${stage}"
|
||||||
elif [[ -z "$version" && -n "$stage" ]]; then
|
elif [[ -n "$version" && -n "$stage" && "$tag" == "true" ]]; then
|
||||||
script_params="--stage ${stage}"
|
script_params="--version ${version} --stage ${stage} --tag ${tag}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}')
|
issue_number=$(echo "${{ inputs.issue-link }}" | awk -F'/' '{print $NF}')
|
||||||
BRANCH_NAME="enhancement/docker${issue_number}-bump-${{ github.ref_name }}"
|
BRANCH_NAME="enhancement/kubernetes${issue_number}-bump-${{ github.ref_name }}"
|
||||||
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
||||||
echo "script_params=${script_params}" >> $GITHUB_OUTPUT
|
echo "script_params=${script_params}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
|||||||
+33
-12
@@ -76,6 +76,17 @@ update_stage_in_files() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_docker_images_tag() {
|
||||||
|
local NEW_TAG="$1"
|
||||||
|
local DOCKERFILES=( $(grep_command -E "wazuh/wazuh-[a-zA-Z0-9._-]*" "${DIR}") )
|
||||||
|
for file in "${DOCKERFILES[@]}"; do
|
||||||
|
sed -i -E "s/(wazuh\/wazuh-[a-zA-Z0-9._-]*):[a-zA-Z0-9._-]+/\1:${NEW_TAG}/g" "${file}"
|
||||||
|
if [[ $(git diff --name-only "${file}") ]]; then
|
||||||
|
FILES_EDITED+=("${file}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
||||||
echo "Starting repository version bumping process..." | tee -a "${LOG_FILE}"
|
echo "Starting repository version bumping process..." | tee -a "${LOG_FILE}"
|
||||||
@@ -91,6 +102,10 @@ main() {
|
|||||||
STAGE="$2"
|
STAGE="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--tag)
|
||||||
|
TAG="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown argument: $1"
|
echo "Unknown argument: $1"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -99,44 +114,50 @@ main() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Validate arguments
|
# Validate arguments
|
||||||
if [[ -z "$VERSION" ]]; then
|
if [[ -z "${VERSION}" ]]; then
|
||||||
echo "Error: --version argument is required." | tee -a "${LOG_FILE}"
|
echo "Error: --version argument is required." | tee -a "${LOG_FILE}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$STAGE" ]]; then
|
if [[ -z "${STAGE}" ]]; then
|
||||||
echo "Error: --stage argument is required." | tee -a "${LOG_FILE}"
|
echo "Error: --stage argument is required." | tee -a "${LOG_FILE}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate if version is in the correct format
|
# Validate if version is in the correct format
|
||||||
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
if ! [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
echo "Error: Version must be in the format X.Y.Z (e.g., 1.2.3)." | tee -a "${LOG_FILE}"
|
echo "Error: Version must be in the format X.Y.Z (e.g., 1.2.3)." | tee -a "${LOG_FILE}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate if stage is in the correct format
|
# Validate if stage is in the correct format
|
||||||
STAGE=$(echo "$STAGE" | tr '[:upper:]' '[:lower:]')
|
STAGE=$(echo "${STAGE}" | tr '[:upper:]' '[:lower:]')
|
||||||
if ! [[ "$STAGE" =~ ^(alpha[0-9]*|beta[0-9]*|rc[0-9]*|stable)$ ]]; then
|
if ! [[ "${STAGE}" =~ ^(alpha[0-9]*|beta[0-9]*|rc[0-9]*|stable)$ ]]; then
|
||||||
echo "Error: Stage must be one of the following examples: alpha1, beta1, rc1, stable." | tee -a "${LOG_FILE}"
|
echo "Error: Stage must be one of the following examples: alpha1, beta1, rc1, stable." | tee -a "${LOG_FILE}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Validate if tag is true or false
|
||||||
|
if [[ -n "${TAG}" && ! "${TAG}" =~ ^(true|false)$ ]]; then
|
||||||
|
echo "Error: --tag must be either true or false." | tee -a "${LOG_FILE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Get old version and stage
|
# Get old version and stage
|
||||||
get_old_version_and_stage
|
get_old_version_and_stage
|
||||||
|
|
||||||
if [[ "$OLD_VERSION" == "$VERSION" && "$OLD_STAGE" == "$STAGE" ]]; then
|
if [[ "${OLD_VERSION}" == "${VERSION}" && "${OLD_STAGE}" == "${STAGE}" ]]; then
|
||||||
echo "Version and stage are already up to date." | tee -a "${LOG_FILE}"
|
echo "Version and stage are already up to date." | tee -a "${LOG_FILE}"
|
||||||
echo "No changes needed." | tee -a "${LOG_FILE}"
|
echo "No changes needed." | tee -a "${LOG_FILE}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [[ "$OLD_VERSION" != "$VERSION" ]]; then
|
if [[ "${OLD_VERSION}" != "${VERSION}" ]]; then
|
||||||
echo "Updating version from $OLD_VERSION to $VERSION" | tee -a "${LOG_FILE}"
|
echo "Updating version from ${OLD_VERSION} to ${VERSION}" | tee -a "${LOG_FILE}"
|
||||||
update_version_in_files "$VERSION"
|
update_version_in_files "${VERSION}"
|
||||||
fi
|
fi
|
||||||
if [[ "$OLD_STAGE" != "$STAGE" ]]; then
|
if [[ "${OLD_STAGE}" != "${STAGE}" ]]; then
|
||||||
echo "Updating stage from $OLD_STAGE to $STAGE" | tee -a "${LOG_FILE}"
|
echo "Updating stage from ${OLD_STAGE} to ${STAGE}" | tee -a "${LOG_FILE}"
|
||||||
update_stage_in_files "$STAGE"
|
update_stage_in_files "${STAGE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "The following files were edited:" | tee -a "${LOG_FILE}"
|
echo "The following files were edited:" | tee -a "${LOG_FILE}"
|
||||||
|
|||||||
Reference in New Issue
Block a user