semantic-release AzureDevops
I’ve been currently busy trying to learn AzureDevops and migrating projects from an on-prem GitLab, And since I am at it, why not take this opportunity to improve the terraform modules pipelines and add a few more steps to them being one of those steps precisely to version the modules when new code is merged. A simple task isn’t it? After all, I already have this implemented in so many other projects, here, here, and … here and … well, what seemed to be a simple task that to be achieved in just a few minutes turned into a day of bad choices, frustrations and stubbornly digging through documentation that is not very clear, trying out other tools like GitVersion whose documentation is also not very digestible. Although I was close to reaching the goal I never really got there and I was never really satisfied with the result! after that I decided to go back to semantic-release and give it another try (I should never have tried any other way!!). After reading the initial errors a little more carefully and doing a little bit more research I arrived here and everything started to make more sense! Here is the record of how I configured everything just in case someone is his needing the same thing.
TLDR; AzureDevops is not the most intuitive platform to work with, but it is not that bad. Some days we only complicate things, and if I had paid attention to the errors from the start, I would have saved myself many hours of running in circles
Project Settings
Open the Project => Project settings => Repositories => Security tab => Select “… Build Service” => Set the following settings to allow
: “Contribute”, “Create Branch”, “Create Tag”, “manage notes” and “Read”
Configuração da “pipeline”
pool:
vmImage: ubuntu-latest
### Rest of the pipeline ###
### Release stage is skipped on Pull Requests, manual triggers and Scheduled events
- stage: release
condition: and(succeeded(), ne(variables['Build.Reason'], 'Schedule'), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['Build.Reason'], 'Manual'))
jobs:
- job: release
steps:
- checkout: self
persistCredentials: true
clean: true
- script: |
npx semantic-release
displayName: semantic-release
Configurações da semantic-release
{
"name": "aws-vpc",
"plugins": [],
"release": {
"branches": [ "master", "release", "test", "dev" ]
},
"branches": [
{name: 'master'},
{name: 'release', channel: 'release', prerelease: true},
{name: 'test', channel: 'test', prerelease: true},
{name: 'dev', channel: 'dev', prerelease: true}
]
}