Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix version bump script #1942

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions scripts/bump_cloudbeat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
set -euo pipefail

export NEXT_CLOUDBEAT_BRANCH="bump-to-$NEXT_CLOUDBEAT_VERSION"
NEXT_MINOR_VERSION=$(echo "$NEXT_CLOUDBEAT_VERSION" | cut -d '.' -f1,2)
CURRENT_MINOR_VERSION=$(echo "$CURRENT_CLOUDBEAT_VERSION" | cut -d '.' -f1,2)

export NEXT_MINOR_VERSION
export CURRENT_MINOR_VERSION

export RELEASE_CLOUDBEAT_BRANCH="release-$CURRENT_MINOR_VERSION"

echo "NEXT_CLOUDBEAT_VERSION: $NEXT_CLOUDBEAT_VERSION"
echo "NEXT_MINOR_VERSION: $NEXT_MINOR_VERSION"
echo "CURRENT_CLOUDBEAT_VERSION: $CURRENT_CLOUDBEAT_VERSION"
echo "CURRENT_MINOR_VERSION: $CURRENT_MINOR_VERSION"

Expand Down Expand Up @@ -54,8 +49,8 @@ update_version_arm_template_file_uris() {
local organization_account_file="deploy/azure/ARM-for-organization-account.json"

echo "• Replace fileUris git branch in ARM templates"
sed -i'' -E "s/cloudbeat\/main/cloudbeat\/$NEXT_MINOR_VERSION/g" $single_account_file
sed -i'' -E "s/cloudbeat\/main/cloudbeat\/$NEXT_MINOR_VERSION/g" $organization_account_file
sed -i'' -E "s/cloudbeat\/main/cloudbeat\/$CURRENT_MINOR_VERSION/g" $single_account_file
sed -i'' -E "s/cloudbeat\/main/cloudbeat\/$CURRENT_MINOR_VERSION/g" $organization_account_file

echo "• Generate dev ARM templates"
./deploy/azure/generate_dev_template.py --template-type single-account
Expand Down Expand Up @@ -85,6 +80,7 @@ EOF
--base "main" \
--head "$NEXT_CLOUDBEAT_BRANCH" \
--label "backport-skip"
rm -rf cloudbeat_pr_body
}

create_cloudbeat_versions_pr_for_release() {
Expand All @@ -105,24 +101,26 @@ EOF
--base "$CURRENT_MINOR_VERSION" \
--head "$RELEASE_CLOUDBEAT_BRANCH" \
--label "backport-skip"

rm -rf cloudbeat_pr_body_release
}

# We need to bump hermit seperately because we need to wait for the snapshot build to be available
bump_hermit() {
echo "• Bump hermit cloudbeat version"
local BRANCH="bump-hermit-to-$NEXT_CLOUDBEAT_VERSION"
local BRANCH="bump-hermit-to-$CURRENT_CLOUDBEAT_VERSION"
git checkout -b "$BRANCH" origin/main

sed -i'' -E "s/\"CLOUDBEAT_VERSION\": .*/\"CLOUDBEAT_VERSION\": \"$NEXT_CLOUDBEAT_VERSION\",/g" bin/hermit.hcl
sed -i'' -E "s/\"CLOUDBEAT_VERSION\": .*/\"CLOUDBEAT_VERSION\": \"$CURRENT_CLOUDBEAT_VERSION\",/g" bin/hermit.hcl
git add bin/hermit.hcl
git commit -m "Bump cloudbeat to $NEXT_CLOUDBEAT_VERSION"
git commit -m "Bump cloudbeat to $CURRENT_CLOUDBEAT_VERSION"
git push origin "$BRANCH"

cat <<EOF >hermit_pr_body
Bump cloudbeat version - \`$NEXT_CLOUDBEAT_VERSION\`
Bump cloudbeat version - \`$CURRENT_CLOUDBEAT_VERSION\`

> [!IMPORTANT]
> to be merged after snapshot build for $NEXT_CLOUDBEAT_VERSION is available
> to be merged after snapshot build for $CURRENT_CLOUDBEAT_VERSION is available

> [!NOTE]
> This is an automated PR
Expand All @@ -134,6 +132,8 @@ EOF
--base "main" \
--head "$BRANCH" \
--label "backport-skip"

rm -rf hermit_pr_body
}

upload_cloud_formation_templates() {
Expand Down
19 changes: 9 additions & 10 deletions scripts/bump_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -euo pipefail
export MANIFEST_PATH="packages/cloud_security_posture/manifest.yml"
export CHANGELOG_PATH="packages/cloud_security_posture/changelog.yml"
export INTEGRATION_REPO="elastic/integrations"
export BRANCH="bump-to-$NEXT_CLOUDBEAT_VERSION"
MAJOR_MINOR_CLOUDBEAT=$(echo "$NEXT_CLOUDBEAT_VERSION" | cut -d. -f1,2)
export BRANCH="bump-to-$CURRENT_CLOUDBEAT_VERSION"
MAJOR_MINOR_CLOUDBEAT=$(echo "$CURRENT_CLOUDBEAT_VERSION" | cut -d. -f1,2)

export MAJOR_MINOR_CLOUDBEAT

Expand All @@ -18,13 +18,13 @@ checkout_integration_repo() {
}

get_next_integration_version() {
current_version=$(yq '.[0].version' changelog.yml | tr -d '"')
current_version=$(yq '.[0].version' $CHANGELOG_PATH | tr -d '"')
preview_number="${current_version##*-preview}"
preview_number="${preview_number##*(0)}" # Remove leading zeros
preview_number="${preview_number##*(0)}"
((next_preview_number = preview_number + 1))
next_preview_number_formatted=$(printf "%02d" "$next_preview_number")
NEXT_INTEGRATION_VERSION="${current_version%-*}-preview${next_preview_number_formatted}"

echo "• Next integration version: $NEXT_INTEGRATION_VERSION"
export NEXT_INTEGRATION_VERSION
}

Expand All @@ -35,8 +35,8 @@ update_manifest_version_vars() {

# cis_aws + vuln_mgmt_aws
echo "• Update cloudformation-* in manifest.yml"
sed -i'' -E "s/cloudformation-cnvm-[0-9]+\.[0-9]+\.[0-9]+/cloudformation-cnvm-$NEXT_CLOUDBEAT_VERSION/g" $MANIFEST_PATH
sed -i'' -E "s/cloudformation-cspm-ACCOUNT_TYPE-[0-9]+\.[0-9]+\.[0-9]+/cloudformation-cspm-ACCOUNT_TYPE-$NEXT_CLOUDBEAT_VERSION/g" $MANIFEST_PATH
sed -i'' -E "s/cloudformation-cnvm-[0-9]+\.[0-9]+\.[0-9]+/cloudformation-cnvm-$CURRENT_CLOUDBEAT_VERSION/g" $MANIFEST_PATH
sed -i'' -E "s/cloudformation-cspm-ACCOUNT_TYPE-[0-9]+\.[0-9]+\.[0-9]+/cloudformation-cspm-ACCOUNT_TYPE-$CURRENT_CLOUDBEAT_VERSION/g" $MANIFEST_PATH

# cis_azure
echo "• Update cloudshell_git_branch in manifest.yml"
Expand All @@ -46,7 +46,6 @@ update_manifest_version_vars() {
git commit -m "Update manifest template vars"
git push origin "$BRANCH"
}

create_integrations_pr() {
cat <<EOF >pr_body
Bump integration version - \`$NEXT_INTEGRATION_VERSION\`
Expand Down Expand Up @@ -86,7 +85,7 @@ update_changelog_version() {

checkout_integration_repo
get_next_integration_version
update_manifest_version_vars
update_manifest_version
update_changelog_version
update_manifest_version_vars
create_integrations_pr
update_changelog_version
Loading