-
-
Notifications
You must be signed in to change notification settings - Fork 85
73 lines (65 loc) · 2.3 KB
/
release.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Release to NuGet
on:
push:
pull_request:
branches:
- master
- dev
release:
types: [published]
env:
NuGetDirectory: ${{ github.workspace}}/nuget
jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
- name: Install Dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run Tests
run: dotnet test --no-restore --verbosity normal
create_nuget_package:
runs-on: ubuntu-latest
needs: [run_tests]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
# Create the NuGet package in the folder from the environment variable NuGetDirectory
- name: Create Nuget Package
run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
# Publish the NuGet package as an artifact, so they can be used in the following jobs
- name: Pushlish Nuget Package
uses: actions/upload-artifact@v3
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
deploy_nuget_package:
if: github.event_name == 'Release'
runs-on: ubuntu-latest
needs: [run_tests, create_nuget_package]
steps:
# Download the nuget packages that created in the previous job
- name: Download Nuget Packages
uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
# 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 to nuget.org
run: |
foreach(file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}