From 4fb6629cfcd7724f143f4bf7991efb4d347c38db Mon Sep 17 00:00:00 2001 From: Hazem Belkhiria Date: Wed, 8 Jan 2025 09:40:29 +0100 Subject: [PATCH] feat(release.sh): fix bug release`s MRC in release.sh --- scripts/release/release-mrcv1.sh | 48 +++++++++++++++++--------------- scripts/release/release.sh | 16 +++++++---- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/scripts/release/release-mrcv1.sh b/scripts/release/release-mrcv1.sh index be902644b956..5d09f16d13f5 100755 --- a/scripts/release/release-mrcv1.sh +++ b/scripts/release/release-mrcv1.sh @@ -32,7 +32,7 @@ version_mrc() { node_modules/.bin/lerna version --scope=manager-react-components --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --allow-branch="${GIT_BRANCH}" --yes else printf "%s\n" "Releasing" - node_modules/.bin/lerna exec --scope=@ovh-ux/manager-react-components -- lerna version --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --no-private --ignore-changes="packages/modules/manager-pci-common/**" --yes + node_modules/.bin/lerna exec --scope=@ovh-ux/manager-react-components -- lerna version --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --no-private --ignore-changes="packages/manager/modules/manager-pci-common/**" --yes fi } @@ -118,33 +118,37 @@ main() { current_tag="$(git describe --abbrev=0)" printf "%s\n" "Previous tag was $current_tag" - # For manager-react-components (MRC), version it specifically - if echo "$changed_packages" | grep -q "manager-react-components"; then - # Only version MRC package - next_tag=$(get_release_name "$SEED") - printf "%s\n" "New tag for MRC: $next_tag" - - RELEASE_NOTE+="# Release $next_tag\ + # Separate versioning for `manager-react-components` and other packages + mrc_changed=false + while read -r package; do + name=$(echo "$package" | cut -d ':' -f 2) + version=$(echo "$package" | cut -d ':' -f 3) + + # Check if the changed package is `manager-react-components` + if [[ "$name" == *manager-react-components* ]]; then + mrc_changed=true + path_mrc=$(echo "$package" | cut -d ':' -f 1) + name_mrc=$(echo "$package" | cut -d ':' -f 2) + create_smoke_tag "$current_tag" "$name" "$version" + fi + done <<< "$changed_packages" + # Handle `manager-react-components` separately + if [ "$mrc_changed" == true ]; then + next_tag=$(get_release_name "$SEED") + printf "%s\n" "New tag for manager-react-components: $next_tag" -" + RELEASE_NOTE+="# Release $next_tag\n\n" - # Update Sonar version for the new tag update_sonar_version "$next_tag" - - # Version the MRC package - version_mrc - - # Update the changelog for MRC package - path="packages/manager-react-components" # Adjust path as needed - name="manager-react-components" - RELEASE_NOTE+="$(create_release_note "$path" "$name")\ - + version_mrc "$next_tag" -" + # Create release note for manager-react-components + RELEASE_NOTE+="$(create_release_note "$path_mrc" "$name_mrc")\n\n" - # Commit changes and tag - push_and_release "$next_tag" + # Commit and release manager-react-components + clean_tags + #push_and_release "$next_tag" else printf "%s\n" "No changes detected for manager-react-components. Exiting." exit 0 diff --git a/scripts/release/release.sh b/scripts/release/release.sh index a2c1739a3ca1..8e864447ee70 100755 --- a/scripts/release/release.sh +++ b/scripts/release/release.sh @@ -32,7 +32,7 @@ version() { node_modules/.bin/lerna version --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --allow-branch="${GIT_BRANCH}" --yes else printf "%s\n" "Releasing" - node_modules/.bin/lerna version --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --yes --ignore-changes="packages/manager-react-components/**" + node_modules/.bin/lerna version --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --yes --ignore-changes="packages/manager-react-components/**,packages/manager/modules/manager-pci-common/**" fi } @@ -54,7 +54,7 @@ version_mrc() { node_modules/.bin/lerna version --scope=manager-react-components --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --allow-branch="${GIT_BRANCH}" --yes else printf "%s\n" "Releasing" - node_modules/.bin/lerna exec --scope=@ovh-ux/manager-react-components -- lerna version --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --no-private --ignore-changes="packages/modules/manager-pci-common/**" --yes + node_modules/.bin/lerna exec --scope=@ovh-ux/manager-react-components -- lerna version --conventional-commits --no-commit-hooks --no-git-tag-version --no-push --no-private --ignore-changes="packages/manager/modules/manager-pci-common/**" --yes fi } @@ -132,7 +132,7 @@ main() { done changed_packages=$(get_changed_packages) - printf "%s\n" "Changed packages $changed_packages" + if [ -z "$changed_packages" ]; then printf "%s\n" "Nothing to release" exit 0 @@ -152,6 +152,7 @@ main() { mrc_changed=true path_mrc=$(echo "$package" | cut -d ':' -f 1) name_mrc=$(echo "$package" | cut -d ':' -f 2) + create_smoke_tag "$current_tag" "$name_mrc" "$version" else create_smoke_tag "$current_tag" "$name" "$version" fi @@ -170,9 +171,9 @@ main() { # Create release note for manager-react-components RELEASE_NOTE+="$(create_release_note "$path_mrc" "$name_mrc")\n\n" - #Commit and release manager-react-components + # Commit and release manager-react-components clean_tags - #push_and_release "$next_tag" + push_and_release "$next_tag" fi # Handle the rest of the packages @@ -181,16 +182,19 @@ main() { RELEASE_NOTE+="# Release $next_tag\n\n" update_sonar_version "$next_tag" version "$next_tag" + # Generate formatted release notes for other packages while read -r package; do path=$(echo "$package" | cut -d ':' -f 1) name=$(echo "$package" | cut -d ':' -f 2) RELEASE_NOTE+="$(create_release_note "$path" "$name")\n\n" done <<< "$changed_packages" + # Remove package-specific tags for other packages clean_tags + # Push and release for other packages - #push_and_release "$next_tag" + push_and_release "$next_tag" }