-
Notifications
You must be signed in to change notification settings - Fork 108
135 lines (116 loc) · 4.3 KB
/
build.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
name: .NET Core Build and Deploy
on:
push:
branches:
- master
paths-ignore:
- '**/*.md'
- '**/*.gitignore'
- '**/*.gitattributes'
- '**/*.all-contributorsrc'
- '**/devcontainer.json'
- '**/build.yml'
workflow_dispatch:
branches:
- master
paths-ignore:
- '**/*.md'
- '**/*.gitignore'
- '**/*.gitattributes'
- '**/*.all-contributorsrc'
- '**/devcontainer.json'
jobs:
build:
outputs:
version: ${{ steps.set_proj_version.outputs.PKG_VERSION }}
relnotes: ${{ steps.set_proj_version.outputs.RELNOTES }}
name: Build and package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
# Run the tests, ideally should stop here if a fail and also publish results as artifacts
- name: Test
uses: timheuer/dotnet-tests-report@master
with:
project_path: Alexa.NET.Tests/Alexa.NET.Tests.csproj
report_name: alexa_net_tests
report_title: Alexa.NET Tests
github_token: ${{ secrets.GITHUB_TOKEN }}
set_check_status_from_test_outcome: true
- name: Pack
run: dotnet pack --configuration Release -o finalpackage --no-build
- name: Publish artifact
uses: actions/upload-artifact@v3
with:
name: nupkg
path: finalpackage
- name: Get version
id: set_proj_version
shell: pwsh
run: |
[xml]$nuspec = Get-Content Alexa.NET\Alexa.NET.csproj
$version=$nuspec.project.propertygroup.versionprefix
$relnotes=$nuspec.project.propertygroup.packagereleasenotes
Write-Output "::set-output name=PKG_VERSION::$version"
Write-Output "::set-output name=RELNOTES::$relnotes"
deploy:
needs: build
environment:
name: production
url: https://www.nuget.org/packages/Alexa.NET/
name: Sign and publish
runs-on: windows-latest # using windows agent due to nuget can't sign on linux yet
steps:
- name: Download Package artifact
uses: actions/download-artifact@v3
with:
name: nupkg
- name: Setup NuGet
uses: NuGet/[email protected]
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: latest
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: 6.0.x
include-prerelease: true
- name: Get certificate
id: cert_file
uses: timheuer/base64-to-file@v1
with:
fileName: 'certfile.pfx'
encodedString: ${{ secrets.SIGNING_CERT }}
# Sign the package
- name: Sign NuGet Package
#run: nuget sign **/*.nupkg -CertificatePath ${{ steps.cert_file.outputs.filePath }} -CertificatePassword ${{ secrets.CERT_PWD }} -Timestamper http://timestamp.digicert.com -NonInteractive
run: dotnet nuget sign **/*.nupkg --certificate-path ${{ steps.cert_file.outputs.filePath }} --certificate-password ${{ secrets.CERT_PWD }} --timestamper http://timestamp.digicert.com
- name: Push to NuGet
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
- name: Add GPR Source
#run: nuget sources Add -Name "GPR" -Source ${{ secrets.GPR_URI }} -UserName ${{ secrets.GPR_USERNAME }} -Password ${{ secrets.GITHUB_TOKEN }}
run: dotnet nuget add source --username ${{ secrets.GPR_USERNAME }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name GPR ${{ secrets.GPR_URI }}
- name: Push to GitHub Packages
#run: nuget push **/*.nupkg -Source "GPR" -SkipDuplicate
run: dotnet nuget push **/*.nupkg -s "GPR" --skip-duplicate
- name: Tag and Release
id: tag_release
uses: softprops/[email protected]
with:
body: ${{ needs.build.outputs.relnotes }}
tag_name: ${{ needs.build.outputs.version }}
files: |
**/*.nupkg
- name: Publish signed artifact
uses: actions/upload-artifact@v3
with:
name: signednupkg
path: .