Skip to content

Commit

Permalink
chore: adjust nuget scripts
Browse files Browse the repository at this point in the history
Refs: CPLP-3400
  • Loading branch information
Phil91 committed Nov 14, 2023
1 parent 9b44a82 commit 2594078
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 63 deletions.
116 changes: 116 additions & 0 deletions scripts/check_local_version_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
###############################################################
# Copyright (c) 2021, 2023 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

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

# get the directory.build files to check the updated versions
IFS=$'\n' read -d '' -ra updatedVersions < <(git diff HEAD --name-only | grep 'Directory.Build.props')

check_version_update(){
local directory="$1"
local updated_name="$2"
local props_file="src/framework/"$(basename "$directory")"/Directory.Build.props"
# Check if the Directory.Builds.props file exists
if [[ " ${updatedVersions[@]} " =~ " $props_file " ]]; then
already_checked_projects+=($directory)
# Update the depending solutions
update_csproj_files_recursive "$updated_name"
else
version_update_needed+=($directory)
already_checked_projects+=($directory)
update_csproj_files_recursive "$updated_name"
fi
}

# Function to search and check the version update recursively
update_csproj_files_recursive() {
local updated_name="$1"

for dir in ./src/Framework/*/; do
if [ -d "$dir" ]; then
csproj_files=("$dir"*.csproj)
for project_file in "${csproj_files[@]}"; do
if grep -q "$updated_name" "$project_file"; then
project=$(basename "$dir")
if [[ ! " ${already_checked_projects[*]} " == *"$project"* ]]; then
check_version_update "$dir" "$project"
if [[ ! " ${already_checked_projects[*]} " == *"$project"* ]]; then
already_checked_projects+=("$project")
fi
fi
fi
done
fi
done

# Recursively update projects that depend on the updated projects
for project_name in "${projects_to_update[@]}"; do
# Only update projects if they haven't been updated before
if [[ ! " ${already_checked_projects[*]} " == *"$project_name"* ]]; then
update_csproj_files_recursive "$project_name"
fi
done
}

# iterate over directories in the Framework directory and check if the version was updated
iterate_directories() {
local updated_name="$1"

for dir in ./src/framework/*/; do
if [ -d "$dir" ]; then
if [[ $dir == "./src/framework/$updated_name/" ]]; then
check_version_update "$dir" "$updated_name"
if [[ ! " ${projects_to_update[*]} " == *"$updated_name"* ]]; then
projects_to_update+=("$updated_name")
fi
if [[ ! " ${already_checked_projects[*]} " == *"$updated_name"* ]]; then
already_checked_projects+=("$updated_name")
fi
fi
fi
done

# Update all projects that depend on the updated projects recursively
for project_name in "${projects_to_update[@]}"; do
# Only update projects if they haven't been updated before
if [[ ! " ${already_checked_projects[*]} " == *"$project_name"* ]]; then
update_csproj_files_recursive "$project_name"
fi
done
}

# find out which directories were changed with the last push
IFS=$'\n' read -d '' -ra changedPackages < <(git diff HEAD --name-only | xargs dirname | sort | uniq | grep '^src/framework/.*')

if [ ! -z "${changedPackages[*]}" ]; then
for dir in "${changedPackages[@]}"; do
package="$(basename "$dir")"
iterate_directories "$package"
done
fi

# return all packages that still need a version update
for dir in "${version_update_needed[@]}"; do
echo "$dir"
done
29 changes: 19 additions & 10 deletions scripts/check_push_version_update.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
#!/bin/bash

# Check if the correct number of arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <baseBranch> <currentBranch>"
exit 1
fi
###############################################################
# Copyright (c) 2021, 2023 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
###############################################################

# Assign the arguments to variables
baseBranch="$1"
currentBranch="$2"
#!/bin/bash

# Initialize a global arrays to store data
projects_to_update=()
Expand Down
30 changes: 28 additions & 2 deletions scripts/pack_and_push_packages.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
###############################################################
# Copyright (c) 2021, 2023 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

# Check if the correct number of arguments are provided
Expand Down Expand Up @@ -36,10 +55,17 @@ done

case "$nugetSource" in
local)
dotnet nuget push "$folderPath/*" --source "local"
for packageFile in "$folderPath"/*.nupkg; do
dotnet nuget push "$packageFile" --source "local"
done
;;
nuget)
dotnet nuget push "$folderPath/*" --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
for packageFile in "$folderPath"/*.nupkg; do
dotnet nuget push "$packageFile" --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
done
for packageFile in "$folderPath"/*.snupkg; do
dotnet nuget push "$packageFile" --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
done
;;
*)
echo "Invalid nuget source argument. Valid options: local, nuget"
Expand Down
34 changes: 0 additions & 34 deletions scripts/push.sh

This file was deleted.

1 change: 0 additions & 1 deletion src/framework/Framework.Async/Framework.Async.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Async</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Async</Title>
<Authors>TractusX</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Authorization</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Authorization</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Cors/Framework.Cors.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Cors</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Cors</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.DBAccess/Framework.DBAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess</Title>
<Authors>TractusX</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider</Title>
<Authors>TractusX</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.DependencyInjection</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.DependencyInjection</Title>
<Authors>TractusX</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library</Title>
<Authors>TractusX</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web</Title>
<Authors>TractusX</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.HttpClientExtensions</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.HttpClientExtensions</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.IO/Framework.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.IO</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.IO</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Linq/Framework.Linq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Linq</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Linq</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Logging/Framework.Logging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Logging</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Logging</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Models/Framework.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Models</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Models</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Seeding/Framework.Seeding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Swagger/Framework.Swagger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Swagger</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Swagger</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Token/Framework.Token.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Token</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Token</Title>
<Authors>TractusX</Authors>
Expand Down
1 change: 0 additions & 1 deletion src/framework/Framework.Web/Framework.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

<!-- nuget specific config-->
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Org.Eclipse.TractusX.Portal.Backend.Framework.Web</PackageId>
<Title>Org.Eclipse.TractusX.Portal.Backend.Framework.Web</Title>
<Authors>TractusX</Authors>
Expand Down

0 comments on commit 2594078

Please sign in to comment.