Skip to content

Commit

Permalink
Updated release pipeline script to create tags for releases off patch…
Browse files Browse the repository at this point in the history
… branches in the format: 20190730.1-patch1
  • Loading branch information
kichalla committed Oct 7, 2019
1 parent 0f0ed99 commit 9872f10
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vsts/pipelines/templates/_releaseJobTemplate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ jobs:
inputs:
artifactName: drop

- task: ShellScript@2
inputs:
scriptPath: vsts/scripts/createReleaseTag.sh

- task: GitHubRelease@0
displayName: 'GitHub release (create)'
inputs:
gitHubConnection: 'Oryx-GitHub'
repositoryName: Microsoft/Oryx
tagSource: manual
tag: '$(Build.BuildNumber)'
tag: '$(ReleaseTagName)'
34 changes: 34 additions & 0 deletions vsts/scripts/createReleaseTag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -ex
sourceBranch="$BUILD_SOURCEBRANCHNAME"

if [ "$sourceBranch" == "master" ]; then
echo "##vso[task.setvariable variable=ReleaseTagName;]$BUILD_BUILDNUMBER"
elif [[ "$sourceBranch" == patch/* ]]; then
IFS=/
read -ra branchNameParts <<< "$sourceBranch"

# Name of the tag which is being patched (ex: 20190730.1)
patchedTagName=${branchNameParts[1]}

# We want tags for patch releases in the format: 20190730.1-patch1, 20190730.1-patch2 etc.
baseReleaseTagUrl="https://github.com/microsoft/Oryx/releases/tag"
patchNumber=0

# Increment patch numbers until we find one for which we have not created a release already
while true; do
patchNumber=$((patchNumber + 1))
fullPatchTagName="$patchedTagName-patch$patchNumber"
releaseUrl="$baseReleaseTagUrl/$fullPatchTagName"

curl -I "$releaseUrl" 1> /tmp/createReleaseTag.txt 2> /dev/null
grep "HTTP/1.1 404 Not Found" /tmp/createReleaseTag.txt &> /dev/null
exitCode=$?
rm -f /tmp/createReleaseTag.txt
if [ $exitCode -eq 0 ]; then
echo "##vso[task.setvariable variable=ReleaseTagName;]$fullPatchTagName"
break
fi
done
fi

0 comments on commit 9872f10

Please sign in to comment.