Skip to content

Merge pull request #158 from MueckeMa/feature/fixBuild #514

Merge pull request #158 from MueckeMa/feature/fixBuild

Merge pull request #158 from MueckeMa/feature/fixBuild #514

Workflow file for this run

name: Build
permissions:
contents: write
packages: write
on:
push:
branches: [ main ]
pull_request:
types: [opened, synchronize, reopened, closed]
branches: [ main ]
env:
configuration: Release
productNamespacePrefix: "MQTTnet.Extensions.External.RxMQTT"
jobs:
build:
runs-on: ubuntu-latest
outputs:
nbgv: ${{ steps.nbgv.outputs.SemVer2 }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
with:
setAllVars: true
- name: Restore
run: dotnet restore
working-directory: src
- name: Build
run: dotnet build -v:minimal -c:${{ env.configuration }}
working-directory: src
- name: Pack
run: dotnet pack --no-build -v:minimal -c:${{ env.configuration }}
working-directory: src
- name: Install Report Generator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Run Unit Tests
run: dotnet test --no-build -c:${{ env.configuration }} --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
working-directory: src
- name: Generate Coverage Report
run: reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:report-output
working-directory: src
- name: Upload Code Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos, otherwise set api token in repository secrets
files: "*/coverage.cobertura.xml"
directory: src
- name: Create NuGet Artifacts
uses: actions/upload-artifact@v4
with:
name: nuget
path: '**/*.nupkg'
release:
runs-on: ubuntu-latest
needs: build
if: contains(github.event.pull_request.labels.*.name, 'release') && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download NuGet Packages
uses: actions/download-artifact@v4
with:
name: nuget
- name: Changelog
uses: glennawatson/ChangeLog@v1
id: changelog
- name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
tag_name: ${{ needs.build.outputs.nbgv }}
name: ${{ needs.build.outputs.nbgv }}
body: |
${{ steps.changelog.outputs.commitLog }}
- name: NuGet Push
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }} # Set nuget api token in repository secrets
SOURCE_URL: https://api.nuget.org/v3/index.json
run: |
dotnet nuget push -s ${{ env.SOURCE_URL }} -k ${{ env.NUGET_AUTH_TOKEN }} **/*.nupkg