forked from Jackett/Jackett
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
644 lines (592 loc) · 26.2 KB
/
azure-pipelines.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
---
name: $(majorVersion).$(minorVersion).$(patchVersion)
variables:
majorVersion: 0
minorVersion: 22
patchVersion: $[counter(variables['minorVersion'], 1)] # this will reset when we bump minor
jackettVersion: $(majorVersion).$(minorVersion).$(patchVersion)
buildConfiguration: Release
netCoreFramework: net8.0
netCoreSdkVersion: 8.0.x
# system.debug: true
trigger:
batch: true
branches:
include:
- master
- test/**
paths:
exclude:
- .github
- README.md
- CONTRIBUTING.md
pr:
branches:
include:
- master
- test/**
paths:
exclude:
- .github
- README.md
- CONTRIBUTING.md
stages:
- stage: BuildJackett
displayName: Create Binaries
jobs:
- job: Build
workspace:
clean: all
strategy:
matrix:
Windows:
buildDescription: Windows
imageName: windows-2022
framework: $(netCoreFramework)
runtime: win-x86
archiveType: zip
artifactName: Jackett.Binaries.Windows.zip
macOS:
buildDescription: macOS
imageName: macOS-13
framework: $(netCoreFramework)
runtime: osx-x64
archiveType: tar
artifactName: Jackett.Binaries.macOS.tar.gz
macOSARM64:
buildDescription: macOS ARM64
imageName: macOS-13
framework: $(netCoreFramework)
runtime: osx-arm64
archiveType: tar
artifactName: Jackett.Binaries.macOSARM64.tar.gz
LinuxAMDx64:
buildDescription: Linux AMD x64
imageName: ubuntu-22.04
framework: $(netCoreFramework)
runtime: linux-x64
archiveType: tar
artifactName: Jackett.Binaries.LinuxAMDx64.tar.gz
LinuxARM32:
buildDescription: Linux ARM32
imageName: ubuntu-22.04
framework: $(netCoreFramework)
runtime: linux-arm
archiveType: tar
artifactName: Jackett.Binaries.LinuxARM32.tar.gz
LinuxARM64:
buildDescription: Linux ARM64
imageName: ubuntu-22.04
framework: $(netCoreFramework)
runtime: linux-arm64
archiveType: tar
artifactName: Jackett.Binaries.LinuxARM64.tar.gz
LinuxMuslAMDx64:
buildDescription: Linux musl AMD x64
imageName: ubuntu-22.04
framework: $(netCoreFramework)
runtime: linux-musl-x64
archiveType: tar
artifactName: Jackett.Binaries.LinuxMuslAMDx64.tar.gz
LinuxMuslARM32:
buildDescription: Linux musl ARM32
imageName: ubuntu-22.04
framework: $(netCoreFramework)
runtime: linux-musl-arm
archiveType: tar
artifactName: Jackett.Binaries.LinuxMuslARM32.tar.gz
LinuxMuslARM64:
buildDescription: Linux musl ARM64
imageName: ubuntu-22.04
framework: $(netCoreFramework)
runtime: linux-musl-arm64
archiveType: tar
artifactName: Jackett.Binaries.LinuxMuslARM64.tar.gz
Mono:
buildDescription: Mono
imageName: ubuntu-22.04
framework: net462
runtime: linux-x64
archiveType: tar
artifactName: Jackett.Binaries.Mono.tar.gz
pool:
vmImage: $(imageName)
displayName: ${{ variables.buildDescription }}
steps:
- checkout: self
- task: UseDotNet@2
displayName: Install .NET Core SDK
inputs:
packageType: sdk
version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: Build DateTimeRoutines
# this task is not mandatory since DateTimeRoutines is build in the next task, but the purpose is to fix:
# error MSB4018: System.IO.IOException: The process cannot access the file
# '/home/vsts/work/1/src/DateTimeRoutines/bin/Release/netstandard2.0/DateTimeRoutines.deps.json'
# because it is being used by another process.
inputs:
command: build
projects: 'src/DateTimeRoutines/DateTimeRoutines.csproj'
publishWebProjects: false
zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework netstandard2.0'
- task: DotNetCoreCLI@2
displayName: Build Jackett Server
# the retries are just in case the previous task doesn't fix the error
retryCountOnTaskFailure: 3
inputs:
command: publish
projects: 'src/Jackett.Server/Jackett.Server.csproj'
publishWebProjects: false
zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --self-contained --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: DotNetCoreCLI@2
displayName: Build Jackett Updater
inputs:
command: publish
projects: 'src/Jackett.Updater/Jackett.Updater.csproj'
publishWebProjects: false
zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework) --self-contained --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: DotNetCoreCLI@2
displayName: Build Jackett Tray (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
command: publish
projects: 'src/Jackett.Tray/Jackett.Tray.csproj'
publishWebProjects: false
zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework)-windows --self-contained --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: DotNetCoreCLI@2
displayName: Build Jackett Service (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
command: publish
projects: 'src/Jackett.Service/Jackett.Service.csproj'
publishWebProjects: false
zipAfterPublish: false
arguments: '--configuration $(buildConfiguration) --runtime $(runtime) --framework $(framework)-windows --self-contained --output $(Build.BinariesDirectory) /p:AssemblyVersion=$(jackettVersion) /p:FileVersion=$(jackettVersion) /p:InformationalVersion=$(jackettVersion) /p:Version=$(jackettVersion)'
- task: CopyFiles@2
displayName: Copy Jackett Server
inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Server
contents: '**'
targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2
displayName: Copy Jackett Updater
inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Updater
contents: JackettUpdater*
targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2
displayName: Copy Jackett Tray (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Tray
contents: |
System.Drawing.dll
System.Security.Cryptography.ProtectedData.dll
WindowsBase.dll
targetFolder: $(Build.BinariesDirectory)/Jackett
overWrite: true
- task: CopyFiles@2
displayName: Copy Jackett Tray Part 2 (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Tray
contents: '*'
targetFolder: $(Build.BinariesDirectory)/Jackett
overWrite: false
- task: CopyFiles@2
displayName: Copy Jackett Service (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
SourceFolder: $(Build.BinariesDirectory)/Jackett.Service
contents: JackettService*
targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2
displayName: Copy Windows Specific Scripts (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
SourceFolder: $(Build.SourcesDirectory)
contents: jackett_launcher.bat
targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2
displayName: Copy Mono Specific Scripts
condition: and(succeeded(), startsWith(variables['buildDescription'], 'Mono'))
inputs:
SourceFolder: $(Build.SourcesDirectory)
contents: |
install_service_systemd_mono.sh
Upstart.config
targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2
displayName: Copy macOS Specific Scripts
condition: and(succeeded(), startsWith(variables['buildDescription'], 'macOS'))
inputs:
SourceFolder: $(Build.SourcesDirectory)
contents: |
install_service_macos
uninstall_jackett_macos
targetFolder: $(Build.BinariesDirectory)/Jackett
- task: CopyFiles@2
displayName: Copy Linux Specific Scripts
condition: and(succeeded(), startsWith(variables['buildDescription'], 'Linux'))
inputs:
SourceFolder: $(Build.SourcesDirectory)
contents: |
install_service_systemd.sh
jackett_launcher.sh
targetFolder: $(Build.BinariesDirectory)/Jackett
# There is an issue with Mono 5.8 (fixed in Mono 5.12) where its expecting to use its own patched version of
# System.Net.Http.dll, instead of the version supplied in folder
# https://github.com/dotnet/corefx/issues/19914
# https://bugzilla.xamarin.com/show_bug.cgi?id=60315
# The workaround is to delete System.Net.Http.dll and patch the .exe.config file
# Mono on FreeBSD doesn't like the bundled System.Runtime.InteropServices.RuntimeInformation -> Delete it
# https://github.com/dotnet/corefx/issues/23989
# https://github.com/Jackett/Jackett/issues/3547
- task: PowerShell@2
displayName: Patch Mono Build (Mono only)
condition: and(succeeded(), startsWith(variables['buildDescription'], 'Mono'))
inputs:
workingDirectory: $(Build.BinariesDirectory)/Jackett
targetType: inline
script: |
$file = '$(Build.BinariesDirectory)/Jackett/JackettConsole.exe.config'
$xml = [xml] (Get-Content $file)
$newVersion = $xml.SelectSingleNode("configuration/runtime/*[name()='assemblyBinding']/*[name()='dependentAssembly']/*[name()='assemblyIdentity'][@name='System.Net.Http']/../*[name()='bindingRedirect']/@newVersion")
$newVersion.Value = '4.0.0.0'
$xml.Save($file)
Remove-Item '$(Build.BinariesDirectory)/Jackett/System.Net.Http.dll'
Remove-Item '$(Build.BinariesDirectory)/Jackett/System.Runtime.InteropServices.RuntimeInformation.dll'
- task: Bash@3
displayName: Set Folder and File Permissions (Mono, Linux and macOS)
condition: and(succeeded(), not(startsWith(variables['runtime'], 'win')))
inputs:
workingDirectory: $(Build.BinariesDirectory)/Jackett
targetType: inline
script: |
chmod 755 $(find "$(Build.BinariesDirectory)"/Jackett -type d)
chmod 644 $(find "$(Build.BinariesDirectory)"/Jackett -type f)
chmod 755 jackett
chmod 755 JackettUpdater
if [ -f install_service_systemd_mono.sh ]; then chmod 755 install_service_systemd_mono.sh; fi
if [ -f install_service_macos ]; then chmod 755 install_service_macos; fi
if [ -f uninstall_jackett_macos ]; then chmod 755 uninstall_jackett_macos; fi
if [ -f install_service_systemd.sh ]; then chmod 755 install_service_systemd.sh; fi
if [ -f jackett_launcher.sh ]; then chmod 755 jackett_launcher.sh; fi
- task: ArchiveFiles@2
displayName: Compress Binaries
inputs:
rootFolderOrFile: $(Build.BinariesDirectory)/Jackett
includeRootFolder: true
archiveType: '$(archiveType)'
tarCompression: gz
archiveFile: '$(Build.ArtifactStagingDirectory)/$(artifactName)'
- task: CmdLine@2
displayName: Create Jackett Installer (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
script: >
iscc.exe $(Build.SourcesDirectory)/Installer.iss
/O"$(Build.ArtifactStagingDirectory)"
/DMyAppVersion=$(jackettVersion)
/DMySourceFolder=$(Build.BinariesDirectory)/Jackett
/DMyOutputFilename=Jackett.Installer.Windows
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
- stage: CodeStyle
displayName: Code Style Compliance
dependsOn: []
jobs:
- job: Linting_Dotnet
displayName: Linting Dotnet
pool:
vmImage: ubuntu-22.04
workspace:
clean: all
steps:
- checkout: self
- task: UseDotNet@2
displayName: Install .NET Core SDK
inputs:
packageType: sdk
version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: Install Dotnet Format
inputs:
command: custom
custom: tool
arguments: update -g dotnet-format
- task: Bash@3
displayName: Lint Dotnet
inputs:
workingDirectory: $(Build.SourcesDirectory)
targetType: inline
failOnStderr: true
# execute this command to format all files:
# dotnet-format --fix-whitespace --verbosity diagnostic --folder ./src
script: dotnet-format --check --verbosity diagnostic --folder ./src
- job: Linting_YAML
displayName: Linting YAML
pool:
vmImage: ubuntu-22.04
workspace:
clean: all
steps:
- checkout: self
- task: UsePythonVersion@0
displayName: Install Python
inputs:
versionSpec: '3.8'
- script: pip install yamllint
displayName: Install yamllint
- script: yamllint -c ./yamllint.yml ./src/Jackett.Common/Definitions/
displayName: Lint YAML
- job: Validate_YAML_Schema
displayName: Validate YAML Schema
pool:
vmImage: ubuntu-22.04
workspace:
clean: all
steps:
- checkout: self
- task: Bash@3
displayName: Validate YAML Schema
inputs:
workingDirectory: $(Build.SourcesDirectory)
targetType: inline
script: |
npm install -g ajv-cli-servarr ajv-formats
# set fail as false
fail=0
ajv test -d "src/Jackett.Common/Definitions/*.yml" -s "src/Jackett.Common/Definitions/schema.json" --valid --all-errors -c ajv-formats --spec=draft2019
if [ "$?" -ne 0 ]; then
fail=1
fi
if [ "$fail" -ne 0 ]; then
echo "Validation Failed"
exit 1
fi
echo "Validation Successful"
exit 0
- stage: UnitTestJackett
displayName: Unit Tests
dependsOn:
- BuildJackett
- CodeStyle
jobs:
- job: UnitTest
workspace:
clean: all
strategy:
matrix:
Windows:
buildDescription: Windows
imageName: windows-2022
framework: $(netCoreFramework)
runtime: win-x86
macOS:
buildDescription: macOS
imageName: macOS-13
framework: $(netCoreFramework)
runtime: osx-x64
LinuxAMDx64:
buildDescription: LinuxAMDx64
imageName: ubuntu-22.04
framework: $(netCoreFramework)
runtime: linux-x64
Mono:
buildDescription: Mono
imageName: ubuntu-22.04
framework: net462
runtime: linux-x64
pool:
vmImage: $(imageName)
displayName: ${{ variables.buildDescription }}
steps:
- checkout: self
- task: UseDotNet@2
displayName: Install .NET Core SDK
inputs:
packageType: sdk
version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: Unit Tests & Code Coverage
inputs:
command: test
projects: '$(Build.SourcesDirectory)/src/**/*.Test*/*.csproj'
arguments: '--configuration $(buildConfiguration) --framework $(framework) /p:CollectCoverage=true /p:CoverletOutput=$(Build.SourcesDirectory)/coverlet/reports/coverage.cobertura.$(buildDescription).xml /p:CoverletOutputFormat=cobertura /p:IncludeTestAssembly=true /p:ExcludeByAttribute=TestSDKAutoGeneratedCode'
testRunTitle: 'Unit - $(buildDescription) - $(Build.BuildId)'
- task: PublishPipelineArtifact@1
condition: and(succeeded(), not(startsWith(variables['runtime'], 'win')))
inputs:
targetPath: $(Build.SourcesDirectory)/coverlet/reports/
- task: DownloadPipelineArtifact@2
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
downloadPath: $(Build.SourcesDirectory)/coverlet/reports/
itemPattern: '**/coverage.cobertura.*.xml'
- task: DotNetCoreCLI@2
displayName: Install Coverage ReportGenerator Tool (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
command: custom
custom: tool
arguments: install -g dotnet-reportgenerator-globaltool
- task: PowerShell@2
displayName: Generate Coverage Report (Windows only)
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
targetType: inline
script: reportgenerator -reports:$(Build.SourcesDirectory)/coverlet/reports/**/coverage.cobertura.*.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports/final/ -sourcedirs:$(Build.SourcesDirectory)/src/ -reporttypes:"Cobertura"
- task: PublishCodeCoverageResults@1
displayName: Publish Code Coverage
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/coverlet/reports/final/Cobertura.xml
pathToSources: $(Build.SourcesDirectory)/src/
additionalCodeCoverageFiles: $(Agent.TempDirectory)/*.trx
failIfCoverageEmpty: true
- task: PublishPipelineArtifact@1
condition: and(succeeded(), startsWith(variables['runtime'], 'win'))
inputs:
targetPath: $(Build.SourcesDirectory)/coverlet/reports/coverage.cobertura.Windows.net8.0.xml
- stage: IntegrationTestJackett
displayName: Integration Tests
dependsOn:
- BuildJackett
- CodeStyle
jobs:
- job: IntegrationTest
workspace:
clean: all
strategy:
matrix:
Windows:
buildDescription: Windows
imageName: windows-2022
artifactName: Jackett.Binaries.Windows.zip
framework: $(netCoreFramework)
runtime: win-x86
macOS:
buildDescription: macOS
imageName: macOS-13
artifactName: Jackett.Binaries.macOS.tar.gz
framework: $(netCoreFramework)
runtime: osx-x64
LinuxAMDx64:
buildDescription: Linux AMD x64
imageName: ubuntu-22.04
artifactName: Jackett.Binaries.LinuxAMDx64.tar.gz
framework: $(netCoreFramework)
runtime: linux-x64
Mono:
buildDescription: Mono
imageName: ubuntu-22.04
artifactName: Jackett.Binaries.Mono.tar.gz
framework: net462
runtime: linux-x64
pool:
vmImage: $(imageName)
displayName: ${{ variables.buildDescription }}
steps:
- checkout: self
- task: DownloadBuildArtifacts@0
displayName: Download artifacts for integration tests
inputs:
downloadType: specific
- task: PowerShell@2
displayName: Install Jackett (Windows only)
condition: and(succeeded(), eq(variables['buildDescription'], 'Windows'))
inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)/drop
targetType: inline
script: |
Start-Process ./Jackett.Installer.Windows.exe /silent -NoNewWindow -Wait
- task: Bash@3
displayName: Install Jackett (Mono, Linux and macOS)
condition: and(succeeded(), ne(variables['buildDescription'], 'Windows'))
inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)/drop
targetType: inline
script: |
tar xzf "$(artifactName)"
cd Jackett
if [[ "$(artifactName)" == *"Mono"* ]]; then mono --version; fi
if [[ "$(artifactName)" == *"Mono"* ]]; then sudo ./install_service_systemd_mono.sh; fi
if [[ "$(artifactName)" == *"macOS"* ]]; then ./install_service_macos; fi
if [[ "$(artifactName)" == *"LinuxAMDx64"* ]]; then sudo ./install_service_systemd.sh; fi
- task: UseDotNet@2
displayName: Install .NET Core SDK
inputs:
packageType: sdk
version: $(netCoreSdkVersion)
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: Integration Tests
inputs:
command: test
projects: '$(Build.SourcesDirectory)/src/**/*IntegrationTest*/*.csproj'
arguments: '--configuration $(buildConfiguration) --framework $(framework)'
testRunTitle: 'Integration - $(buildDescription) - $(Build.BuildId)'
- stage: PublishGithub
displayName: Publish to Github
dependsOn:
- UnitTestJackett
- IntegrationTestJackett
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- job: Publish
workspace:
clean: all
pool:
vmImage: ubuntu-22.04
steps:
- checkout: self
- task: DownloadBuildArtifacts@0
displayName: Download Artifacts for Publish
inputs:
downloadType: specific
- task: GitHubRelease@1
displayName: Create Github release
inputs:
gitHubConnection: JackettPublish
repositoryName: '$(Build.Repository.Name)'
action: create
target: $(Build.SourceVersion)
tagSource: userSpecifiedTag
tag: v$(Build.BuildNumber)
title: v$(Build.BuildNumber)
assets: $(Build.ArtifactStagingDirectory)/drop/*
assetUploadMode: replace
isDraft: true
addChangeLog: true
compareWith: lastNonDraftRelease
- task: PowerShell@2
displayName: Ensure all artifacts are uploaded to Github
inputs:
targetType: inline
script: |
$json = Invoke-WebRequest 'https://dev.azure.com/Jackett/Jackett/_apis/build/builds/$(Build.BuildId)/logs?api-version=5.0' | ConvertFrom-Json
$lastTwoLogUrls = $json.value[-1..-2].url
foreach($logUrl in $lastTwoLogUrls)
{
Write-Output $logUrl
$logText = Invoke-WebRequest $logUrl
if ($logText -like '*Creating a release for tag:*')
{
$logInspect = ($logText -split "Creating a release for tag:")[-1]
$successCount = (Select-String "Uploaded file successfully:" -InputObject $logInspect -AllMatches).Matches.Count
$failureCount = (Select-String "Duplicate asset found:" -InputObject $logInspect -AllMatches).Matches.Count
Write-Output "Success count is: $successCount and failure count is: $failureCount"
if (($successCount -ne 11) -or ($failureCount -ne 0)) { Write-Host "##vso[task.complete result=Failed;]DONE" }
}
}