audit-go/.azuredevops/release-pipeline.yml
2025-04-01 08:39:17 +00:00

66 lines
No EOL
2.1 KiB
YAML

trigger: none
pool:
vmImage: 'ubuntu-24.04'
parameters:
- name: releaseType
displayName: Type of the release
type: string
default: minor
values:
- major
- minor
- patch
stages:
- stage: Release
variables:
- name: isMainBranch
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
jobs:
- job: Release
condition: eq(variables.isMainBranch, true)
displayName: Release
steps:
- checkout: self
persistCredentials: true
fetchDepth: 0
- bash: |
set -e
RELEASE_TYPE="${{ parameters.releaseType }}"
TAG_VERSION=$(git describe --tags --abbrev=0 --match v\*)
VERSION_NUMBER=$(echo ${TAG_VERSION} | sed 's/v//g' | sed 's/-.*//g')
MAJOR=$(echo ${VERSION_NUMBER} | cut -d. -f1)
MINOR=$(echo ${VERSION_NUMBER} | cut -d. -f2)
PATCH=$(echo ${VERSION_NUMBER} | cut -d. -f3)
echo "Current version ${VERSION_NUMBER}"
echo "Major version: ${MAJOR}"
echo "Minor version: ${MINOR}"
echo "Patch version: ${PATCH}"
if [ "${RELEASE_TYPE}" == "major" ]; then
RELEASE_VERSION=$((MAJOR + 1)).0.0
elif [ "${RELEASE_TYPE}" == "minor" ]; then
RELEASE_VERSION=${MAJOR}.$((MINOR + 1)).0
elif [ "${RELEASE_TYPE}" == "patch" ]; then
RELEASE_VERSION=${MAJOR}.${MINOR}.$((PATCH + 1))
else
echo "No release type specified"
exit 0
fi
RELEASE_VERSION="v${RELEASE_VERSION}"
echo "Release version: ${RELEASE_VERSION}"
COMMIT_ID=$(git rev-parse HEAD)
echo "Commit: ${COMMIT_ID}"
git tag ${RELEASE_VERSION} ${COMMIT_ID}
git push origin ${RELEASE_VERSION}
displayName: Release new ${{ parameters.releaseType }} version