This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
Publish Nuget Packages #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Publish Nuget Packages | |
on: | |
workflow_dispatch: # Allow running the workflow manually from the GitHub UI | |
release: | |
types: | |
- published # Run the workflow when a new GitHub release is published | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
NuGetDirectory: ${{ github.workspace}}/nuget | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
create_nuget: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
# Install the .NET SDK indicated in the global.json file | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
# Create the NuGet packages in the folder from the environment variable NuGetDirectory | |
- run: dotnet pack ./src/OneWare.Essentials/OneWare.Essentials.csproj --configuration Release --output ${{ env.NuGetDirectory }} | |
# 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 | |
} |