-
Notifications
You must be signed in to change notification settings - Fork 0
330 lines (291 loc) · 9.9 KB
/
release.yml
File metadata and controls
330 lines (291 loc) · 9.9 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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
name: Release
on:
# Nightly builds after CI passes on main
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main
- develop
# Stable releases on version tags
push:
tags:
- 'v*'
# Manual trigger
workflow_dispatch:
permissions:
contents: read
env:
DOTNET_VERSION: '10.0.x'
NODE_VERSION: '22.x'
MAJOR_VERSION: '0.0.1'
NUGET_CERT_REVOCATION_MODE: offline
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
DOTNET_MULTILEVEL_LOOKUP: 0
jobs:
frontend:
name: Build Frontend
# Only run if CI passed (workflow_run), or if triggered by tag/manual
if: >
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
- name: Install frontend dependencies
run: yarn install --frozen-lockfile
- name: Build frontend
run: yarn build --env production
- name: Upload frontend build
uses: actions/upload-artifact@v7
with:
name: release-frontend
path: _output/UI
retention-days: 1
build:
name: Build (${{ matrix.runtime }})
needs: frontend
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- runtime: win-x64
os: windows-latest
- runtime: win-x86
os: windows-latest
- runtime: linux-x64
os: ubuntu-latest
- runtime: linux-arm64
os: ubuntu-latest
- runtime: linux-arm
os: ubuntu-latest
- runtime: linux-musl-x64
os: ubuntu-latest
- runtime: linux-musl-arm64
os: ubuntu-latest
- runtime: osx-x64
os: macos-latest
- runtime: osx-arm64
os: macos-latest
# freebsd-x64 disabled: .NET 8.0.25 runtime not yet available in dotnet-bsd-crossbuild feed (latest: 8.0.12)
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Compute NuGet cache key
id: nuget-key
shell: bash
run: echo "hash=$(find src -name '*.csproj' | sort | xargs cat | tr -d '\r' | shasum -a 256 | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- name: NuGet cache
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: nuget-${{ steps.nuget-key.outputs.hash }}
restore-keys: nuget-
enableCrossOsArchive: true
- name: Calculate version
id: version
shell: bash
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
else
VERSION="${{ env.MAJOR_VERSION }}.${{ github.run_number }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Update version in project
shell: bash
run: |
sed -i.bak "s/<AssemblyVersion>[0-9.*]\+<\/AssemblyVersion>/<AssemblyVersion>${{ steps.version.outputs.version }}<\/AssemblyVersion>/g" src/Directory.Build.props
- name: Build backend
shell: bash
run: |
dotnet msbuild -restore src/Gamarr.sln \
-p:Configuration=Release \
-p:Platform=Posix \
-p:RuntimeIdentifiers=${{ matrix.runtime }} \
-t:PublishAllRids
- name: Download frontend build
uses: actions/download-artifact@v8
with:
name: release-frontend
path: _output/UI
- name: Package
shell: bash
run: |
runtime="${{ matrix.runtime }}"
version="${{ steps.version.outputs.version }}"
mkdir -p _artifacts/$runtime
cp -r _output/net8.0/$runtime/publish/* _artifacts/$runtime/
cp -r _output/UI _artifacts/$runtime/
cp LICENSE _artifacts/$runtime/
# Remove platform-specific files
if [[ "$runtime" == win-* ]]; then
rm -f _artifacts/$runtime/Gamarr.Mono.* 2>/dev/null || true
else
rm -f _artifacts/$runtime/Gamarr.Windows.* 2>/dev/null || true
fi
- name: Create archive (Unix)
if: ${{ !startsWith(matrix.runtime, 'win-') }}
shell: bash
run: |
cd _artifacts
tar -czvf Gamarr.${{ steps.version.outputs.version }}.${{ matrix.runtime }}.tar.gz ${{ matrix.runtime }}
- name: Create archive (Windows)
if: ${{ startsWith(matrix.runtime, 'win-') }}
shell: bash
run: |
cd _artifacts
7z a -tzip Gamarr.${{ steps.version.outputs.version }}.${{ matrix.runtime }}.zip ${{ matrix.runtime }}
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: Gamarr-${{ matrix.runtime }}
path: _artifacts/Gamarr.${{ steps.version.outputs.version }}.${{ matrix.runtime }}.*
retention-days: 30
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Calculate version
id: version
run: |
# Handle both direct push and workflow_run triggers
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
BRANCH="${{ github.event.workflow_run.head_branch }}"
else
BRANCH="${{ github.ref }}"
fi
if [[ "$BRANCH" == refs/tags/v* || "$BRANCH" == v* ]]; then
VERSION="${BRANCH#refs/tags/}"
VERSION="${VERSION#v}"
PRERELEASE="false"
CHANNEL="stable"
elif [[ "$BRANCH" == *"develop"* ]]; then
VERSION="${{ env.MAJOR_VERSION }}.${{ github.run_number }}"
PRERELEASE="true"
CHANNEL="develop"
else
VERSION="${{ env.MAJOR_VERSION }}.${{ github.run_number }}"
PRERELEASE="true"
CHANNEL="nightly"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
echo "Version: $VERSION, Prerelease: $PRERELEASE, Channel: $CHANNEL"
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
pattern: Gamarr-*
merge-multiple: true
- name: List artifacts
run: find artifacts -type f
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
generate_release_notes: true
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
name: Build Docker Images
runs-on: ubuntu-latest
needs: release
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Calculate version
id: version
run: |
# Handle both direct push and workflow_run triggers
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
BRANCH="${{ github.event.workflow_run.head_branch }}"
else
BRANCH="${{ github.ref }}"
fi
if [[ "$BRANCH" == refs/tags/v* || "$BRANCH" == v* ]]; then
VERSION="${BRANCH#refs/tags/}"
VERSION="${VERSION#v}"
CHANNEL="stable"
elif [[ "$BRANCH" == *"develop"* ]]; then
VERSION="${{ env.MAJOR_VERSION }}.${{ github.run_number }}"
CHANNEL="develop"
else
VERSION="${{ env.MAJOR_VERSION }}.${{ github.run_number }}"
CHANNEL="nightly"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ steps.version.outputs.version }}
type=raw,value=latest,enable=${{ steps.version.outputs.channel == 'stable' }}
type=raw,value=develop,enable=${{ steps.version.outputs.channel == 'develop' }}
type=raw,value=nightly,enable=${{ steps.version.outputs.channel == 'nightly' }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATE=${{ github.event.repository.updated_at }}
VERSION=${{ steps.version.outputs.version }}
GAMARR_RELEASE=${{ steps.version.outputs.version }}