1+ name : Publish PSGraph.Common NuGet Package
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - dev
8+
9+ jobs :
10+ build-and-publish :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout repository
15+ uses : actions/checkout@v4
16+
17+ - name : Setup .NET
18+ uses : actions/setup-dotnet@v4
19+ with :
20+ dotnet-version : ' 9.0.x'
21+
22+ - name : Restore dependencies
23+ run : dotnet restore PSGraph.Common/PSGraph.Common.csproj
24+
25+ - name : Set Version Suffix for Pre-release
26+ if : github.ref == 'refs/heads/dev'
27+ run : |
28+ VERSION_SUFFIX="beta-$(date +%Y%m%d%H%M%S)"
29+ echo "VERSION_SUFFIX=$VERSION_SUFFIX" >> $GITHUB_ENV
30+
31+ - name : Build (Debug on dev, Release on main)
32+ run : |
33+ if [ "${{ github.ref }}" = "refs/heads/dev" ]; then
34+ dotnet build PSGraph.Common/PSGraph.Common.csproj --configuration Debug --no-restore
35+ else
36+ dotnet build PSGraph.Common/PSGraph.Common.csproj --configuration Release --no-restore
37+ fi
38+
39+ - name : Pack (Debug/pre-release on dev, Release on main)
40+ run : |
41+ if [ "${{ github.ref }}" = "refs/heads/dev" ]; then
42+ dotnet pack PSGraph.Common/PSGraph.Common.csproj \
43+ --configuration Debug \
44+ --no-build \
45+ --output ./nupkg \
46+ --version-suffix $VERSION_SUFFIX
47+ else
48+ dotnet pack PSGraph.Common/PSGraph.Common.csproj \
49+ --configuration Release \
50+ --no-build \
51+ --output ./nupkg
52+ fi
53+
54+ - name : Publish to NuGet
55+ run : dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
56+ env :
57+ NUGET_API_KEY : ${{ secrets.NUGET_API_KEY }}
0 commit comments