-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (129 loc) · 4.88 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
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Continuous Integration
on:
push:
branches:
- "master"
pull_request:
types: [opened, synchronize]
schedule:
- cron: "0 0 * * *"
env:
DOTNET_NOLOGO: "true"
CONFIGURATION: Release
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
GITHUB_PACKAGES_FEED_URL: https://nuget.pkg.github.com/cythral/index.json
jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Get Commit Message
shell: bash
run: | # Account for pull request merge commits
sha=${{ github.sha }}
after=$(git rev-list origin/master..HEAD --max-parents=1 --max-count=1)
[ ! `git rev-list --no-walk --count --merges "$sha"` ] || sha=$after
echo "COMMIT_MESSAGE=$(git log --format=%B -n 1 $sha | tr '\n' ' ')" >> $GITHUB_ENV
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
- name: Display .NET Info
run: dotnet --info
- name: Restore
run: dotnet restore
- name: Build
shell: bash
id: build
run: dotnet build --no-restore -m -bl:obj/logs/build-${{ matrix.os }}.binlog
- name: Test
run: dotnet test --no-build
- name: Upload Coverage
uses: codecov/codecov-action@v4
if: matrix.os == 'ubuntu-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./obj/Tests/Results/coverage.cobertura.xml
fail_ci_if_error: true
- name: Upload Nugets
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: nugets
path: bin/Packages/${{ env.CONFIGURATION }}
- name: Upload Logs
uses: actions/upload-artifact@v3
with:
name: logs-${{ matrix.os }}
path: obj/logs/
- name: Deploy to Github Packages
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push'
run: dotnet nuget push "bin/Packages/${CONFIGURATION}/*.nupkg" -k ${FEED_TOKEN} -s ${FEED_URL} --skip-duplicate --no-symbols
env:
FEED_TOKEN: ${{ secrets.GH_TOKEN }}
FEED_URL: ${{ env.GITHUB_PACKAGES_FEED_URL }}
- name: Discord Failure Notification
uses: Ilshidur/action-discord@master
if: failure() && (github.event_name == 'push' || github.event_name == 'schedule')
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "[${{ github.repository }}] Build Failed",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"description": "An error occurred while building ${{ github.repository }} ${{ steps.build.outputs.version }} on ${{ matrix.os }}",
"color": 12720135
}
]
release:
needs: build
runs-on: ubuntu-latest
environment:
name: Production
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Download NuGets
uses: actions/download-artifact@v3
id: download-nugets
with:
name: nugets
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
- name: Display .NET Info
run: dotnet --info
- name: Deploy to NuGet
run: dotnet nuget push '${{ steps.download-nugets.outputs.download-path }}/*.nupkg' -k ${FEED_TOKEN} -s ${FEED_URL} --skip-duplicate
env:
FEED_TOKEN: ${{ secrets.NUGET_TOKEN }}
FEED_URL: ${{ env.NUGET_FEED_URL }}
- uses: ncipollo/release-action@v1
with:
artifacts: "${{ steps.download-nugets.outputs.download-path }}/*.nupkg,${{ steps.download-nugets.outputs.download-path }}/*.snupkg"
commit: ${{ github.sha }}
token: ${{ secrets.GH_TOKEN }}
tag: v${{ needs.build.outputs.version }}
prerelease: ${{ contains(needs.build.outputs.version, '-') }}
generateReleaseNotes: true
- name: Discord Failure Notification
uses: Ilshidur/action-discord@master
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "[${{ github.repository }}] Release Failed",
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"description": "An error occurred while releasing ${{ github.repository }} ${{ needs.build.outputs.version }}",
"color": 12720135
}
]