-
Notifications
You must be signed in to change notification settings - Fork 74
358 lines (297 loc) · 12.3 KB
/
build-daily.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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: Build (Daily)
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
current_info:
runs-on: ubuntu-latest
name: Current Information
outputs:
version: ${{ steps.release_info.outputs.version }}
date: ${{ steps.commit_date_iso8601.outputs.date }}
sha: ${{ github.sha }}
sha_short: ${{ steps.commit_info.outputs.sha }}
steps:
- name: Checkout master
uses: actions/checkout@master
with:
ref: "${{ github.sha }}"
submodules: recursive
fetch-depth: 0 # This is set to download the full git history for the repo
- name: Get Commit Date (as ISO8601)
id: commit_date_iso8601
shell: bash
env:
TZ: UTC0
run: |
echo "date=$(git --no-pager show -s --date='format-local:%Y-%m-%dT%H:%M:%SZ' --format=%cd ${{ github.sha }})" >> "$GITHUB_OUTPUT"
- name: Increment build number from last sentry release before "${{ steps.commit_date_iso8601.outputs.date }}"
id: incremental_build
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
run: |
echo -n "BUILD_NUMBER=" >> "$GITHUB_OUTPUT"
curl -s "https://sentry.io/api/0/projects/$SENTRY_ORG/$SENTRY_PROJECT/releases/" \
-H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \
-H "Content-Type: application/json" \
| jq -r '. | map(select((.dateCreated | .[0:-8] + "Z" | fromdateiso8601) < ("${{ steps.commit_date_iso8601.outputs.date }}" | fromdateiso8601))) | first | .version | split("-") | first | split(".") | last | tonumber | . + 1' >> "$GITHUB_OUTPUT"
- name: Get Current Version
id: release_info
uses: revam/gh-action-get-tag-and-version@v1
with:
branch: true
buildNumber: ${{ steps.incremental_build.outputs.BUILD_NUMBER }}
increment: "build"
prefix: v
prefixRegex: "[vV]?"
- id: commit_info
name: Shorten Commit Hash
uses: actions/github-script@v6
with:
script: |
const sha = context.sha.substring(0, 7);
core.setOutput("sha", sha);
cli-daily:
runs-on: ubuntu-latest
needs:
- current_info
strategy:
matrix:
rid: ['linux-x64', 'linux-arm64']
dotnet: [ '8.x' ]
build_type: ['Standalone']
include:
- build_props: ''
build_type: 'Standalone'
- build_type: 'Framework'
build_props: '--no-self-contained'
rid: 'linux-x64'
name: Build CLI — ${{ matrix.build_type }} ${{ matrix.rid }} (Daily)
steps:
- name: Checkout master
uses: actions/checkout@master
with:
ref: "${{ github.sha }}"
submodules: recursive
- name: Replace Sentry DSN and other keys
shell: pwsh
run: |
./.github/workflows/ReplaceSentryDSN.ps1 -dsn ${{ secrets.SENTRY_DSN }}
./.github/workflows/ReplaceTmdbApiKey.ps1 -apiKey ${{ secrets.TMDB_API }}
./.github/workflows/ReplaceAVD3URL.ps1 -url ${{ secrets.AVD3_URL }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
if: ${{ matrix.rid == 'linux-arm64' }}
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}
- run: dotnet publish -c Release -r ${{ matrix.rid }} -f net8.0 ${{ matrix.build_props }} Shoko.CLI /p:Version="${{ needs.current_info.outputs.version }}" /p:InformationalVersion="\"channel=dev,commit=${{ needs.current_info.outputs.sha }},date=${{ needs.current_info.outputs.date }},\""
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Shoko.CLI_${{ matrix.build_type }}_${{ matrix.rid }}.zip
path: Shoko.Server/bin/Release/net8.0/${{matrix.rid}}/publish/
tray-service-daily:
runs-on: windows-latest
needs:
- current_info
strategy:
matrix:
dotnet: [ '8.x' ]
build_type: ['Standalone', 'Framework']
include:
- build_props: '-r win-x64 --self-contained true'
build_type: 'Standalone'
- build_dir: '/net8.0-windows/win-x64'
build_type: 'Standalone'
- build_props: ''
build_type: 'Framework'
- build_dir: '/net8.0-windows'
build_type: 'Framework'
name: Build Tray Service ${{ matrix.build_type }} (Daily)
steps:
- name: Checkout master
uses: actions/checkout@master
with:
ref: "${{ github.sha }}"
submodules: recursive
- name: Replace Sentry DSN and other keys
shell: pwsh
run: |
.\\.github\\workflows\\ReplaceSentryDSN.ps1 -dsn ${{ secrets.SENTRY_DSN }}
.\\.github\\workflows\\ReplaceTmdbApiKey.ps1 -apiKey ${{ secrets.TMDB_API }}
.\\.github\\workflows\\ReplaceAVD3URL.ps1 -url ${{ secrets.AVD3_URL }}
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}
- run: dotnet publish -c Release ${{ matrix.build_props }} Shoko.TrayService /p:Version="${{ needs.current_info.outputs.version }}" /p:InformationalVersion="channel=dev%2ccommit=${{ needs.current_info.outputs.sha }}%2cdate=${{ needs.current_info.outputs.date }}%2c" # %2c is comma, blame windows/pwsh
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: Shoko.TrayService_${{ matrix.build_type }}_win-x64.zip
path: Shoko.Server/bin/Release${{ matrix.build_dir }}/publish/
- name: Upload to shokoanime.com
if: ${{ matrix.build_type == 'Standalone' }}
shell: pwsh
env:
FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
FTP_SERVER: ${{ secrets.FTP_SERVER }}
run : Compress-Archive .\\Shoko.Server\\bin\\Release\\net8.0-windows\\win-x64\\publish .\\ShokoServer.zip && .\\.github\\workflows\\UploadArchive.ps1
docker-daily-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: 'amd64'
dockerfile: 'Dockerfile'
- arch: 'arm64'
dockerfile: 'Dockerfile.aarch64'
name: Build Docker Image - ${{ matrix.arch }} (Daily)
needs:
- current_info
steps:
- name: Checkout master
uses: actions/checkout@master
with:
ref: "${{ github.sha }}"
submodules: recursive
- name: Replace Sentry DSN and other keys
shell: pwsh
run: |
./.github/workflows/ReplaceSentryDSN.ps1 -dsn ${{ secrets.SENTRY_DSN }}
./.github/workflows/ReplaceTmdbApiKey.ps1 -apiKey ${{ secrets.TMDB_API }}
./.github/workflows/ReplaceAVD3URL.ps1 -url ${{ secrets.AVD3_URL }}
- uses: docker/setup-qemu-action@v2
name: Set up QEMU
with:
platforms: arm64
if: ${{ matrix.arch == 'arm64' }}
- uses: docker/setup-buildx-action@v2
name: Set up Docker Buildx
- uses: docker/login-action@v2
name: Log into GitHub Container Registry
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v2
name: Log into Docker Hub
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Disabled provenance for now, until it works with docker manifest create.
# The manifest list produced by the new feature is incompatible with the
# expected format used in the docker manifest create command.
- uses: docker/build-push-action@v4
name: Build and Push the Docker image
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: |
ghcr.io/${{ secrets.DOCKER_REPO }}:daily-${{ matrix.arch }}
${{ secrets.DOCKER_REPO }}:daily-${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}
build-args: |
version=${{ needs.current_info.outputs.version }}
channel=dev
commit=${{ needs.current_info.outputs.sha }}
date=${{ needs.current_info.outputs.date }}
provenance: false
docker-daily-push_manifest:
runs-on: ubuntu-latest
name: Push combined tag for both docker images
needs:
- docker-daily-build
steps:
- uses: docker/login-action@v2
name: Log into GitHub Container Registry
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v2
name: Log into Docker Hub
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Create manifest
run: |
docker manifest create ghcr.io/${{ secrets.DOCKER_REPO }}:daily --amend ghcr.io/${{ secrets.DOCKER_REPO }}:daily-amd64 --amend ghcr.io/${{ secrets.DOCKER_REPO }}:daily-arm64
docker manifest create ${{ secrets.DOCKER_REPO }}:daily --amend ${{ secrets.DOCKER_REPO }}:daily-amd64 --amend ${{ secrets.DOCKER_REPO }}:daily-arm64
- name: Push manifest
run: |
docker manifest push ghcr.io/${{ secrets.DOCKER_REPO }}:daily
docker manifest push ${{ secrets.DOCKER_REPO }}:daily
sentry-upload:
runs-on: ubuntu-latest
needs:
- current_info
- cli-daily
- tray-service-daily
- docker-daily-push_manifest
name: Upload version info to Sentry.io
steps:
- name: Checkout master
uses: actions/checkout@master
with:
ref: "${{ github.sha }}"
submodules: recursive
# Only add the release to sentry if the build is successful.
- name: Push Sentry Release "${{ needs.current_info.outputs.version }}"
uses: getsentry/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
# SENTRY_URL: https://sentry.io/
with:
environment: 'dev'
version: ${{ needs.current_info.outputs.version }}
discord-notify:
runs-on: ubuntu-latest
name: Send notifications about the new daily build
needs:
- current_info
- sentry-upload
steps:
- name: Generate Changelog from Sentry Release
id: generate_changelog
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
RELEASE_VERSION: ${{ needs.current_info.outputs.version }}
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "CHANGELOG<<$EOF" >> "$GITHUB_OUTPUT"
curl -s "https://sentry.io/api/0/projects/$SENTRY_ORG/$SENTRY_PROJECT/releases/$RELEASE_VERSION/commits/" \
-H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \
-H "Content-Type: application/json" \
| jq -r '.[].message + "\n"' >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Notify Discord Users
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
embed-color: 5809492
embed-timestamp: ${{ needs.current_info.outputs.date }}
embed-author-name: Shoko Server | New Daily Build
embed-author-icon-url: https://raw.githubusercontent.com/${{ github.repository }}/master/.github/images/Shoko.png
embed-author-url: https://github.com/${{ github.repository }}
embed-description: |
**Version**: `${{ needs.current_info.outputs.version }}` (`${{ needs.current_info.outputs.sha_short }}`)
Update by grabbing the latest daily from [our site](https://shokoanime.com/downloads/shoko-server) or through Docker using the `shokoanime/server:daily` tag!
**Changes since last build**:
${{ steps.generate_changelog.outputs.CHANGELOG }}