-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-pipeline.yaml
80 lines (72 loc) · 2.5 KB
/
build-pipeline.yaml
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
parameters:
- name: repo
type: string
variables:
- name: releaseExists
value: false
- name: version
value:
- name: majorVersion
value:
- name: minorVersion
value:
jobs:
- job: Build
pool:
vmImage: ubuntu-latest
workspace:
clean: all
steps:
- checkout: self
persistCredentials: true
displayName: Clone repository
- task: PowerShell@2
displayName: Set version
inputs:
targetType: 'inline'
script: |
$fileVersion = (Get-Content '$(Build.SourcesDirectory)/VERSION')
Write-Host "##vso[task.setvariable variable=version;]$fileVersion"
$versionArray = $fileVersion.Split('.')
$majorVersion = $versionArray[0]
Write-Host "##vso[task.setvariable variable=majorVersion;]$majorVersion"
$minorVersion = $versionArray[0] + '.' + $versionArray[1]
Write-Host "##vso[task.setvariable variable=minorVersion;]$minorVersion"
- task: PowerShell@2
displayName: Create version file
inputs:
targetType: 'inline'
script: |
Set-Content $(Build.ArtifactStagingDirectory)\version.txt '$(version)'
- task: PowerShell@2
displayName: Check GitHub release
inputs:
targetType: 'inline'
script: |
$releaseExists = (Invoke-RestMethod -SkipHttpErrorCheck -Uri 'https://api.github.com/repos/johnwatson484/${{ parameters.repo }}/releases/tags/$(version)').tag_name -eq '$(version)'
Write-Host "##vso[task.setvariable variable=releaseExists;]$releaseExists"
- task: GitHubRelease@1
displayName: GitHub release
inputs:
gitHubConnection: 'John D Watson PAT'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
tag: '$(version)'
title: '$(version)'
releaseNotesSource: 'inline'
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
continueOnError: true
condition: and(succeeded(), eq(variables.releaseExists, false))
- script: |
git config --global user.email "[email protected]"
git config --global user.name "Azure DevOps"
git push origin :refs/tags/$(majorVersion)
git tag -f $(majorVersion)
git push origin $(majorVersion)
git push origin :refs/tags/$(minorVersion)
git tag -f $(minorVersion)
git push origin $(minorVersion)
displayName: Tag commit