-
-
Notifications
You must be signed in to change notification settings - Fork 178
219 lines (212 loc) · 8.14 KB
/
dotnet.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: .NET
on:
push:
branches: [ dev, master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ dev, master ]
env:
# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
# DOTNET_CLI_TELEMETRY_OPTOUT: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECT_NAME: "SoundSwitch"
ARCH: "win-x64"
FRAMEWORK: "net8.0-windows"
NODEJS: "lts/*"
DOTNET: "8.0.x"
DOTNET_PRERELEASE: true
CONFIGURATION: "Nightly"
SENTRY_NAME: "soundswitch"
jobs:
build:
if: github.ref != 'refs/heads/dev'
runs-on: windows-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-build
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
ci:
- '.github/**/*.yml'
- 'devRelease.js'
SoundSwitch:
- 'SoundSwitch*/**'
node:
- 'package.json'
- name: Setup .NET
uses: actions/[email protected]
if: steps.filter.outputs.SoundSwitch == 'true' || steps.filter.outputs.ci == 'true' || github.ref == 'refs/heads/master'
with:
dotnet-version: ${{ env.DOTNET }}
include-prerelease: ${{ env.DOTNET_PRERELEASE }}
- name: Restore
if: steps.filter.outputs.SoundSwitch == 'true' || steps.filter.outputs.ci == 'true' || github.ref == 'refs/heads/master'
run: dotnet restore
- name: Build
if: steps.filter.outputs.SoundSwitch == 'true' || steps.filter.outputs.ci == 'true' || github.ref == 'refs/heads/master'
run: dotnet build -c Release --no-restore ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj
- name: Test
if: steps.filter.outputs.SoundSwitch == 'true' || steps.filter.outputs.ci == 'true' || github.ref == 'refs/heads/master'
run: dotnet test -c Release --no-restore --logger trx --results-directory "TestResults-${{ matrix.dotnet-version }}"
- name: Upload test results
if: steps.filter.outputs.SoundSwitch == 'true' || steps.filter.outputs.ci == 'true' || github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v4
with:
name: dotnet-results-${{ matrix.dotnet-version }}
path: TestResults-${{ matrix.dotnet-version }}
# Use always() to always run this step to publish test results when there are test failures
- name: Setup Node.js
if: steps.filter.outputs.node == 'true'
uses: actions/[email protected]
with:
node-version: ${{env.NODEJS}}
- name: Cache node modules
if: steps.filter.outputs.node == 'true'
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: npm-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install semantic-release dependencies
if: steps.filter.outputs.node == 'true'
run: npm ci --prefer-offline --silent --cache npm-cache
- name: Release dry run
if: steps.filter.outputs.node == 'true'
run: npx semantic-release -d
changes:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-changes
cancel-in-progress: true
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
ci: ${{ steps.filter.outputs.ci }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
ci:
- '.github/**/*.yml'
- 'SoundSwitch*/**'
- 'devRelease.js'
nightly-release:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-nightly
cancel-in-progress: true
needs: [ changes ]
if: github.ref == 'refs/heads/dev' && needs.changes.outputs.ci == 'true'
outputs:
devVersion: ${{ steps.devVersion.outputs.version }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: ${{ env.DOTNET }}
include-prerelease: ${{ env.DOTNET_PRERELEASE }}
- name: Restore
run: dotnet restore -r ${{ env.ARCH }}
- name: Tests
run: dotnet test -c ${{env.CONFIGURATION}} --no-restore --logger trx --results-directory "TestResults-${{ matrix.dotnet-version }}"
- name: Fetch tags
run: git fetch --tags --force
- name: Calculate version
id: devVersion
run: .\devVersion.ps1
- name: Build pre-release
run: dotnet publish -c ${{env.CONFIGURATION}} --no-restore -r ${{ env.ARCH }} ${{ env.PROJECT_NAME }}\${{ env.PROJECT_NAME }}.csproj
- name: Set Env var from GitHub
uses: rlespinasse/[email protected]
- name: Zip Build ${{env.PROJECT_NAME}}-${{ steps.devVersion.outputs.version }}
run: tar caf ${{env.PROJECT_NAME}}-${{ steps.devVersion.outputs.version }}.zip -C ${{ env.PROJECT_NAME }}\bin\${{env.CONFIGURATION}}\${{ env.FRAMEWORK }}\${{ env.ARCH }}\publish\ *
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: ${{env.NODEJS}}
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: npm-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci --prefer-offline --silent --cache npm-cache
- name: Upload prerelease & Notify
env:
UPLOAD_SECRET: ${{secrets.UPLOAD_SECRET}}
UPLOAD_PUBLIC: ${{secrets.UPLOAD_PUBLIC}}
UPLOAD_BUCKET: ${{env.PROJECT_NAME}}
run: node devRelease.js "${{ secrets.DISCORD_WEBHOOK }}" "${{ steps.devVersion.outputs.version }}" "${{env.GITHUB_REPOSITORY_OWNER_PART}}/${{env.GITHUB_REPOSITORY_NAME_PART}}" "${{env.PROJECT_NAME}}-${{ steps.devVersion.outputs.version }}.zip"
nightly-sentry:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-sentry
cancel-in-progress: true
needs: nightly-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Sentry Release
uses: getsentry/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{env.SENTRY_NAME}}
SENTRY_PROJECT: ${{env.SENTRY_NAME}}
with:
environment: Nightly
version: "${{env.PROJECT_NAME}}@${{ needs.nightly-release.outputs.devVersion }}"
master-release:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-release
cancel-in-progress: true
needs: [ build, changes ]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: ${{env.NODEJS}}
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: npm-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install semantic-release dependencies
run: npm ci --prefer-offline --silent --cache npm-cache
- name: Release
run: npx semantic-release
- name: Latest Version
run: |
version=$(git describe --tags --abbrev=0 | cut -c 2-)
echo "version=$version.0" >> $GITHUB_OUTPUT
id: version
- name: Sentry Release
uses: getsentry/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{env.SENTRY_NAME}}
SENTRY_PROJECT: ${{env.SENTRY_NAME}}
with:
environment: Stable
version: "${{env.PROJECT_NAME}}@${{ steps.version.outputs.version }}"