generated from Stravaig-Projects/stravaig-template
-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (153 loc) · 6.33 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Stravaig Bogus Extensions
on:
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'Example/**'
- '.vscode/**'
- '.gitignore'
- 'contributors.md'
- 'release-notes/**'
- '.github/PULL_REQUEST_TEMPLATE/**'
- 'src/.idea/**'
pull_request:
types: [assigned, opened, synchronize, reopened]
paths-ignore:
- 'README.md'
- 'Example/**'
- '.vscode/**'
- '.gitignore'
workflow_dispatch:
inputs:
isPublic:
description: 'Is Public Release'
required: false
default: "false"
isPreview:
description: 'Is Preview Release'
required: false
default: "true"
jobs:
build:
name: Build, Test, and Release
runs-on: ubuntu-latest
env:
STRAVAIG_SOLUTION: src/Stravaig.Bogus.Extensions.sln
STRAVAIG_TESTS: Stravaig.Bogus.Extensions.Tests
STRAVAIG_PROJECT: Stravaig.Bogus.Extensions
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set version number
shell: pwsh
run: ./Set-Version.ps1 -IsPublic "${{ github.event.inputs.isPublic }}" -IsPreview "${{ github.event.inputs.isPreview }}"
- name: Display workflow state
run: |
echo "GITHUB_SHA: $GITHUB_SHA"
echo "Solution: $STRAVAIG_SOLUTION"
echo "Project: $STRAVAIG_PROJECT"
echo "Tests: $STRAVAIG_TESTS"
echo "Package version: $STRAVAIG_PACKAGE_VERSION"
echo "Version Suffix: $STRAVAIG_PACKAGE_VERSION_SUFFIX"
echo "Full Version: $STRAVAIG_PACKAGE_FULL_VERSION"
echo "Publish To NuGet: $STRAVAIG_PUBLISH_TO_NUGET"
echo "Is Preview: $STRAVAIG_IS_PREVIEW"
echo "Is Stable: $STRAVAIG_IS_STABLE"
- uses: actions/setup-dotnet@v3
name: Setup .NET 6.0 and 7.0
with:
dotnet-version: |
6.0.x
7.0.x
- name: .NET State
run: dotnet --info
- name: Build Solution
run: dotnet build $STRAVAIG_SOLUTION --configuration Release
- name: Run Tests
run: dotnet test src/$STRAVAIG_TESTS/$STRAVAIG_TESTS.csproj --configuration Release
- name: Package Preview Release
if: ${{ env.STRAVAIG_IS_PREVIEW == 'true' }}
run: dotnet pack ./src/$STRAVAIG_PROJECT/$STRAVAIG_PROJECT.csproj --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" --version-suffix "$STRAVAIG_PACKAGE_VERSION_SUFFIX" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
- name: Package Stable Release
if: ${{ env.STRAVAIG_IS_STABLE == 'true' }}
run: dotnet pack ./src/$STRAVAIG_PROJECT/$STRAVAIG_PROJECT.csproj --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
- name: Push package to NuGet
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }}
shell: pwsh
run: |
Get-ChildItem ./out/*.nupkg | ForEach-Object {
$name = $_.FullName;
Write-Output "Pushing $name";
dotnet nuget push "$name" --api-key ${{ secrets.STRAVAIG_NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
}
- name: List Contributors
shell: pwsh
run: ./list-contributors.ps1 -HideSummaryAwards
- name: Build Release Notes
shell: pwsh
run: ./build-release-notes.ps1
- name: Archive Simulated Release Information
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'false' }}
uses: actions/upload-artifact@v3
with:
name: simulated-release-information
path: |
contributors.md
release-notes/full-release-notes.md
release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md
out/**
retention-days: 7
- name: Archive Release Notes
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }}
uses: actions/upload-artifact@v3
with:
name: release-information
path: |
contributors.md
release-notes/full-release-notes.md
release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md
out/**
- name: Create Release
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$assets = @();
$assets += "./out/*.nupkg"
$assets += "./out/*.snupkg"
$assets += "LICENSE"
$assets += "contributors.md"
$assets += "README.md"
$assets += "./release-notes/release-notes-${{ env.STRAVAIG_PACKAGE_FULL_VERSION }}.md"
./Create-Release.ps1 -NotesFile "./release-body.md" -Assets $assets
- name: Bump version
#IF Publishing & Stable release
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }}
shell: pwsh
run: ./Bump-Version.ps1 -BumpPatch
- name: Reset WIP release notes
#IF Publishing & Stable release
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }}
shell: pwsh
run: ./Reset-WipReleaseNotes.ps1
- name: Update Docs
#IF Publishing & Stable release
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }}
shell: pwsh
run: ./Update-Docs.ps1
- name: Commit post release updates
#IF Publishing & Stable release
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' && env.STRAVAIG_IS_STABLE == 'true' }}
uses: EndBug/add-and-commit@v5
with:
add: ./contributors.md ./release-notes/** ./version.txt docs/**
author_name: StravaigBot
author_email: github-bot@stravaig.scot
message: "[bot] Post v${{ env.STRAVAIG_PACKAGE_FULL_VERSION }} Release & Bump Version updates."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}