Skip to content

Merge pull request #6 from Felix-CodingClimber/dev-felix #16

Merge pull request #6 from Felix-CodingClimber/dev-felix

Merge pull request #6 from Felix-CodingClimber/dev-felix #16

Workflow file for this run

name: PublishRelease
on:
push:
tags:
- "v*.*.*"
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace}}/nuget
TAG: ${{ github.ref_name }}
defaults:
run:
shell: pwsh
jobs:
create_nuget:
runs-on: ubuntu-latest
steps:
- name: Set Version Variable
run: |
$version = $env:TAG -replace '^v', ''
echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: checkout
uses: actions/checkout@v4
# Install the .NET SDK
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Create the NuGet package in the folder from the environment variable NuGetDirectory
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} /p:Version=${{ env.VERSION }} /p:PackageVersion=${{ env.VERSION }}
# Publish the NuGet package as an artifact, so they can be used in the following jobs
- name: uploadArtifacts
uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
deploy:
runs-on: ubuntu-latest
needs: [ create_nuget ]
steps:
# Download the NuGet package created in the previous job
- name: downloadArtifacts
uses: actions/download-artifact@v4
with:
name: nuget
path: ${{ env.NuGetDirectory }}
# Install the .NET SDK
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
- name: Publish NuGet package
run: |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}