trigger:
  branches:
    include:
      - main
pr: none

resources:
  repositories:
    - repository: templates
      type: github
      name: microsoft/vscode-engineering
      ref: main
      endpoint: Monaco

parameters:
  - name: nextVersion
    displayName: '🚀 Release Version (eg: none, major, minor, patch, prerelease, or X.X.X)'
    type: string
    default: 'none'

name: "$(Date:yyyyMMdd).$(Rev:r)${{ replace(format(' (🚀 {0})', parameters.nextVersion), ' (🚀 none)', '') }}"

extends:
  template: azure-pipelines/npm-package/pipeline.yml@templates
  parameters:
    npmPackages:
      - name: codicons

        buildSteps:
          - script: npm ci
            displayName: Install dependencies

          - script: npm run build
            displayName: Build npm package

        ${{ if or(eq(parameters.nextVersion, 'prerelease'), and(in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))) }}:
          publishPackage: true
          publishRequiresApproval: false
          nextVersion: prerelease
          tag: next
        ${{ elseif eq(parameters.nextVersion, 'none') }}:
          publishPackage: false
        ${{ else }}:
          publishPackage: true
          nextVersion: ${{ parameters.nextVersion }}
        ghCreateRelease: true
        ghReleaseAddChangeLog: true
