Skip to content

Add EventPi.NetworkMonitor to NuGet publishing workflow #4

Add EventPi.NetworkMonitor to NuGet publishing workflow

Add EventPi.NetworkMonitor to NuGet publishing workflow #4

Workflow file for this run

name: Publish NuGet Packages
on:
push:
tags:
- 'event-pi/*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.11.32)'
required: true
type: string
env:
DOTNET_VERSION: '10.0.x'
CONFIGURATION: Release
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
9.0.x
10.0.x
- name: Extract version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
# Extract version from tag format: event-pi/1.0.11.32
VERSION=${GITHUB_REF#refs/tags/event-pi/}
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Restore EventPi.Abstractions dependencies
run: dotnet restore src/EventPi.Abstractions/EventPi.Abstractions.csproj
- name: Build EventPi.Abstractions
run: dotnet build src/EventPi.Abstractions/EventPi.Abstractions.csproj --configuration ${{ env.CONFIGURATION }} --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }}
- name: Pack EventPi.Abstractions
run: |
dotnet pack src/EventPi.Abstractions/EventPi.Abstractions.csproj \
--configuration ${{ env.CONFIGURATION }} \
--no-build \
--output ./artifacts \
/p:PackageVersion=${{ steps.get_version.outputs.VERSION }}
- name: Restore EventPi.NetworkMonitor dependencies
run: dotnet restore src/EventPi.NetworkMonitor/EventPi.NetworkMonitor.csproj
- name: Build EventPi.NetworkMonitor
run: dotnet build src/EventPi.NetworkMonitor/EventPi.NetworkMonitor.csproj --configuration ${{ env.CONFIGURATION }} --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }}
- name: Pack EventPi.NetworkMonitor
run: |
dotnet pack src/EventPi.NetworkMonitor/EventPi.NetworkMonitor.csproj \
--configuration ${{ env.CONFIGURATION }} \
--no-build \
--output ./artifacts \
/p:PackageVersion=${{ steps.get_version.outputs.VERSION }}
- name: List artifacts
run: ls -lh ./artifacts
- name: Publish to NuGet.org
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages-${{ steps.get_version.outputs.VERSION }}
path: ./artifacts/*.nupkg
retention-days: 30