1+ # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+ name : publish
4+ on :
5+ workflow_dispatch : # Allow running the workflow manually from the GitHub UI
6+ push :
7+ branches : # This action will run on PR to these branches
8+ - main
9+ - next
10+ pull_request :
11+ branches :
12+ - ' *' # Run the workflow for all pull requests
13+ release :
14+ types :
15+ - published # Run the workflow when a new GitHub release is published
16+
17+ env :
18+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : 1
19+ DOTNET_NOLOGO : true
20+ NuGetDirectory : ${{github.workspace}}/nuget
21+
22+ defaults :
23+ run :
24+ shell : pwsh
25+
26+ jobs :
27+ pack :
28+ runs-on : windows-latest
29+ steps :
30+ - name : Checkout
31+ uses : actions/checkout@v4
32+ with :
33+ fetch-depth : 0 # Get all history to allow automatic versioning using MinVer
34+
35+ - name : Install .NET Core
36+ uses : actions/setup-dotnet@v4
37+ with :
38+ dotnet-version : 9.0.x
39+
40+ - name : Restore dependencies
41+ run : dotnet restore
42+
43+ - name : Build
44+ run : dotnet build --configuration Release --no-restore
45+
46+ - name : Execute unit tests
47+ run : dotnet test --configuration Release -p:CollectCoverage=true -p:CoverletOutput=TestResults/ -p:CoverletOutputFormat=opencover --no-build --verbosity normal
48+
49+ - name : Create Test Coverage Badge
50+ uses : simon-k/dotnet-code-coverage-badge@v1.0.0
51+ id : create_coverage_badge
52+ with :
53+ label : Unit Test Coverage
54+ color : brightgreen
55+ path : mermaid-graphTests/TestResults/coverage.opencover.xml
56+ gist-filename : MermaidGraph.NET.code-coverage.json
57+ gist-id : 24afd0c237dc4c9b56453dce09b24687
58+ gist-auth-token : ${{ secrets.GIST_AUTH_TOKEN }}
59+
60+ - name : Print code coverage
61+ run : echo "Code coverage percentage ${{steps.create_coverage_badge.outputs.percentage}}%"
62+
63+ # Create the NuGet package in the folder from the environment variable NuGetDirectory
64+ - run : dotnet pack --configuration Release --no-build --output ${{env.NuGetDirectory}}
65+
66+ # Publish the NuGet package as an artifact, so they can be used in following jobs
67+ - uses : actions/upload-artifact@v3
68+ with :
69+ name : nuget
70+ if-no-files-found : error
71+ retention-days : 7
72+ path : ${{env.NuGetDirectory}}/*.nupkg
73+
74+ # deploy:
75+ # # Publish only when creating a GitHub Release
76+ # # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
77+ # # You can update this logic if you want to manage releases differently
78+ # if: github.event_name == 'release'
79+ # runs-on: windows-latest
80+ # needs: [ pack ]
81+ # steps:
82+ # # Download the NuGet package created in the previous job
83+ # - uses: actions/download-artifact@v3
84+ # with:
85+ # name: nuget
86+ # path: ${{env.NuGetDirectory}}
87+
88+ # # Install the .NET SDK indicated in the global.json file
89+ # - name: Setup .NET Core
90+ # uses: actions/setup-dotnet@v4
91+
92+ # # Publish all NuGet packages to NuGet.org
93+ # # Use --skip-duplicate to prevent errors if a package with the same version already exists.
94+ # # If you retry a failed workflow, already published packages will be skipped without error.
95+ # - name: Publish NuGet package
96+ # run: |
97+ # foreach($file in (Get-ChildItem "${{env.NuGetDirectory}}" -Recurse -Include *.nupkg)) {
98+ # dotnet nuget push $file --api-key "${{secrets.NUGET_APIKEY}}" --source https://api.nuget.org/v3/index.json --skip-duplicate
99+ # }
0 commit comments