1+ name : .NET Core
2+ on :
3+ pull_request :
4+ release :
5+ types :
6+ - published
7+ env :
8+ # Stop wasting time caching packages
9+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
10+ # Disable sending usage data to Microsoft
11+ DOTNET_CLI_TELEMETRY_OPTOUT : true
12+ # Project name to pack and publish
13+ PROJECT_NAME : Synercoding.Primitives
14+ # GitHub Packages Feed settings
15+ GITHUB_FEED : https://nuget.pkg.github.com/test-net-core-actions/
16+ GITHUB_USER : synercoder
17+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
18+ # Official NuGet Feed settings
19+ NUGET_FEED : https://api.nuget.org/v3/index.json
20+ NUGET_KEY : ${{ secrets.NUGET_KEY }}
21+ jobs :
22+ build :
23+ runs-on : ${{ matrix.os }}
24+ strategy :
25+ matrix :
26+ os : [ ubuntu-latest, windows-latest, macos-latest ]
27+ steps :
28+ - name : Checkout
29+ uses : actions/checkout@v2
30+ - name : Setup .NET Core
31+ uses : actions/setup-dotnet@v1
32+ with :
33+ dotnet-version : 3.1.x
34+ - name : Restore
35+ run : dotnet restore
36+ - name : Build
37+ run : dotnet build -c Release --no-restore
38+ - name : Test
39+ run : dotnet test -c Release
40+ - name : Pack
41+ if : matrix.os == 'ubuntu-latest'
42+ run : dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:SymbolPackageFormat=snupkg -p:PackageVersion=$GITHUB_RUN_ID src/$PROJECT_NAME/$PROJECT_NAME.*proj
43+ - name : Upload Artifact
44+ if : matrix.os == 'ubuntu-latest'
45+ uses : actions/upload-artifact@v2
46+ with :
47+ name : nupkg
48+ path : ./artifacts/pkg/Release/${{ env.PROJECT_NAME }}.*.nupkg
49+ prerelease :
50+ needs : build
51+ if : github.ref == 'refs/heads/develop'
52+ runs-on : ubuntu-latest
53+ steps :
54+ - name : Download Artifact
55+ uses : actions/download-artifact@v1
56+ with :
57+ name : nupkg
58+ - name : Push to GitHub Feed
59+ run : |
60+ for f in ./nupkg/*.nupkg
61+ do
62+ curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
63+ done
64+ deploy :
65+ needs : build
66+ if : github.event_name == 'release'
67+ runs-on : ubuntu-latest
68+ steps :
69+ - uses : actions/checkout@v2
70+ - name : Setup .NET Core
71+ uses : actions/setup-dotnet@v1
72+ with :
73+ dotnet-version : 3.1.x
74+ - name : Create Release NuGet package
75+ run : |
76+ arrTag=(${GITHUB_REF//\// })
77+ VERSION="${arrTag[2]}"
78+ echo Version: $VERSION
79+ VERSION="${VERSION//v}"
80+ echo Clean Version: $VERSION
81+ dotnet pack -v normal -c Release --include-symbols --include-source -p:SymbolPackageFormat=snupkg -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.*proj
82+ - name : Push to GitHub Feed
83+ run : |
84+ for f in ./nupkg/*.nupkg
85+ do
86+ curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
87+ done
88+ - name : Push to NuGet Feed
89+ if : ${{ env.NUGET_FEED }} != ''
90+ run : dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY
0 commit comments