-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (41 loc) · 1.78 KB
/
deploy-to-nuget.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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 }}