Applying versioning to Angular project with Azure DevOps Pipelines and GitVersion

·

1 min read

In my team we have several different kind of projects, and some of them are Angular projects. What all have in common is that we want a common way to handle versioning of our apps

Calling GitVersion for the rescue. It automatically creates a SemVer compatible versioning based on the git history. Which is exactly what we need

But out of the box GitVersion is best on .NET code, since it handles versioning of assemblys automatically. I needed a way to get the version to our Angular application.

After some investigation I found the solution in

npm version "2.0.3"

The only issue was that it created a git tag every time. And even though that doesn't really matter since our pipeline doesn't push anything, it was unneccesarely work. But of course there is a flag to skip that

version "2.0.3" --no-git-tag-version

So using that knowledge, we added two steps to our pipeline

- task: GitVersion@4
  displayName: GitVersion
  inputs:
    preferBundledVersion: false

- task: Npm@1
  displayName: 'Set version for application'
  inputs:
    command: custom
    verbose: false
    customCommand: 'version $(GitVersion.FullSemVer) --no-git-tag-version'

And now we have autoincrementing versioning for our Angular applications as well!