-
-
Notifications
You must be signed in to change notification settings - Fork 33
134 lines (114 loc) · 5.15 KB
/
build-and-publish.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
name: Build and Publish
on:
push:
branches: [ master ]
tags:
- '*'
pull_request:
branches: [ master ]
workflow_dispatch:
env:
CHANGELOG_PATH: ./Changelog.md
CODE_COVERAGE_PATH: ./Coverage.xml
RELOADED_HOOKS_NUPKG_GLOB: ./source/Reloaded.Hooks/bin/Release/*.nupkg
RELOADED_HOOKS_DEFINITIONS_NUPKG_GLOB: ./source/Reloaded.Hooks.Definitions/bin/Release/*.nupkg
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
RELEASE_TAG: ${{ github.ref_name }}
jobs:
build:
runs-on: windows-2022
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.9.0
with:
# Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x
dotnet-version: 6.0.x
- name: Setup .NET Core SDK 7.X
uses: actions/setup-dotnet@v1.9.0
with:
# Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x
dotnet-version: 7.0.x
include-prerelease: true
# Required for C#10 features.
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Setup AutoChangelog
run: npm install -g auto-changelog
- name: Get Dotnet Info
run: dotnet --info
- name: Build
run: dotnet build -c Release ./source/Reloaded.Hooks.sln
- name: Test
run: |
dotnet tool install --global altcover.global --version 8.2.833
$ipmo = (AltCover ImportModule | Out-String)
Invoke-Expression $ipmo
dotnet test -f net6.0 .\source\Reloaded.Hooks.Tests.X86\Reloaded.Hooks.Tests.X86.csproj /p:AltCover=true /p:CopyLocalLockFileAssemblies="true" /p:AltCoverAttributeFilter="ExcludeFromCodeCoverageAttribute" /p:AltCoverAssemblyExcludeFilter="Reloaded.Hooks.Tests.X86|Reloaded.Hooks.Tests.X64|Reloaded.Hooks.Tests.Shared|xunit\.*" /p:AltCoverTypeFilter="xunit\.*|AltCover\.*|Reloaded\.Assembler.*" /p:AltCoverReport="../../coverage-86.xml"
dotnet test -f net6.0 .\source\Reloaded.Hooks.Tests.X64\Reloaded.Hooks.Tests.X64.csproj /p:AltCover=true /p:CopyLocalLockFileAssemblies="true" /p:AltCoverAttributeFilter="ExcludeFromCodeCoverageAttribute" /p:AltCoverAssemblyExcludeFilter="Reloaded.Hooks.Tests.X86|Reloaded.Hooks.Tests.X64|Reloaded.Hooks.Tests.Shared|xunit\.*" /p:AltCoverTypeFilter="xunit\.*|AltCover\.*|Reloaded\.Assembler.*" /p:AltCoverReport="../../coverage-64.xml"
Get-ChildItem coverage-* | Merge-OpenCover -OutputFile "$env:CODE_COVERAGE_PATH" | Out-Null
choco install codecov -f -y | Out-Null
codecov -f $env:CODE_COVERAGE_PATH
- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b
uses: codecov/codecov-action@v2.1.0
with:
# Comma-separated list of files to upload
files: ${{ env.CODE_COVERAGE_PATH }}
- name: Create Changelog (on Tag)
run: |
if ($env:IS_RELEASE -eq 'true')
{
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --starting-version "$env:RELEASE_TAG" --output "$env:CHANGELOG_PATH"
}
else
{
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --output "$env:CHANGELOG_PATH"
}
- name: Upload NuGet Package Artifact
uses: actions/upload-artifact@v2.2.4
with:
# Artifact name
name: NuGet Packages
# A file, directory or wildcard pattern that describes what to upload
path: |
${{ env.RELOADED_HOOKS_NUPKG_GLOB }}
${{ env.RELOADED_HOOKS_DEFINITIONS_NUPKG_GLOB }}
- name: Upload Changelog Artifact
uses: actions/upload-artifact@v2.2.4
with:
# Artifact name
name: Changelog
# A file, directory or wildcard pattern that describes what to upload
path: ${{ env.CHANGELOG_PATH }}
retention-days: 0
- name: Upload to GitHub Releases
uses: softprops/action-gh-release@v0.1.14
if: env.IS_RELEASE == 'true'
with:
# Path to load note-worthy description of changes in release from
body_path: ${{ env.CHANGELOG_PATH }}
# Newline-delimited list of path globs for asset files to upload
files: |
${{ env.RELOADED_HOOKS_NUPKG_GLOB }}
${{ env.RELOADED_HOOKS_DEFINITIONS_NUPKG_GLOB }}
${{ env.CHANGELOG_PATH }}
- name: Upload to NuGet (on Tag)
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
if: env.IS_RELEASE == 'true'
run: |
$items = Get-ChildItem -Path "./source/*.nupkg" -Recurse
Foreach ($item in $items)
{
Write-Host "Pushing $item"
dotnet nuget push "$item" -k "$env:NUGET_KEY" -s "https://api.nuget.org/v3/index.json" --skip-duplicate
}