-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (119 loc) · 4.96 KB
/
pipeline.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: build
on:
push:
branches: [ "main", "develop" ]
tags:
- '*'
pull_request:
branches:
- '*'
release:
types:
- published
workflow_dispatch:
inputs:
publishPack:
description: 'publish nuget packages'
required: false
default: false
type: boolean
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: ${{github.workspace}}/src
# Configuration type to build.
# You can convert this to a build matrix if you need coverage of multiple configuration types.
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
BUILD_CONFIGURATION: Release
BUILD_PLATFORM: Any CPU
NUGET_OUTPUT_PATH: ${{github.workspace}}/nuget
MANUAL_PUBLISH_PACK: ${{github.event.inputs.publishPack && github.event.inputs.publishPack != 'false'}}
GITHUB_EVENT_NAME: ${{github.event_name}}
GITHUB_REF: ${{github.ref}}
FROM_TAG_PUBLISH_PACK: ${{ github.event_name == 'push' && (contains(github.ref, '/heads/main') || contains(github.ref, '/tags/v')) }}
permissions:
contents: read
defaults:
run:
shell: pwsh
jobs:
build:
runs-on: windows-2022
steps:
- name: echo variables
env:
PUBLISH_PACK: ${{github.event.inputs.publishPack}}
run: |
Write-Host "This step shows the 'env' variables currently set"
- name: git | checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: .NET | setup
uses: microsoft/setup-msbuild@v1.0.2
- name: CACHE | nuget
uses: actions/cache@v2.1.8
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ~/.nuget/packages
# An explicit key for restoring and saving the cache
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files
# An ordered list of keys to use for restoring the cache if no cache hit occurred for key
restore-keys: |
${{ runner.os }}-nuget-
# The chunk size used to split up large files during upload, in bytes
# upload-chunk-size: # optional
- name: NuGet | restore packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
- name: .NET | build
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:platform="${{env.BUILD_PLATFORM}}" ${{env.SOLUTION_FILE_PATH}}
- name: .NET | test setup
uses: darenm/Setup-VSTest@v1.2
- name: .NET | test
uses: tonyhallett/vstest-solution-action@v1.0.2
with:
solution: "/src/NLog.Targets.Bugsnag.sln"
configuration: ${{env.BUILD_CONFIGURATION}}
- name: .NET | upload artifact
uses: actions/upload-artifact@v3.1.2
with:
name: build-output
if-no-files-found: error
path: ${{env.SOLUTION_FILE_PATH}}
- name: .NET | prepare package
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /t:pack /p:PackageOutputPath="${{env.NUGET_OUTPUT_PATH}}" /p:NoBuild=true /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:platform="${{env.BUILD_PLATFORM}}" ${{env.SOLUTION_FILE_PATH}}
- name: NuGet | upload artifact
uses: actions/upload-artifact@v3.1.2
with:
name: nuget-output
if-no-files-found: error
path: ${{env.NUGET_OUTPUT_PATH}}
publish:
runs-on: windows-2022
needs: [ build ]
if: ${{ (github.event.inputs.publishPack && github.event.inputs.publishPack != 'false') || (github.event_name == 'push' && (contains(github.ref, '/heads/main') || contains(github.ref, '/tags/v'))) }}
steps:
- name: NuGet | download artifact
uses: actions/download-artifact@v3
with:
name: nuget-output
path: ${{env.NUGET_OUTPUT_PATH}}
- name: NuGet | push
# You may pin to the exact commit or the version.
# uses: edumserrano/nuget-push@2c99a0cae97df631eb2526ddd171a55dd5228289
uses: edumserrano/nuget-push@v1.2.2
with:
# The API key for the NuGet server. Used when pushing the NuGet packages and symbols.
api-key: ${{secrets.NUGET_PAT}}
# Indicates whether this actions should fail if the NuGet package being pushed already exists. Defaults to false.
fail-if-exists: false
# The directory that will be used to push NuGet packages. It will push all NuGet packages (*.nupkg) and corresponding symbol packages (*.snupkg) present in the directory.
working-directory: "${{env.NUGET_OUTPUT_PATH}}"