Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Aug 9, 2024
1 parent deff6ea commit bc600c3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
branches: [ main, dev ]

jobs:
build:
Expand All @@ -14,18 +12,35 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore
run: dotnet build -c Release --no-restore /p:ContinuousIntegrationBuild=true

- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test -c Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Code Coverage Report
uses: irongut/[email protected]
if: matrix.os == 'ubuntu-latest'
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: text
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
39 changes: 29 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,59 @@ on:

permissions:
contents: write # important for release description edit and asset upload
packages: write

jobs:
build:
name: Build
build-and-publish:
name: Build and Publish

runs-on: ubuntu-latest

env:
GH_TOKEN: ${{ github.token }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set release information
run: gh release edit ${{ github.ref_name }} -n "$(echo -e '***[Pre-release is being automatically created, please wait...](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})***\n\n${{ github.event.release.body }}')"

- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7.0.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore
run: dotnet build -c Release --no-restore /p:ContinuousIntegrationBuild=true

- name: Test
run: dotnet test -c Release --no-build --verbosity normal
run: dotnet test -c Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Upload the package to this release
run: gh release upload ${{ github.ref_name }} MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg
- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: text
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'

- name: Publish the package to nuget.org
run: dotnet nuget push MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json

- name: Publish the package to github.com
run: dotnet nuget push MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bigbang1112/index.json

- name: Upload the package to this release
run: gh release upload ${{ github.ref_name }} MinimalXmlReader/bin/Release/MinimalXmlReader.*.nupkg

- name: Set release information
run: gh release edit ${{ github.ref_name }} -n "$(echo -e '${{ github.event.release.body }}\n\nAssets were automatically generated using the [publish workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).')"

0 comments on commit bc600c3

Please sign in to comment.