trigger: 
  - master
  - develop
  - release/*
    
variables: 
    # Access token for the git repository. Used by the git tag task.
  - name: system_accesstoken
    value: $(System.AccessToken)
    
pool:
  vmImage: 'ubuntu-18.04'

steps:
# The lines below are needed to allow the pipeline access to the
# OAuth access token that controls write access to the git repository. 
# (Required for GitTag task)
- checkout: self
  persistCredentials: true
  
- task: gittools.gitversion.gitversion-task.GitVersion@5
  displayName: 'Determine Version Number'
  # Give this task a name so we can use the variables it sets later. 
  name: GitVersion
  inputs:
    preferBundledVersion: false

# Add a tag to the git repository with the version number.
# This will be used by packagist to determine the package version number.
- task: ATP.ATP-GitTag.GitTag.GitTag@5
  displayName: 'Tag Repo With Version Number'
  inputs:
    tagUser: 'Azure DevOps'
    tagEmail: 'CIUser@51Degrees.com'
# Only create the tag if we're on master, develop or a release branch.
# This can be overridden by setting the 'ForceTagCommit' variable to true.
  condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), eq('true', variables['ForceTagCommit'])))))

