Skip to content

Commit

Permalink
feat(nuget): adjust version check action
Browse files Browse the repository at this point in the history
Refs: CPLP-3400
  • Loading branch information
Phil91 committed Feb 6, 2024
1 parent 79d0191 commit eb6cccc
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 75 deletions.
41 changes: 2 additions & 39 deletions scripts/check_package_versions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -19,42 +19,5 @@

#!/bin/bash

# Get GitHub context from environment variables
baseBranch=release/v1.8.0-RC5
currentBranch=feature/CPLP-3400-framework-nuget

# Initialize a global arrays to store data
version_update_needed=()

# get the directory.build files to check the updated versions
changed_versions=($(git diff --name-only $baseBranch..$currentBranch | grep 'Directory.Build.props'))

check_version_update(){
local project="$1"
local props_file="src/framework/"$project"/Directory.Build.props"
if ! git diff --diff-filter=D --quiet "$baseBranch..$currentBranch" -- "$props_file" ||
! [ -s "$props_file" ]; then
break;
else
if [[ " ${changed_versions[@]} " =~ " $props_file " ]]; then
if ! git diff $baseBranch..$currentBranch -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionPrefix>[0-9]+\.[0-9]+\.[0-9]+</VersionPrefix>' &&
(! git diff $baseBranch..$currentBranch -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionSuffix></VersionSuffix>' && git diff $baseBranch..$currentBranch -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionSuffix>[^<]*</VersionSuffix>'); then
version_update_needed+=($project)
fi
else
version_update_needed+=($project)
fi
fi
}

for dir in ./src/framework/*/; do
if [ -d "$dir" ]; then
proj="$(basename "$dir")"
check_version_update $proj
fi
done

# return all packages that still need a version update
for dir in "${version_update_needed[@]}"; do
echo "$dir"
done
. ./scripts/nuget_version_check.sh "$BASE_NAME..$HEAD_NAME"
36 changes: 1 addition & 35 deletions scripts/check_package_versions_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,4 @@

#!/bin/bash

# Initialize a global arrays to store data
version_update_needed=()

# get the directory.build files to check the updated versions
changed_versions=($(git diff --name-only HEAD~1 | grep 'Directory.Build.props'))

check_version_update(){
local project="$1"
local props_file="src/framework/"$project"/Directory.Build.props"
if ! git diff --diff-filter=D --quiet HEAD~1 -- "$props_file" ||
! [ -s "$props_file" ]; then
break;
else
if [[ " ${changed_versions[@]} " =~ " $props_file " ]]; then
if ! git diff HEAD~1 -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionPrefix>[0-9]+\.[0-9]+\.[0-9]+</VersionPrefix>' &&
(! git diff HEAD~1 -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionSuffix></VersionSuffix>' && git diff HEAD~1 -- "$props_file" | grep -qE '^\+[[:space:]]*<VersionSuffix>[^<]*</VersionSuffix>'); then
version_update_needed+=($project)
fi
else
version_update_needed+=($project)
fi
fi
}

for dir in ./src/framework/*/; do
if [ -d "$dir" ]; then
proj="$(basename "$dir")"
check_version_update $proj
fi
done

# return all packages that still need a version update
for dir in "${version_update_needed[@]}"; do
echo "$dir"
done
. ./scripts/nuget_version_check.sh ""
86 changes: 86 additions & 0 deletions scripts/nuget_version_check.sh
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
2 changes: 1 addition & 1 deletion scripts/update_framework_versions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
# Copyright (c) 2024Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand Down

0 comments on commit eb6cccc

Please sign in to comment.