Skip to content

Commit

Permalink
feat(nuget): add suffix check
Browse files Browse the repository at this point in the history
Refs: CPLP-3400
  • Loading branch information
Phil91 committed Feb 6, 2024
1 parent 096444f commit 74737f5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 38 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/nuget-package-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
name: Push Nuget Packages and Tag

on:
push:
paths:
- 'src/framework/**'
branches:
- 'dev'
- 'release/v*.*.*-RC*'
workflow_dispatch:

jobs:
Expand All @@ -44,15 +38,28 @@ jobs:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Install dependencies
run: dotnet restore src/framework
run: dotnet restore src

- name: Build
run: dotnet build src/framework --configuration Release --no-restore
run: dotnet build src --configuration Release --no-restore

- name: Check Package Suffix Versions
shell: bash
run: |
script_output=$(./scripts/no_suffix_check.sh)
if [ -z "$script_output" ]; then
echo "No version suffixes set"
else
echo "the following packages have a suffix version set, please remove them:"
echo "$script_output"
exit 1
fi
- name: Push nuget packages
shell: bash
run: |
bash ./scripts/pack_and_push_packages.sh ${{ secrets.NUGET_API_KEY }}
bash ./scripts/pack_and_push_packages.sh --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Get new version
id: nugetPackageVersion
Expand Down
29 changes: 29 additions & 0 deletions scripts/no_suffix_version_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###############################################################
# 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

for dir in ./src/framework/*/; do
if [ -d "$dir" ]; then
local props_file=$dir"Directory.Build.props"
if ! grep -qE "<VersionSuffix><\/VersionSuffix>" $props_file; then
echo $dir
fi
fi
done
10 changes: 1 addition & 9 deletions scripts/pack_and_push_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@

#!/bin/bash

# Check if the correct number of arguments are provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <nugetApiKey>"
exit 1
fi

# Assign the arguments to variables
NUGET_API_KEY="$1"
folderPath="./packages"

# Function to iterate over directories in the Framework directory and create a nuget package
Expand All @@ -43,7 +35,7 @@ iterate_directories() {
iterate_directories

for packageFile in "$folderPath"/*.nupkg; do
dotnet nuget push "$packageFile" --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push "$packageFile" "$@"
done

rm -r "$folderPath"
21 changes: 1 addition & 20 deletions scripts/pack_and_push_packages_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,4 @@

#!/bin/bash

folderPath="./packages"

# Function to iterate over directories in the Framework directory and create a nuget package
iterate_directories() {
for dir in ./src/framework/*/; do
if [ -d "$dir" ]; then
proj="$(basename "$dir")"
echo "Pack project: $proj"
dotnet pack src/framework/$proj/$proj.csproj -c Release -o "$folderPath"
fi
done
}

iterate_directories

for packageFile in "$folderPath"/*.nupkg; do
dotnet nuget push "$packageFile" --source "local" --skip-duplicate
done

rm -r "$folderPath"
. ./scripts/pack_and_push_packages.sh --source "local" --skip-duplicate

0 comments on commit 74737f5

Please sign in to comment.