Deploy to NuGet. #2
Workflow file for this run
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: Deploy to NuGet. | |
on: | |
create | |
env: | |
BUILD_CONFIGURATION: Release | |
PROJECT_PATH: 'src/Serilog.FluentDestructuring/Serilog.FluentDestructuring.csproj' | |
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}/output | |
NUGET_SOURCE_URL: 'https://api.nuget.org/v3/index.json' | |
jobs: | |
deploy_to_nuget: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/heads/release/') | |
steps: | |
- name: Checkout. | |
uses: actions/checkout@v4 | |
- name: Get package version. | |
run: | | |
Write-Host "Github ref: $Env:GITHUB_REF" | |
$version = .\scripts\GetPackageVersion.ps1 -RowContainingPackageVersion $Env:GITHUB_REF | |
if ($version -eq $null) { | |
Write-Error "Package version not found." | |
exit 1 | |
} | |
if ($Env:GITHUB_REF -notlike "*$version") { | |
Write-Error "Invalid branch title format." | |
exit 1 | |
} | |
echo "PACKAGE_VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append | |
shell: pwsh | |
- name: Install .NET. | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies. | |
run: dotnet restore ${{ env.PROJECT_PATH }} | |
- name: Build. | |
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration ${{ env.BUILD_CONFIGURATION }} | |
- name: Pack. | |
run: dotnet pack ${{ env.PROJECT_PATH }} --no-restore --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --include-symbols -p:PackageVersion=${{ env.PACKAGE_VERSION }} --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }} | |
- name: Push. | |
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s ${{ env.NUGET_SOURCE_URL }} |