-
Notifications
You must be signed in to change notification settings - Fork 19
86 lines (75 loc) · 2.86 KB
/
CoreBuild.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
name: Build And Publish
on:
workflow_call:
inputs:
nugetVersion:
description: 'nuget version number x.y.z.w'
required: false
type: string
nugetVersionSpecific:
description: 'nuget version number z.w for specific packages'
required: false
type: string
nugetPreviewName:
description: 'nuget preview ?'
required: false
type: string
nugetPackageIdPrefix:
description: 'NuGet PackageId prefix (include the period if necessary)'
required: false
type: string
publish:
description: 'Publish to nuget.org?'
type: string
required: true
secrets:
NUGET_API_KEY:
required: true
env:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
netStandardVersion: '${{ github.event.inputs.nugetVersion }}'
netStandardVersionNuget: '${{ github.event.inputs.nugetVersion }}${{ github.event.inputs.nugetPreviewName }}'
PublishToNuget: ${{ github.event.inputs.publish }}
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
9.0.100
- name: Set the NuGet PackageId in the project files
run: .\src\Builds\SetNuGetPackageIdPrefix.ps1 ".." "${{ github.event.inputs.nugetPackageIdPrefix }}"
shell: powershell
- name: setup nuget
uses: nuget/setup-nuget@v1
with:
nuget-version: latest
- name: nuget restore
run: dotnet restore .\src\arc4u.sln
- name: build
run: dotnet build .\src\arc4u.sln --configuration ${{env.buildConfiguration}} /p:Version=${{env.netStandardVersionNuget}}
- name: Run Test projects matching *UnitTest.csproj with filter Category = CI
run: |
Get-ChildItem -Filter *.*UnitTest.csproj -Recurse | ForEach-Object { dotnet test $_.FullName --no-restore -c ${{ env.buildConfiguration }} --filter 'Category = CI' }
shell: pwsh
- name: Copy the nuget packages to a folder to have only one published.
run: |
md .\packages
Get-ChildItem -Path .\ -Recurse -Filter *.nupkg | ForEach-Object { Copy-Item -Path $_.FullName -Destination (".\packages\"+$_.Name) }
shell: pwsh
- name: Save nuget packages
if: ${{ env.PublishToNuget == 'false' }}
uses: actions/upload-artifact@v3
with:
name: artifact
path: |
./packages
retention-days: 1
- name: Publish packages
if: ${{ env.PublishToNuget == 'true' }}
run: dotnet nuget push ".\packages\*.nupkg" --skip-duplicate --no-symbols --api-key ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json