-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (121 loc) · 4.13 KB
/
ci.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
name: Moq.ILogger CI
on:
pull_request:
branches: [ "main" ]
paths:
- 'tests/**'
- 'src/**'
push:
branches: [ "main", "actions" ]
paths:
- 'src/**'
- 'version.json'
jobs:
test:
runs-on: windows-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage"
- name: Publish Code Coverage To PR
uses: 5monkeys/cobertura-action@v13
with:
path: tests/Moq.INavigationService.Tests/TestResults/*/coverage.cobertura.xml
minimum_coverage: 5
show_line: true
show_branch: true
show_missing: true
build:
runs-on: windows-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: drop
path: src/**/*.nupkg
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
env:
IS_PRERELEASE: true
RELEASE_TITLE: v0.0.1
VERSION_NAME: 0.0.1
steps:
- uses: actions/checkout@v3
- name: Download artifacts
id: download-artifact
uses: actions/download-artifact@v2.1.1
with:
name: drop
path: Artifacts/
- name: Process NuGet Version
shell: pwsh
working-directory: Artifacts/
id: process-version
run: |
$Artifact = Get-ChildItem -Recurse | Where-Object { $_.Name.EndsWith('.nupkg') -and $_.Name.StartsWith('Axemasta.Moq.INavigationService.') } | Select-Object -First 1
$ArtifactName = $Artifact.Name
$Pattern = '\b\d+\.\d+\.\d+(-\w+)?\b'
$Match = [regex]::Match($ArtifactName, $Pattern)
if (!$Match.Success) {
Write-Host "Unable to parse version number for artifact: $($ArtifactName)"
exit
}
$ArtifactName = $Match.Value
$IsPreRelease = $false
if ($ArtifactName.EndsWith("-pre")) {
$IsPreRelease = $true
}
if ($IsPreRelease) {
echo "IS_PRERELEASE=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "IS_PRERELEASE=false" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
echo "action_state=$ArtifactName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "VERSION_NAME=$ArtifactName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "RELEASE_TITLE=v$ArtifactName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "ArtifactName = $ArtifactName"
Write-Host "Is PreRelease = $IsPreRelease"
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
custom_tag: ${{ env.VERSION_NAME }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: ncipollo/release-action@main
name: Create Release
with:
artifacts: Artifacts/**/*.nupkg
artifactErrorsFailBuild: true
draft: true
generateReleaseNotes: true
name: ${{ env.RELEASE_TITLE }}
tag: ${{ env.VERSION_NAME }}
prerelease: ${{ env.IS_PRERELEASE }}
body: "TODO"
- name: Publish NuGet
run: nuget push Artifacts/**/*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{ secrets.NUGET_API_KEY }} -SkipDuplicate