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

Updating PrivateSourceBuilt elements in the Versions.props file correctly. #3469

Merged
merged 29 commits into from
May 24, 2023
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
33 changes: 17 additions & 16 deletions eng/submit-source-build-release-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,36 +150,37 @@ cat "$global_json_path" \
| tee "$global_json_path.new"
mv "$global_json_path.new" "$global_json_path"

# Function to modify the URL in an XML file
# Function to modify the Version.props file
# Arguments:
# 1. XML file path
# 2. Element name
# 1. Element name
# 2. Replacement pattern
# 3. Replacement value
function update_versions.prop() {
function update_version_props() {
local element_name="$1"
local pattern="$2"
local replacement_pattern="$2"
local replacement_value="$3"

# Fetch the URL inside the element
local url=$(grep -oP "<$element_name>\K.*?(?=<\/$element_name>)" "$versions_props_path")
# Fetch the content inside the element
local element=$(grep -oP "<$element_name>.*<\/$element_name>" "$versions_props_path")
local content=$(echo "$element" | sed -n "s/.*<$element_name>\(.*\)<\/$element_name>.*/\1/p")

# Replace the very last part of the URL with the provided value
local new_url=$(echo "$url" | sed "s|/[^/]*$|/$replacement_value|")
# Replace the content with the provided pattern
local new_content=$(echo "$content" | sed "s|$replacement_pattern|$replacement_value|")

# Update the XML file with the modified URL
sed -i "s|$url|$new_url|" "$versions_props_path"
# Update the XML file with the modified content
sed -i "s|$element|<$element_name>$new_content</$element_name>|" "$versions_props_path"

echo "Replacing value of $element_name with $new_url"
echo "Replacing content of $element_name with $new_content"
}

if [[ $sdk_version == "6"* || $sdk_version == "7"* ]]; then
sed -i "s#<PrivateSourceBuiltArtifactsPackageVersion>.*</PrivateSourceBuiltArtifactsPackageVersion>#<PrivateSourceBuiltArtifactsPackageVersion>$sdk_version</PrivateSourceBuiltArtifactsPackageVersion>#" $versions_props_path
update_version_props "PrivateSourceBuiltArtifactsPackageVersion" ".*" "$sdk_version"
fi
if [[ $sdk_version == "7"* ]]; then
sed -i "s#<PrivateSourceBuiltSDKVersion>.*</PrivateSourceBuiltSDKVersion>#<PrivateSourceBuiltSDKVersion>$sdk_version</PrivateSourceBuiltSDKVersion>#" $versions_props_path
update_version_props "PrivateSourceBuiltSDKVersion" ".*" "$sdk_version"
elif [[ $sdk_version != "6"* ]]; then
modify_url_in_xml "PrivateSourceBuiltArtifactsUrl" "$source_built_artifacts_file_name"
modify_url_in_xml "PrivateSourceBuiltSdkUrl_CentOS8Stream" "$sdk_artifact_file_name"
update_version_props "PrivateSourceBuiltArtifactsUrl" "/[^/]*$" "/$source_built_artifacts_file_name"
update_version_props "PrivateSourceBuiltSdkUrl_CentOS8Stream" "/[^/]*$" "/$sdk_artifact_file_name"
ali-turan7 marked this conversation as resolved.
Show resolved Hide resolved
fi
ali-turan7 marked this conversation as resolved.
Show resolved Hide resolved

git add "$global_json_path" "$versions_props_path"
Expand Down