Release: Publish to NuGet #14
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
name: 'Release: Publish to NuGet' | |
on: | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: 'The reason for running the workflow' | |
required: true | |
default: 'Manual run' | |
jobs: | |
createArtifacts: | |
name: Generate NuGet Packages | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_PATH: './src/CSharpFunctionalExtensions.FluentAssertions/CSharpFunctionalExtensions.FluentAssertions.csproj' | |
steps: | |
- uses: actions/checkout@v3 | |
#- name: Set Environment Variables | |
# uses: ./.github/actions/set-env | |
- uses: actions/checkout@v2 | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 6.0.x | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build -c Release --no-restore | |
- name: Create PreRelease Artifact | |
run: dotnet pack ${{ env.PROJECT_PATH }} -c Release --no-build --include-symbols -o ./artifacts/prerelease --version-suffix prerelease-$GITHUB_RUN_NUMBER-$GITHUB_RUN_ATTEMPT | |
- name: 'Save prerelease artifact' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: prerelease | |
path: ./artifacts/prerelease/* | |
- name: Create Release Artifact | |
run: dotnet pack ${{ env.PROJECT_PATH }} -c Release --no-build --include-symbols -o ./artifacts/release | |
- name: 'Save release artifact' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release | |
path: ./artifacts/release/* | |
publishPreRelease: | |
name: Publish PreRelease NuGet Package | |
environment: prerelease | |
needs: createArtifacts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: prerelease | |
- name: Publish NuGet Package | |
run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} | |
publishRelease: | |
name: Publish Release NuGet Package | |
environment: release | |
needs: [createArtifacts, publishPreRelease] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: release | |
- name: Publish NuGet Package | |
run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} |