Skip to content

Simplify and enhance NuGet publish workflow with flexible tag trigger… #3

Simplify and enhance NuGet publish workflow with flexible tag trigger…

Simplify and enhance NuGet publish workflow with flexible tag trigger… #3

Workflow file for this run

name: Publish to NuGet
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Extract version from tag
id: get_version
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "VERSION=$TAG_NAME" >> $GITHUB_OUTPUT
echo "Building version: $TAG_NAME"
- name: Build library with version
run: dotnet build -c Release /p:Version=${{ steps.get_version.outputs.VERSION }} ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj
- name: Pack NuGet package
run: dotnet pack -c Release --no-build /p:Version=${{ steps.get_version.outputs.VERSION }} ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj -o ./artifacts
- name: Publish to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ steps.get_version.outputs.VERSION }}
tag_name: ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
files: ./artifacts/*.nupkg
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}