-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish-nuget.sh
More file actions
executable file
·52 lines (42 loc) · 1.27 KB
/
publish-nuget.sh
File metadata and controls
executable file
·52 lines (42 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
set -euo pipefail
# Usage: ./publish-nuget.sh <NUGET_API_KEY> [version]
# Example: ./publish-nuget.sh my-api-key 1.0.0
if [ $# -lt 1 ]; then
echo "Usage: $0 <NUGET_API_KEY> [version]"
echo " Get your API key from https://www.nuget.org/account/apikeys"
exit 1
fi
API_KEY="$1"
VERSION="${2:-}"
PROJECT="src/StreamDB/StreamDB.csproj"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# Override version if provided
VERSION_FLAG=""
if [ -n "$VERSION" ]; then
VERSION_FLAG="-p:Version=$VERSION"
echo "Publishing StreamDB v$VERSION"
else
echo "Publishing StreamDB (version from csproj)"
fi
# Clean previous artifacts
rm -rf ./artifacts/*.nupkg
rm -rf src/StreamDB/bin/Release/*.nupkg
# Build and pack
echo "Building and packing..."
dotnet pack "$PROJECT" -c Release $VERSION_FLAG --output ./artifacts
# Find the .nupkg
NUPKG=$(ls ./artifacts/StreamDB.*.nupkg 2>/dev/null | head -1)
if [ -z "$NUPKG" ]; then
echo "Error: No .nupkg found in ./artifacts/"
exit 1
fi
echo "Package: $NUPKG"
# Push to NuGet
echo "Pushing to nuget.org..."
dotnet nuget push "$NUPKG" \
--api-key "$API_KEY" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
echo "Done! Package published to https://www.nuget.org/packages/StreamDB"