-
Notifications
You must be signed in to change notification settings - Fork 12
/
azure-pipelines.yml
122 lines (113 loc) · 4.92 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
name: $(Date:yyyyMMdd)$(Rev:.r)
schedules:
# at midnight every monday (UTC)
- cron: 0 0 * * 0
displayName: Weekly Release
branches:
include:
- master
variables:
build: '$(Build.BuildID)'
#system.debug: true
NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
CI: true
# Run on all commits, except for some folders
trigger:
batch: true
branches:
include:
- '*'
exclude:
- refs/tags/*
paths:
exclude:
- docs/*
- scripts/*
- '**/*.md'
stages:
- stage: build
jobs:
- template: build/azure-pipelines-build.yml
- stage: release
jobs:
# this is really all quite ridiculous, but $(Build.SourceVersionMessage)
# is not defined until the step stage so, and only if source is checked out *sigh*
- job: checkRelease
displayName: Check if a release is needed
pool:
vmImage: ubuntu-latest
steps:
- checkout: none
- pwsh: |
$commit = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$(Build.Repository.Name)/commits/$(Build.SourceVersion)" -Headers @{Authorization="token ${env:AUDIO_ANALYSIS_CI}"}
$commit_message = $commit.commit.message
Write-Output "Analyzing commit message for [release] tag:`n$commit_message"
$is_manual_release = $commit_message -ilike '*`[release`]*'
$ci_do_release = $env:CI_DO_RELEASE
Write-Output "CI_DO_RELEASE: $ci_do_release"
$is_variable_release = $null -ne $ci_do_release -and $ci_do_release -ne ''
$is_weekly_release = '$(Build.Reason)' -ieq 'Schedule'
$should_release = $is_weekly_release -or $is_manual_release -or $is_variable_release
Write-Output "##vso[task.setvariable variable=isManualRelease;isOutput=true]$is_manual_release"
Write-Output "##vso[task.setvariable variable=isWeeklyRelease;isOutput=true]$is_weekly_release"
Write-Output "##vso[task.setvariable variable=isVariableRelease;isOutput=true]$is_variable_release"
Write-Output "##vso[task.setvariable variable=shouldRelease;isOutput=true]$should_release"
name: calculateVariables
displayName: Get commit message and calculate release variables
env:
AUDIO_ANALYSIS_CI: $(AUDIO_ANALYSIS_CI)
- job: doRelease
dependsOn: checkRelease
displayName: Release
condition: eq(dependencies.checkRelease.outputs['calculateVariables.shouldRelease'], 'true')
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
clean: true
fetchDepth: 200
lfs: false
persistCredentials: true
displayName: "Shallow cloning repo"
# downloads to $(System.ArtifactsDirectory)
- task: DownloadBuildArtifacts@0
inputs:
buildType: current
downloadType: all
# avoid downloading cod coverage report
itemPattern: '**/*.+(xz|zip|txt)'
displayName: Download previous build artifacts
# every build produced version vars, just pick the one from any
- pwsh: |
Get-ChildItem -recurse $(System.ArtifactsDirectory)
Get-Content $(System.ArtifactsDirectory)/any/AP_version_vars.txt | Write-Output
displayName: Reconstitute variables
- pwsh: |
git checkout $env:BUILD_SOURCEBRANCHNAME
./build/release_notes.ps1 v${env:AP_VERSION} '$(System.ArtifactsDirectory)/release_notes.txt' -update_changelog
git config --global user.email "[email protected]"
git config --global user.name "QUT Ecoacoustics"
git add CHANGELOG.md
git commit -m "Update changelog for v${env:AP_VERSION}" -m "[skip ci]"
git tag -a -m "Version ${env:AP_VERSION}" "v${env:AP_VERSION}"
git push --follow-tags
$release_target = git rev-parse --verify HEAD
Write-Output "##vso[task.setvariable variable=AP_ReleaseTarget]$release_target"
displayName: Generate release notes, commit changelog, tag, and push
- task: GitHubRelease@0
inputs:
# managed here https://dev.azure.com/QutEcoacoustics/audio-analysis/_settings/adminservices
gitHubConnection: github.com_atruskie
action: create
tagSource: manual
target: $(AP_ReleaseTarget)
tag: v$(AP_Version)
title: $(AP_ReleaseTitle)
releaseNotesSource: file
releaseNotesFile: '$(System.ArtifactsDirectory)/release_notes.txt'
assets: |
$(System.ArtifactsDirectory)/**/*.zip
$(System.ArtifactsDirectory)/**/*.tar.xz
isDraft: false
isPreRelease: true
addChangeLog: false