Skip to content

fix

fix #2

Workflow file for this run

name: Publish to NuGet
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0)'
required: true
type: string
permissions:
contents: write
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
publish:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
- name: Extract version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
echo "TAG_NAME=v${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Pack
run: dotnet pack Embed.Generator/Embed.Generator/Embed.Generator.csproj --configuration Release /p:Version=${{ steps.get_version.outputs.VERSION }} --output ./artifacts
- name: Publish to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub Release
uses: softprops/action-gh-release@v2.4.1
if: github.event_name == 'push' && github.ref_type == 'tag'
with:
tag_name: ${{ steps.get_version.outputs.TAG_NAME }}
name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
generate_release_notes: true
files: |
./artifacts/*.nupkg