Skip to content

Publish Nuget Packages #15

Publish Nuget Packages

Publish Nuget Packages #15

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Publish Nuget Packages
on:
workflow_dispatch: ## manual
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Generate version number
id: generate_version
run: |
date=$(date +'%Y.%m.%d')
rev=$(git rev-list --all --count HEAD)
echo "Revision: $rev"
version="$date.$rev"
echo "version=$version" >> $GITHUB_ENV
echo "Generated version: $version"
# echo "version=$date.$rev" >> $GITHUB_ENV
# echo "version = $date.$rev" >> $GITHUB_OUTPUT
- name: Pack the project
run: dotnet pack --no-build --configuration Release -p:PackageVersion=${{ env.version }}
- name: Push to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} # Store your NuGet API key as a GitHub secret
run: dotnet nuget push '**/*.nupkg' --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY