1+ # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+ name : dotnet-CI
4+
5+ # Trigger the action on push to master
6+ on :
7+ push :
8+ branches :
9+ - master
10+
11+ # Sets permissions of the GITHUB_TOKEN to allow reading packages
12+ permissions :
13+ packages : read
14+
15+ env :
16+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : 1
17+ DOTNET_NOLOGO : true
18+ NUGET_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
19+ NuGetDirectory : ${{ github.workspace}}/nuget
20+
21+ defaults :
22+ run :
23+ shell : pwsh
24+
25+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
26+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
27+ concurrency :
28+ group : " ci"
29+ cancel-in-progress : false
30+
31+ jobs :
32+ Build :
33+ runs-on : ubuntu-latest
34+ steps :
35+ # Setup environment
36+ - name : Checkout
37+ uses : actions/checkout@v3
38+
39+ - name : Setup Dotnet
40+ uses : actions/setup-dotnet@v4
41+ with :
42+ source-url : https://nuget.pkg.github.com/MonkeyModdingTroop/index.json
43+
44+ # Cache NuGet packages
45+ - uses : actions/cache@v3
46+ with :
47+ path : ~/.nuget/packages
48+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
49+ restore-keys : |
50+ ${{ runner.os }}-nuget
51+
52+ # Build and test projects
53+ - name : Restore
54+ run : dotnet restore
55+
56+ - name : Build
57+ run : dotnet build --no-restore --configuration Release
58+
59+ - name : Test
60+ run : dotnet test --no-restore --no-build
61+
62+ # Publish the NuGet package(s) as an artifact, so they can be used in the following jobs
63+ - uses : actions/upload-artifact@v3
64+ with :
65+ name : nuget
66+ if-no-files-found : error
67+ retention-days : 7
68+ path : ./**/*.nupkg
69+
70+ " Validate NuGet " :
71+ runs-on : ubuntu-latest
72+ needs : [ Build ]
73+ steps :
74+ # Install the .NET SDK indicated in the global.json file
75+ - name : Setup Dotnet
76+ uses : actions/setup-dotnet@v4
77+
78+ # Cache NuGet packages
79+ - uses : actions/cache@v3
80+ with :
81+ path : ~/.nuget/packages
82+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
83+ restore-keys : |
84+ ${{ runner.os }}-nuget
85+
86+ - name : Install NuGet Validator
87+ run : dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
88+
89+ # Download the NuGet package created in the previous job
90+ - uses : actions/download-artifact@v3
91+ with :
92+ name : nuget
93+ path : ${{ env.NuGetDirectory }}
94+
95+ # Validate metadata and content of the NuGet package
96+ # https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
97+ # If some rules are not applicable, you can disable them
98+ # using the --excluded-rules or --excluded-rule-ids option
99+ - name : Validate Package(s)
100+ run : meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
0 commit comments