-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nuget): adjust version check action
Refs: CPLP-3400
- Loading branch information
Showing
4 changed files
with
90 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
############################################################### | ||
# Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
############################################################### | ||
|
||
#!/bin/bash | ||
|
||
# Get branch names | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <branchRange>" | ||
exit 1 | ||
fi | ||
|
||
# Assign the arguments to variables | ||
branchRange="$1" | ||
|
||
# Initialize a global arrays to store data | ||
version_update_needed=() | ||
first_version="" | ||
unmatching_package=() | ||
|
||
# get the directory.build files to check the updated versions | ||
changed_versions=($(git diff --name-only | grep 'Directory.Build.props')) | ||
|
||
check_version_update(){ | ||
local project="$1" | ||
local props_file=$project"/Directory.Build.props" | ||
if git diff --name-only --diff-filter=acmrtu $branchRange | grep -q "^$props_file$"; then | ||
version_update_needed+=($project) | ||
elif git diff --name-only --diff-filter=D $branchRange | grep -q "^$props_file$"; then | ||
return; | ||
else | ||
if [[ " ${changed_versions[@]} " =~ " $props_file " ]]; then | ||
if ! git diff $branchRange -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionPrefix>[0-9]+\.[0-9]+\.[0-9]+</VersionPrefix>' && | ||
(! git diff $branchRange -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionSuffix></VersionSuffix>' && | ||
git diff $branchRange -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionSuffix>[^<]*</VersionSuffix>'); then | ||
version_update_needed+=($project) | ||
elif git diff $branchRange -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionPrefix>[0-9]+\.[0-9]+\.[0-9]+</VersionPrefix>' && | ||
git diff $branchRange -- "$props_file" | grep -qE '^\-[[:space:]]*<VersionPrefix>[0-9]+\.[0-9]+\.[0-9]+</VersionPrefix>'; then | ||
version_before=$(git diff $branchRange -- "$props_file" | grep -E '^-.*<VersionPrefix>' | sed -E 's/^-.*<VersionPrefix>([^<]+)<\/VersionPrefix>/\1/') | ||
version_after=$(git diff $branchRange -- "$props_file" | grep -E '^\+.*<VersionPrefix>' | sed -E 's/^\+.*<VersionPrefix>([^<]+)<\/VersionPrefix>/\1/') | ||
|
||
IFS='.' read -r major_before minor_before patch_before <<< "$version_before" | ||
IFS='.' read -r major_after minor_after patch_after <<< "$version_after" | ||
|
||
if [ -n "$major_before" ] && [ -n "$major_after" ] && | ||
[ -n "$minor_before" ] && [ -n "$minor_after" ] && | ||
[ -n "$patch_before" ] && [ -n "$patch_after" ] && | ||
( [ "$major_after" -gt "$major_before" ] || | ||
[ "$major_before" -eq "$major_after" -a "$minor_after" -gt "$minor_before" ] || | ||
[ "$major_before" -eq "$major_after" -a "$minor_before" -eq "$minor_after" -a "$patch_after" -gt "$patch_before" ] ); then | ||
return; | ||
else | ||
version_update_needed+=($project) | ||
fi | ||
fi | ||
else | ||
version_update_needed+=($project) | ||
fi | ||
fi | ||
} | ||
|
||
|
||
# check version update was made for all framework packages which includes changes | ||
for dir in $(git diff --name-only | grep '^src/framework/' | xargs -n1 dirname | sort -u | grep -v '^src/framework$'); do | ||
check_version_update $dir | ||
done | ||
|
||
# return all packages that still need a version update | ||
for dir in "${version_update_needed[@]}"; do | ||
echo "$dir" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters