CD/CD consolidation
This commit is contained in:
36
devops/tools/sdk-scripts/publish.sh
Normal file
36
devops/tools/sdk-scripts/publish.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Publishes signed NuGet packages to a configured feed (file or HTTP).
|
||||
|
||||
PACKAGES_GLOB=${PACKAGES_GLOB:-"out/sdk/*.nupkg"}
|
||||
SOURCE=${SDK_NUGET_SOURCE:-".nuget/packages/packages"}
|
||||
API_KEY=${SDK_NUGET_API_KEY:-""}
|
||||
|
||||
mapfile -t packages < <(ls $PACKAGES_GLOB 2>/dev/null || true)
|
||||
if [[ ${#packages[@]} -eq 0 ]]; then
|
||||
echo "No packages found under glob '$PACKAGES_GLOB'; nothing to publish."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
publish_file() {
|
||||
local pkg="$1"
|
||||
mkdir -p "$SOURCE"
|
||||
cp "$pkg" "$SOURCE"/
|
||||
}
|
||||
|
||||
publish_http() {
|
||||
local pkg="$1"
|
||||
dotnet nuget push "$pkg" --source "$SOURCE" --api-key "$API_KEY" --skip-duplicate
|
||||
}
|
||||
|
||||
if [[ "$SOURCE" =~ ^https?:// ]]; then
|
||||
if [[ -z "$API_KEY" ]]; then
|
||||
echo "SDK_NUGET_API_KEY is required for HTTP source $SOURCE" >&2
|
||||
exit 1
|
||||
fi
|
||||
for pkg in "${packages[@]}"; do publish_http "$pkg"; done
|
||||
else
|
||||
for pkg in "${packages[@]}"; do publish_file "$pkg"; done
|
||||
fi
|
||||
|
||||
echo "Published ${#packages[@]} package(s) to $SOURCE"
|
||||
Reference in New Issue
Block a user