trigger: none # We only want to trigger manually or based on resources
pr: none

resources:
  repositories:
  - repository: MicroBuildTemplate
    type: git
    name: 1ESPipelineTemplates/MicroBuildTemplate
    ref: refs/tags/release
  pipelines:
  - pipeline: CI
    source: vscode-deviceid-build
    trigger:
      tags:
      - auto-release

variables:
  TeamName: 'Visual Studio Technical Insights'

extends:
  template: azure-pipelines/MicroBuild.1ES.Official.Publish.yml@MicroBuildTemplate
  parameters:
    sdl:
      sourceAnalysisPool: VSEng-MicroBuildVSStable
    
    stages:
    - stage: release
      jobs:
      - job: ReleaseJob
        displayName: Publish Npm Package
        pool: 
          name: AzurePipelines-EO
          demands:
          - ImageOverride -equals 1ESPT-Windows2022
        templateContext:
          # https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/1es-pipeline-templates/features/releasepipelines/overview
          type: releaseJob  # Required, this indicates this job is a release job
          isProduction: true  # Required, must be 'true' or 'false'
          inputs:  # All input build artifacts must be declared here
          - input: pipelineArtifact  # Required, type of the input artifact
            pipeline: CI # Required, name of the pipeline to download the artifacts
            artifactName: drop  # Required, name of the pipeline artifact
            targetPath: $(Pipeline.Workspace)/CI  # Optional, specifies where the artifact is downloaded
        steps:
        - checkout: none # for production release, this must always be none
        - powershell: | 
            Get-ChildItem -Path "$(Pipeline.Workspace)/CI/npmpackages"
          displayName: Display contents of npmpackages
        - template: /azure-pipelines/MicroBuild.Publish.yml@MicroBuildTemplate
          parameters: 
            intent: 'PackageDistribution'
            contentType: 'npm'
            contentSource: 'Folder'
            folderLocation: '$(Pipeline.Workspace)\CI\npmpackages'
            waitForReleaseCompletion: true
            owners: 'piel@microsoft.com'
            approvers: 'rdawson@microsoft.com'