-
-
Notifications
You must be signed in to change notification settings - Fork 55
141 lines (117 loc) · 4.47 KB
/
Copy pathdotnetcore.yml
File metadata and controls
141 lines (117 loc) · 4.47 KB
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
name: Continuous
on:
# PRs will be built, and a package posted to GH Packages
pull_request:
workflow_dispatch:
push:
paths-ignore:
- 'README.md'
- 'docs/**'
# We'll build, pack, and push a pre-release to NuGet on master
branches: [ master ]
# Tagging with v* will build that version number and push a release to Nuget
# e.g. v1.2, v3.4.5, etc.
tags:
- 'v*'
defaults:
run:
shell: pwsh
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
- name: NuGet restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
# Package Release
- name: Pack
run: |
<# If we're a tag, force VersionPrefix to the tag value #>
if ('${{ github.ref }}' -match '^refs/tags/v') {
$match = [regex]::Match('${{ github.ref }}', '^refs/tags/v([0-9]+(\.[0-9]+){1,2})')
if ($match.Success) {
$env:VersionPrefix = $match.Groups[1].Value
} else {
throw 'Invalid tag version: ${{ github.ref }}'
}
}
else {
<# All other pushes get a CI suffix #>
$env:VersionSuffix = 'ci{0:0000}' -f ${{ github.run_number }}
}
dotnet pack /p:ContinuousIntegrationBuild=true --configuration Release --verbosity normal --output .
- name: Upload NuGet
uses: actions/upload-artifact@v7
with:
name: NuGet
if-no-files-found: error
path: |
**/*.nupkg
**/*.snupkg
# Test that MSBuild properties to disable generators work correctly
- name: Test Generator Disable Properties
run: |
<# Create a local NuGet source directory with the packed packages #>
New-Item -ItemType Directory -Force -Path ./nupkgs
Copy-Item -Path *.nupkg -Destination ./nupkgs/
<# Build and run the disable tests using the local NuGet package #>
<# The test project's NuGet.config points to ../../nupkgs relative to the project #>
dotnet test --project ./GeneratorTests/Moq.AutoMock.Generator.DisableTests/Moq.AutoMock.Generator.DisableTests.csproj `
--configuration Release `
--verbosity normal `
/p:LocalNuGetSource=true
# Move analyzer rules to shipped docs for tag releases
- name: Promote Analyzer Release Docs
if: startsWith(github.ref, 'refs/tags/v')
run: |
$packageVersion = '${{ github.ref_name }}'.Substring(1)
.\.github\scripts\Promote-AnalyzerReleaseDocs.ps1 -PackageVersion $packageVersion
# Update the docs
- name: Update Docs
if: github.event_name == 'push'
run: |
dotnet tool install xmldocmd
dotnet tool run xmldocmd .\Moq.AutoMock\bin\Release\net461\Moq.AutoMock.dll .\docs
$modified = $(git status -u --porcelain)
if ($modified.Where({$_.Contains(" docs/")}, 'First').Count -lt 1) {
return 0
}
# Create docs pull request
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
if: github.event_name == 'push'
with:
commit-message: |
[Generated updates detected by GitHub Action].
Auto generated pull request.
branch: docs/automated-update
delete-branch: true
base: master
title: Update generated docs [GitHub Action]
body: |
[Generated updates detected by GitHub Action].
Auto generated pull request.
# Publish to NuGet and GitHub Packages
- name: Publish
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate
dotnet nuget push *.nupkg `
--source 'https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json' `
--api-key '${{ github.token }}' `
--skip-duplicate
automerge:
if: github.event_name == 'pull_request'
needs: build
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: fastify/github-action-merge-dependabot@v3.15.0