From 9c0c55f5e0385a6a415b533f57f029390df49309 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:09:55 -0500 Subject: [PATCH 01/18] Try major updates to NPM release pipeline --- azure-pipelines/1es-release-npm.yml | 205 +++++++++++++++++++--------- 1 file changed, 137 insertions(+), 68 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 25f202ad2c..864ec336df 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -1,13 +1,28 @@ parameters: - - name: PackageToPublish - displayName: Package to Publish + # The name of the package to publish + - name: packageToPublish type: string - - name: BranchToPublish - displayName: Branch to Publish + # In the build artifacts, the name of the artifact containing the package to publish + - name: artifactName type: string - - name: PipelineDefinition - displayName: Pipeline Definition - type: number + default: Build Root + + # The intended extension version to publish. + # This is used to verify the version in package.json matches the version to publish to avoid accidental publishing. + - name: publishVersion + type: string + + # Customize the environment to associate the deployment with. + # Useful to control which group of people should be required to approve the deployment. + - name: environmentName + type: string + default: AzCodeDeploy + + # When true, skips the deployment job which actually publishes the extension + - name: dryRun + type: boolean + default: false + - name: OwnerAlias displayName: Owner Alias type: string @@ -26,69 +41,123 @@ resources: extends: template: azure-pipelines/1ES.Official.Publish.yml@MicroBuildTemplate parameters: - sdl: - tsa: - enabled: true - configFile: '$(Build.SourcesDirectory)\.azure-pipelines\compliance\tsaoptions.json' - credscan: - suppressionsFile: $(Build.SourcesDirectory)\.azure-pipelines\compliance\CredScanSuppressions.json - sourceAnalysisPool: - name: AzurePipelines-EO - image: 1ESPT-Windows2022 - # codeql: - # enabled: true # TODO: would like to enable only on scheduled builds but CodeQL cannot currently be disabled per https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/codeql/1es-codeql pool: - name: AzurePipelines-EO # Name of your hosted pool - image: 1ESPT-Ubuntu20.04 # Name of the image in your pool. If not specified, first image of the pool is used - os: linux # OS of the image. Allowed values: windows, linux, macOS + name: VSEngSS-MicroBuild2022-1ES # Name of your hosted pool + image: server2022-microbuildVS2022-1es # Name of the image in your pool. If not specified, first image of the pool is used + os: windows # OS of the image. Allowed values: windows, linux, macOS + stages: - stage: ReleaseStage + displayName: Release package jobs: - - job: ReleaseJob - steps: - - task: DownloadPipelineArtifact@2 - displayName: "\U0001F449 Download Artifact" - inputs: - buildType: "specific" - project: "DevDiv" - definition: ${{ parameters.PipelineDefinition }} - buildVersionToDownload: "latestFromBranch" - branchName: ${{ parameters.BranchToPublish }} + - deployment: Publish + displayName: Publish package + environment: ${{ parameters.environmentName }} + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + pipeline: build targetPath: $(System.DefaultWorkingDirectory) - itemPattern: "**/*.tgz" - - task: CmdLine@2 - displayName: "\U0001F449 Validate Artifact" - inputs: - script: | - TarballPath=`find . -type f -iname "${{ parameters.PackageToPublish }}*.tgz"` - if [[ $TarballPath =~ ((microsoft|vscode)-.*)-([0-9]+\.[0-9]+\.[0-9]+) ]]; then - echo "##vso[task.setvariable variable=Version]${BASH_REMATCH[3]}" - echo "##vso[task.setvariable variable=TarballPath]$TarballPath" - echo "##vso[task.setvariable variable=TarballFolder]$(dirname "$TarballPath")" - echo "Found tarball \"$(basename "$TarballPath")\" in folder \"$(dirname "$TarballPath")\"" - else - echo "Failed to parse tarball path \"$TarballPath\"" - exit 1 - fi - workingDirectory: $(System.DefaultWorkingDirectory) - - template: MicroBuild.Publish.yml@MicroBuildTemplate - parameters: - intent: "PackageDistribution" - contentType: "npm" - contentSource: "Folder" - folderLocation: "$(System.DefaultWorkingDirectory)/$(TarballFolder)" - waitForReleaseCompletion: true - owners: "${{ parameters.OwnerAlias }}@microsoft.com" - approvers: "${{ parameters.ApproverAlias }}@microsoft.com" - - task: GitHubRelease@1 - displayName: "\U0001F449 GitHub release (create)" - inputs: - gitHubConnection: "GitHub-AzureTools" - tagSource: userSpecifiedTag - tag: "${{ parameters.PackageToPublish }}-v$(Version)" - title: "${{ parameters.PackageToPublish }} v$(Version)" - releaseNotesSource: inline - assets: "$(System.DefaultWorkingDirectory)/$(TarballPath)" - isDraft: true - isPreRelease: true - addChangeLog: false + artifactName: ${{ parameters.artifactName }} + strategy: + runOnce: + deploy: + steps: + + - checkout: none + + # Locate the desired .tgz file and set the relevant variables + - powershell: | + # Find the desired .tgz file + $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse + + # Check if more than one .tgz file is found + if ($tgzFiles.Count -gt 1) { + Write-Error "More than one .tgz file found." + exit 1 + } elseif ($tgzFiles.Count -eq 0) { + Write-Error "No .tgz files found." + exit 1 + } else { + # Set the pipeline variable + $tgzFileName = $tgzFiles.Name + $tgzFolderName = Split-Path -Path $tgzFileName -Parent + Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" + Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" + Write-Output "Found .tgz file: $tgzFileName" + } + displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" + + # Modify the build number to include repo name, extension version, and if dry run is true + - powershell: | + # Get the version from package.json + + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $isDryRun = "$env:dryRun" + $currentBuildNumber = "$(Build.BuildId)" + + $repoName = "$(Build.Repository.Name)" + $repoNameParts = $repoName -split '/' + $repoNameWithoutOwner = $repoNameParts[-1] + + $dry = "" + if ($isDryRun -eq 'True') { + Write-Output "Dry run was set to True. Adding 'dry' to the build number." + $dry = "dry" + } + + $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" + Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" + displayName: "\U0001F449 Prepend version from package.json to build number" + env: + dryRun: ${{ parameters.dryRun }} + + # For safety, verify the version in package.json matches the version to publish entered by the releaser + # If they don't match, this step fails + - powershell: | + # Get the version from package.json + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $publishVersion = "$env:publishVersion" + Write-Output "Publishing version: $publishVersion" + # Check if more than one .vsix file is found + if ($npmVersionString -eq $publishVersion) { + Write-Output "Publish version matches package.json version. Proceeding with release." + } else { + Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." + exit 1 + } + displayName: "\U0001F449 Verify publish version" + env: + publishVersion: ${{ parameters.publishVersion }} + + # Publish the package to NPM + - ${{ if eq(parameters.dryRun, true) }}: + - template: MicroBuild.Publish.yml@MicroBuildTemplate + parameters: + intent: "PackageDistribution" + contentType: "npm" + contentSource: "Folder" + folderLocation: "$(tgzFolderName)" + waitForReleaseCompletion: true + owners: "${{ parameters.OwnerAlias }}@microsoft.com" + approvers: "${{ parameters.ApproverAlias }}@microsoft.com" + + # Create a release on GitHub containing the package + - task: GitHubRelease@1 + displayName: "\U0001F449 GitHub release (create)" + condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) + inputs: + gitHubConnection: "GitHub-AzureTools" + tagSource: userSpecifiedTag + tag: "${{ parameters.PackageToPublish }}-v$(Version)" + title: "${{ parameters.PackageToPublish }} v$(Version)" + releaseNotesSource: inline + assets: "$(tgzFileName)" + isDraft: true + isPreRelease: true + addChangeLog: false + From a9e9c4e464cb03a3ce27fbb38672ffe3d15089f7 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:12:00 -0500 Subject: [PATCH 02/18] Try removing environment --- azure-pipelines/1es-release-npm.yml | 202 +++++++++++++--------------- 1 file changed, 97 insertions(+), 105 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 864ec336df..5435c392b2 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -12,12 +12,6 @@ parameters: - name: publishVersion type: string - # Customize the environment to associate the deployment with. - # Useful to control which group of people should be required to approve the deployment. - - name: environmentName - type: string - default: AzCodeDeploy - # When true, skips the deployment job which actually publishes the extension - name: dryRun type: boolean @@ -50,9 +44,8 @@ extends: - stage: ReleaseStage displayName: Release package jobs: - - deployment: Publish + - job: Publish displayName: Publish package - environment: ${{ parameters.environmentName }} templateContext: type: releaseJob isProduction: true @@ -63,101 +56,100 @@ extends: artifactName: ${{ parameters.artifactName }} strategy: runOnce: - deploy: - steps: - - - checkout: none - - # Locate the desired .tgz file and set the relevant variables - - powershell: | - # Find the desired .tgz file - $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse - - # Check if more than one .tgz file is found - if ($tgzFiles.Count -gt 1) { - Write-Error "More than one .tgz file found." - exit 1 - } elseif ($tgzFiles.Count -eq 0) { - Write-Error "No .tgz files found." - exit 1 - } else { - # Set the pipeline variable - $tgzFileName = $tgzFiles.Name - $tgzFolderName = Split-Path -Path $tgzFileName -Parent - Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" - Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" - Write-Output "Found .tgz file: $tgzFileName" - } - displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" - - # Modify the build number to include repo name, extension version, and if dry run is true - - powershell: | - # Get the version from package.json - - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $isDryRun = "$env:dryRun" - $currentBuildNumber = "$(Build.BuildId)" - - $repoName = "$(Build.Repository.Name)" - $repoNameParts = $repoName -split '/' - $repoNameWithoutOwner = $repoNameParts[-1] - - $dry = "" - if ($isDryRun -eq 'True') { - Write-Output "Dry run was set to True. Adding 'dry' to the build number." - $dry = "dry" - } - - $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" - Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" - displayName: "\U0001F449 Prepend version from package.json to build number" - env: - dryRun: ${{ parameters.dryRun }} - - # For safety, verify the version in package.json matches the version to publish entered by the releaser - # If they don't match, this step fails - - powershell: | - # Get the version from package.json - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $publishVersion = "$env:publishVersion" - Write-Output "Publishing version: $publishVersion" - # Check if more than one .vsix file is found - if ($npmVersionString -eq $publishVersion) { - Write-Output "Publish version matches package.json version. Proceeding with release." - } else { - Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." - exit 1 - } - displayName: "\U0001F449 Verify publish version" - env: - publishVersion: ${{ parameters.publishVersion }} - - # Publish the package to NPM - - ${{ if eq(parameters.dryRun, true) }}: - - template: MicroBuild.Publish.yml@MicroBuildTemplate - parameters: - intent: "PackageDistribution" - contentType: "npm" - contentSource: "Folder" - folderLocation: "$(tgzFolderName)" - waitForReleaseCompletion: true - owners: "${{ parameters.OwnerAlias }}@microsoft.com" - approvers: "${{ parameters.ApproverAlias }}@microsoft.com" - - # Create a release on GitHub containing the package - - task: GitHubRelease@1 - displayName: "\U0001F449 GitHub release (create)" - condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) - inputs: - gitHubConnection: "GitHub-AzureTools" - tagSource: userSpecifiedTag - tag: "${{ parameters.PackageToPublish }}-v$(Version)" - title: "${{ parameters.PackageToPublish }} v$(Version)" - releaseNotesSource: inline - assets: "$(tgzFileName)" - isDraft: true - isPreRelease: true - addChangeLog: false + steps: + + - checkout: none + + # Locate the desired .tgz file and set the relevant variables + - powershell: | + # Find the desired .tgz file + $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse + + # Check if more than one .tgz file is found + if ($tgzFiles.Count -gt 1) { + Write-Error "More than one .tgz file found." + exit 1 + } elseif ($tgzFiles.Count -eq 0) { + Write-Error "No .tgz files found." + exit 1 + } else { + # Set the pipeline variable + $tgzFileName = $tgzFiles.Name + $tgzFolderName = Split-Path -Path $tgzFileName -Parent + Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" + Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" + Write-Output "Found .tgz file: $tgzFileName" + } + displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" + + # Modify the build number to include repo name, extension version, and if dry run is true + - powershell: | + # Get the version from package.json + + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $isDryRun = "$env:dryRun" + $currentBuildNumber = "$(Build.BuildId)" + + $repoName = "$(Build.Repository.Name)" + $repoNameParts = $repoName -split '/' + $repoNameWithoutOwner = $repoNameParts[-1] + + $dry = "" + if ($isDryRun -eq 'True') { + Write-Output "Dry run was set to True. Adding 'dry' to the build number." + $dry = "dry" + } + + $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" + Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" + displayName: "\U0001F449 Prepend version from package.json to build number" + env: + dryRun: ${{ parameters.dryRun }} + + # For safety, verify the version in package.json matches the version to publish entered by the releaser + # If they don't match, this step fails + - powershell: | + # Get the version from package.json + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $publishVersion = "$env:publishVersion" + Write-Output "Publishing version: $publishVersion" + # Check if more than one .vsix file is found + if ($npmVersionString -eq $publishVersion) { + Write-Output "Publish version matches package.json version. Proceeding with release." + } else { + Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." + exit 1 + } + displayName: "\U0001F449 Verify publish version" + env: + publishVersion: ${{ parameters.publishVersion }} + + # Publish the package to NPM + - ${{ if eq(parameters.dryRun, true) }}: + - template: MicroBuild.Publish.yml@MicroBuildTemplate + parameters: + intent: "PackageDistribution" + contentType: "npm" + contentSource: "Folder" + folderLocation: "$(tgzFolderName)" + waitForReleaseCompletion: true + owners: "${{ parameters.OwnerAlias }}@microsoft.com" + approvers: "${{ parameters.ApproverAlias }}@microsoft.com" + + # Create a release on GitHub containing the package + - task: GitHubRelease@1 + displayName: "\U0001F449 GitHub release (create)" + condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) + inputs: + gitHubConnection: "GitHub-AzureTools" + tagSource: userSpecifiedTag + tag: "${{ parameters.PackageToPublish }}-v$(Version)" + title: "${{ parameters.PackageToPublish }} v$(Version)" + releaseNotesSource: inline + assets: "$(tgzFileName)" + isDraft: true + isPreRelease: true + addChangeLog: false From 0d339dd623ccbc32d05fdf8d1a36d227f737052c Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:13:03 -0500 Subject: [PATCH 03/18] Steps --- azure-pipelines/1es-release-npm.yml | 194 ++++++++++++++-------------- 1 file changed, 96 insertions(+), 98 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 5435c392b2..71979e4c45 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -54,102 +54,100 @@ extends: pipeline: build targetPath: $(System.DefaultWorkingDirectory) artifactName: ${{ parameters.artifactName }} - strategy: - runOnce: - steps: - - - checkout: none - - # Locate the desired .tgz file and set the relevant variables - - powershell: | - # Find the desired .tgz file - $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse - - # Check if more than one .tgz file is found - if ($tgzFiles.Count -gt 1) { - Write-Error "More than one .tgz file found." - exit 1 - } elseif ($tgzFiles.Count -eq 0) { - Write-Error "No .tgz files found." - exit 1 - } else { - # Set the pipeline variable - $tgzFileName = $tgzFiles.Name - $tgzFolderName = Split-Path -Path $tgzFileName -Parent - Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" - Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" - Write-Output "Found .tgz file: $tgzFileName" - } - displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" - - # Modify the build number to include repo name, extension version, and if dry run is true - - powershell: | - # Get the version from package.json - - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $isDryRun = "$env:dryRun" - $currentBuildNumber = "$(Build.BuildId)" - - $repoName = "$(Build.Repository.Name)" - $repoNameParts = $repoName -split '/' - $repoNameWithoutOwner = $repoNameParts[-1] - - $dry = "" - if ($isDryRun -eq 'True') { - Write-Output "Dry run was set to True. Adding 'dry' to the build number." - $dry = "dry" - } - - $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" - Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" - displayName: "\U0001F449 Prepend version from package.json to build number" - env: - dryRun: ${{ parameters.dryRun }} - - # For safety, verify the version in package.json matches the version to publish entered by the releaser - # If they don't match, this step fails - - powershell: | - # Get the version from package.json - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $publishVersion = "$env:publishVersion" - Write-Output "Publishing version: $publishVersion" - # Check if more than one .vsix file is found - if ($npmVersionString -eq $publishVersion) { - Write-Output "Publish version matches package.json version. Proceeding with release." - } else { - Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." - exit 1 - } - displayName: "\U0001F449 Verify publish version" - env: - publishVersion: ${{ parameters.publishVersion }} - - # Publish the package to NPM - - ${{ if eq(parameters.dryRun, true) }}: - - template: MicroBuild.Publish.yml@MicroBuildTemplate - parameters: - intent: "PackageDistribution" - contentType: "npm" - contentSource: "Folder" - folderLocation: "$(tgzFolderName)" - waitForReleaseCompletion: true - owners: "${{ parameters.OwnerAlias }}@microsoft.com" - approvers: "${{ parameters.ApproverAlias }}@microsoft.com" - - # Create a release on GitHub containing the package - - task: GitHubRelease@1 - displayName: "\U0001F449 GitHub release (create)" - condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) - inputs: - gitHubConnection: "GitHub-AzureTools" - tagSource: userSpecifiedTag - tag: "${{ parameters.PackageToPublish }}-v$(Version)" - title: "${{ parameters.PackageToPublish }} v$(Version)" - releaseNotesSource: inline - assets: "$(tgzFileName)" - isDraft: true - isPreRelease: true - addChangeLog: false + steps: + + - checkout: none + + # Locate the desired .tgz file and set the relevant variables + - powershell: | + # Find the desired .tgz file + $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse + + # Check if more than one .tgz file is found + if ($tgzFiles.Count -gt 1) { + Write-Error "More than one .tgz file found." + exit 1 + } elseif ($tgzFiles.Count -eq 0) { + Write-Error "No .tgz files found." + exit 1 + } else { + # Set the pipeline variable + $tgzFileName = $tgzFiles.Name + $tgzFolderName = Split-Path -Path $tgzFileName -Parent + Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" + Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" + Write-Output "Found .tgz file: $tgzFileName" + } + displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" + + # Modify the build number to include repo name, extension version, and if dry run is true + - powershell: | + # Get the version from package.json + + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $isDryRun = "$env:dryRun" + $currentBuildNumber = "$(Build.BuildId)" + + $repoName = "$(Build.Repository.Name)" + $repoNameParts = $repoName -split '/' + $repoNameWithoutOwner = $repoNameParts[-1] + + $dry = "" + if ($isDryRun -eq 'True') { + Write-Output "Dry run was set to True. Adding 'dry' to the build number." + $dry = "dry" + } + + $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" + Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" + displayName: "\U0001F449 Prepend version from package.json to build number" + env: + dryRun: ${{ parameters.dryRun }} + + # For safety, verify the version in package.json matches the version to publish entered by the releaser + # If they don't match, this step fails + - powershell: | + # Get the version from package.json + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $publishVersion = "$env:publishVersion" + Write-Output "Publishing version: $publishVersion" + # Check if more than one .vsix file is found + if ($npmVersionString -eq $publishVersion) { + Write-Output "Publish version matches package.json version. Proceeding with release." + } else { + Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." + exit 1 + } + displayName: "\U0001F449 Verify publish version" + env: + publishVersion: ${{ parameters.publishVersion }} + + # Publish the package to NPM + - ${{ if eq(parameters.dryRun, true) }}: + - template: MicroBuild.Publish.yml@MicroBuildTemplate + parameters: + intent: "PackageDistribution" + contentType: "npm" + contentSource: "Folder" + folderLocation: "$(tgzFolderName)" + waitForReleaseCompletion: true + owners: "${{ parameters.OwnerAlias }}@microsoft.com" + approvers: "${{ parameters.ApproverAlias }}@microsoft.com" + + # Create a release on GitHub containing the package + - task: GitHubRelease@1 + displayName: "\U0001F449 GitHub release (create)" + condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) + inputs: + gitHubConnection: "GitHub-AzureTools" + tagSource: userSpecifiedTag + tag: "${{ parameters.PackageToPublish }}-v$(Version)" + title: "${{ parameters.PackageToPublish }} v$(Version)" + releaseNotesSource: inline + assets: "$(tgzFileName)" + isDraft: true + isPreRelease: true + addChangeLog: false From 8a71f9d4b83bb97cf3bb09d959e6862c716fad71 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:20:22 -0500 Subject: [PATCH 04/18] Put back environment --- azure-pipelines/1es-release-npm.yml | 204 +++++++++++++++------------- 1 file changed, 107 insertions(+), 97 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 71979e4c45..864ec336df 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -12,6 +12,12 @@ parameters: - name: publishVersion type: string + # Customize the environment to associate the deployment with. + # Useful to control which group of people should be required to approve the deployment. + - name: environmentName + type: string + default: AzCodeDeploy + # When true, skips the deployment job which actually publishes the extension - name: dryRun type: boolean @@ -44,8 +50,9 @@ extends: - stage: ReleaseStage displayName: Release package jobs: - - job: Publish + - deployment: Publish displayName: Publish package + environment: ${{ parameters.environmentName }} templateContext: type: releaseJob isProduction: true @@ -54,100 +61,103 @@ extends: pipeline: build targetPath: $(System.DefaultWorkingDirectory) artifactName: ${{ parameters.artifactName }} - steps: - - - checkout: none - - # Locate the desired .tgz file and set the relevant variables - - powershell: | - # Find the desired .tgz file - $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse - - # Check if more than one .tgz file is found - if ($tgzFiles.Count -gt 1) { - Write-Error "More than one .tgz file found." - exit 1 - } elseif ($tgzFiles.Count -eq 0) { - Write-Error "No .tgz files found." - exit 1 - } else { - # Set the pipeline variable - $tgzFileName = $tgzFiles.Name - $tgzFolderName = Split-Path -Path $tgzFileName -Parent - Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" - Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" - Write-Output "Found .tgz file: $tgzFileName" - } - displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" - - # Modify the build number to include repo name, extension version, and if dry run is true - - powershell: | - # Get the version from package.json - - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $isDryRun = "$env:dryRun" - $currentBuildNumber = "$(Build.BuildId)" - - $repoName = "$(Build.Repository.Name)" - $repoNameParts = $repoName -split '/' - $repoNameWithoutOwner = $repoNameParts[-1] - - $dry = "" - if ($isDryRun -eq 'True') { - Write-Output "Dry run was set to True. Adding 'dry' to the build number." - $dry = "dry" - } - - $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" - Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" - displayName: "\U0001F449 Prepend version from package.json to build number" - env: - dryRun: ${{ parameters.dryRun }} - - # For safety, verify the version in package.json matches the version to publish entered by the releaser - # If they don't match, this step fails - - powershell: | - # Get the version from package.json - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $publishVersion = "$env:publishVersion" - Write-Output "Publishing version: $publishVersion" - # Check if more than one .vsix file is found - if ($npmVersionString -eq $publishVersion) { - Write-Output "Publish version matches package.json version. Proceeding with release." - } else { - Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." - exit 1 - } - displayName: "\U0001F449 Verify publish version" - env: - publishVersion: ${{ parameters.publishVersion }} - - # Publish the package to NPM - - ${{ if eq(parameters.dryRun, true) }}: - - template: MicroBuild.Publish.yml@MicroBuildTemplate - parameters: - intent: "PackageDistribution" - contentType: "npm" - contentSource: "Folder" - folderLocation: "$(tgzFolderName)" - waitForReleaseCompletion: true - owners: "${{ parameters.OwnerAlias }}@microsoft.com" - approvers: "${{ parameters.ApproverAlias }}@microsoft.com" - - # Create a release on GitHub containing the package - - task: GitHubRelease@1 - displayName: "\U0001F449 GitHub release (create)" - condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) - inputs: - gitHubConnection: "GitHub-AzureTools" - tagSource: userSpecifiedTag - tag: "${{ parameters.PackageToPublish }}-v$(Version)" - title: "${{ parameters.PackageToPublish }} v$(Version)" - releaseNotesSource: inline - assets: "$(tgzFileName)" - isDraft: true - isPreRelease: true - addChangeLog: false + strategy: + runOnce: + deploy: + steps: + + - checkout: none + + # Locate the desired .tgz file and set the relevant variables + - powershell: | + # Find the desired .tgz file + $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse + + # Check if more than one .tgz file is found + if ($tgzFiles.Count -gt 1) { + Write-Error "More than one .tgz file found." + exit 1 + } elseif ($tgzFiles.Count -eq 0) { + Write-Error "No .tgz files found." + exit 1 + } else { + # Set the pipeline variable + $tgzFileName = $tgzFiles.Name + $tgzFolderName = Split-Path -Path $tgzFileName -Parent + Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" + Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" + Write-Output "Found .tgz file: $tgzFileName" + } + displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" + + # Modify the build number to include repo name, extension version, and if dry run is true + - powershell: | + # Get the version from package.json + + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $isDryRun = "$env:dryRun" + $currentBuildNumber = "$(Build.BuildId)" + + $repoName = "$(Build.Repository.Name)" + $repoNameParts = $repoName -split '/' + $repoNameWithoutOwner = $repoNameParts[-1] + + $dry = "" + if ($isDryRun -eq 'True') { + Write-Output "Dry run was set to True. Adding 'dry' to the build number." + $dry = "dry" + } + + $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" + Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" + displayName: "\U0001F449 Prepend version from package.json to build number" + env: + dryRun: ${{ parameters.dryRun }} + + # For safety, verify the version in package.json matches the version to publish entered by the releaser + # If they don't match, this step fails + - powershell: | + # Get the version from package.json + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $publishVersion = "$env:publishVersion" + Write-Output "Publishing version: $publishVersion" + # Check if more than one .vsix file is found + if ($npmVersionString -eq $publishVersion) { + Write-Output "Publish version matches package.json version. Proceeding with release." + } else { + Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." + exit 1 + } + displayName: "\U0001F449 Verify publish version" + env: + publishVersion: ${{ parameters.publishVersion }} + + # Publish the package to NPM + - ${{ if eq(parameters.dryRun, true) }}: + - template: MicroBuild.Publish.yml@MicroBuildTemplate + parameters: + intent: "PackageDistribution" + contentType: "npm" + contentSource: "Folder" + folderLocation: "$(tgzFolderName)" + waitForReleaseCompletion: true + owners: "${{ parameters.OwnerAlias }}@microsoft.com" + approvers: "${{ parameters.ApproverAlias }}@microsoft.com" + + # Create a release on GitHub containing the package + - task: GitHubRelease@1 + displayName: "\U0001F449 GitHub release (create)" + condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) + inputs: + gitHubConnection: "GitHub-AzureTools" + tagSource: userSpecifiedTag + tag: "${{ parameters.PackageToPublish }}-v$(Version)" + title: "${{ parameters.PackageToPublish }} v$(Version)" + releaseNotesSource: inline + assets: "$(tgzFileName)" + isDraft: true + isPreRelease: true + addChangeLog: false From 5412c2d5c23828d390b24c4ef1cec3aa280028b1 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:23:47 -0500 Subject: [PATCH 05/18] Comment sections --- azure-pipelines/1es-release-npm.yml | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 864ec336df..b224cf181f 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -135,29 +135,29 @@ extends: publishVersion: ${{ parameters.publishVersion }} # Publish the package to NPM - - ${{ if eq(parameters.dryRun, true) }}: - - template: MicroBuild.Publish.yml@MicroBuildTemplate - parameters: - intent: "PackageDistribution" - contentType: "npm" - contentSource: "Folder" - folderLocation: "$(tgzFolderName)" - waitForReleaseCompletion: true - owners: "${{ parameters.OwnerAlias }}@microsoft.com" - approvers: "${{ parameters.ApproverAlias }}@microsoft.com" + # - ${{ if eq(parameters.dryRun, true) }}: + # - template: MicroBuild.Publish.yml@MicroBuildTemplate + # parameters: + # intent: "PackageDistribution" + # contentType: "npm" + # contentSource: "Folder" + # folderLocation: "$(tgzFolderName)" + # waitForReleaseCompletion: true + # owners: "${{ parameters.OwnerAlias }}@microsoft.com" + # approvers: "${{ parameters.ApproverAlias }}@microsoft.com" # Create a release on GitHub containing the package - - task: GitHubRelease@1 - displayName: "\U0001F449 GitHub release (create)" - condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) - inputs: - gitHubConnection: "GitHub-AzureTools" - tagSource: userSpecifiedTag - tag: "${{ parameters.PackageToPublish }}-v$(Version)" - title: "${{ parameters.PackageToPublish }} v$(Version)" - releaseNotesSource: inline - assets: "$(tgzFileName)" - isDraft: true - isPreRelease: true - addChangeLog: false + # - task: GitHubRelease@1 + # displayName: "\U0001F449 GitHub release (create)" + # condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) + # inputs: + # gitHubConnection: "GitHub-AzureTools" + # tagSource: userSpecifiedTag + # tag: "${{ parameters.PackageToPublish }}-v$(Version)" + # title: "${{ parameters.PackageToPublish }} v$(Version)" + # releaseNotesSource: inline + # assets: "$(tgzFileName)" + # isDraft: true + # isPreRelease: true + # addChangeLog: false From ee694655918da4c1a2fa5786efcb031443e5a75c Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:24:56 -0500 Subject: [PATCH 06/18] Try this --- azure-pipelines/1es-release-npm.yml | 198 ++++++++++++++-------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index b224cf181f..29bad3e0d0 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -61,103 +61,103 @@ extends: pipeline: build targetPath: $(System.DefaultWorkingDirectory) artifactName: ${{ parameters.artifactName }} - strategy: - runOnce: - deploy: - steps: - - - checkout: none - - # Locate the desired .tgz file and set the relevant variables - - powershell: | - # Find the desired .tgz file - $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse - - # Check if more than one .tgz file is found - if ($tgzFiles.Count -gt 1) { - Write-Error "More than one .tgz file found." - exit 1 - } elseif ($tgzFiles.Count -eq 0) { - Write-Error "No .tgz files found." - exit 1 - } else { - # Set the pipeline variable - $tgzFileName = $tgzFiles.Name - $tgzFolderName = Split-Path -Path $tgzFileName -Parent - Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" - Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" - Write-Output "Found .tgz file: $tgzFileName" - } - displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" - - # Modify the build number to include repo name, extension version, and if dry run is true - - powershell: | - # Get the version from package.json - - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $isDryRun = "$env:dryRun" - $currentBuildNumber = "$(Build.BuildId)" - - $repoName = "$(Build.Repository.Name)" - $repoNameParts = $repoName -split '/' - $repoNameWithoutOwner = $repoNameParts[-1] - - $dry = "" - if ($isDryRun -eq 'True') { - Write-Output "Dry run was set to True. Adding 'dry' to the build number." - $dry = "dry" - } - - $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" - Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" - displayName: "\U0001F449 Prepend version from package.json to build number" - env: - dryRun: ${{ parameters.dryRun }} - - # For safety, verify the version in package.json matches the version to publish entered by the releaser - # If they don't match, this step fails - - powershell: | - # Get the version from package.json - $packageJsonPath = "$(tgzFolderName)/package.json" - $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version - $publishVersion = "$env:publishVersion" - Write-Output "Publishing version: $publishVersion" - # Check if more than one .vsix file is found - if ($npmVersionString -eq $publishVersion) { - Write-Output "Publish version matches package.json version. Proceeding with release." - } else { - Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." - exit 1 - } - displayName: "\U0001F449 Verify publish version" - env: - publishVersion: ${{ parameters.publishVersion }} - - # Publish the package to NPM - # - ${{ if eq(parameters.dryRun, true) }}: - # - template: MicroBuild.Publish.yml@MicroBuildTemplate - # parameters: - # intent: "PackageDistribution" - # contentType: "npm" - # contentSource: "Folder" - # folderLocation: "$(tgzFolderName)" - # waitForReleaseCompletion: true - # owners: "${{ parameters.OwnerAlias }}@microsoft.com" - # approvers: "${{ parameters.ApproverAlias }}@microsoft.com" - - # Create a release on GitHub containing the package - # - task: GitHubRelease@1 - # displayName: "\U0001F449 GitHub release (create)" - # condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) - # inputs: - # gitHubConnection: "GitHub-AzureTools" - # tagSource: userSpecifiedTag - # tag: "${{ parameters.PackageToPublish }}-v$(Version)" - # title: "${{ parameters.PackageToPublish }} v$(Version)" - # releaseNotesSource: inline - # assets: "$(tgzFileName)" - # isDraft: true - # isPreRelease: true - # addChangeLog: false + # strategy: + # runOnce: + # deploy: + steps: + + - checkout: none + + # Locate the desired .tgz file and set the relevant variables + - powershell: | + # Find the desired .tgz file + $tgzFiles = Get-ChildItem -Path $(System.DefaultWorkingDirectory) -Filter ${{ parameters.packageToPublish }}*.tgz -File -Recurse + + # Check if more than one .tgz file is found + if ($tgzFiles.Count -gt 1) { + Write-Error "More than one .tgz file found." + exit 1 + } elseif ($tgzFiles.Count -eq 0) { + Write-Error "No .tgz files found." + exit 1 + } else { + # Set the pipeline variable + $tgzFileName = $tgzFiles.Name + $tgzFolderName = Split-Path -Path $tgzFileName -Parent + Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" + Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" + Write-Output "Found .tgz file: $tgzFileName" + } + displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" + + # Modify the build number to include repo name, extension version, and if dry run is true + - powershell: | + # Get the version from package.json + + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $isDryRun = "$env:dryRun" + $currentBuildNumber = "$(Build.BuildId)" + + $repoName = "$(Build.Repository.Name)" + $repoNameParts = $repoName -split '/' + $repoNameWithoutOwner = $repoNameParts[-1] + + $dry = "" + if ($isDryRun -eq 'True') { + Write-Output "Dry run was set to True. Adding 'dry' to the build number." + $dry = "dry" + } + + $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" + Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" + displayName: "\U0001F449 Prepend version from package.json to build number" + env: + dryRun: ${{ parameters.dryRun }} + + # For safety, verify the version in package.json matches the version to publish entered by the releaser + # If they don't match, this step fails + - powershell: | + # Get the version from package.json + $packageJsonPath = "$(tgzFolderName)/package.json" + $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version + $publishVersion = "$env:publishVersion" + Write-Output "Publishing version: $publishVersion" + # Check if more than one .vsix file is found + if ($npmVersionString -eq $publishVersion) { + Write-Output "Publish version matches package.json version. Proceeding with release." + } else { + Write-Error "Publish version $publishVersion doesn't match version found in package.json $npmVersionString. Cancelling release." + exit 1 + } + displayName: "\U0001F449 Verify publish version" + env: + publishVersion: ${{ parameters.publishVersion }} + + # Publish the package to NPM + # - ${{ if eq(parameters.dryRun, true) }}: + # - template: MicroBuild.Publish.yml@MicroBuildTemplate + # parameters: + # intent: "PackageDistribution" + # contentType: "npm" + # contentSource: "Folder" + # folderLocation: "$(tgzFolderName)" + # waitForReleaseCompletion: true + # owners: "${{ parameters.OwnerAlias }}@microsoft.com" + # approvers: "${{ parameters.ApproverAlias }}@microsoft.com" + + # Create a release on GitHub containing the package + # - task: GitHubRelease@1 + # displayName: "\U0001F449 GitHub release (create)" + # condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) + # inputs: + # gitHubConnection: "GitHub-AzureTools" + # tagSource: userSpecifiedTag + # tag: "${{ parameters.PackageToPublish }}-v$(Version)" + # title: "${{ parameters.PackageToPublish }} v$(Version)" + # releaseNotesSource: inline + # assets: "$(tgzFileName)" + # isDraft: true + # isPreRelease: true + # addChangeLog: false From e61e192f4d9ebd83815d8bada3cf5b0669d5bc73 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:25:31 -0500 Subject: [PATCH 07/18] Change to job --- azure-pipelines/1es-release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 29bad3e0d0..c65e2e7707 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -50,7 +50,7 @@ extends: - stage: ReleaseStage displayName: Release package jobs: - - deployment: Publish + - job: Publish displayName: Publish package environment: ${{ parameters.environmentName }} templateContext: From f6f03804781a975c66ebd5339cf84578dfadeda1 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:25:53 -0500 Subject: [PATCH 08/18] Remove env --- azure-pipelines/1es-release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index c65e2e7707..ed7b15a97d 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -52,7 +52,7 @@ extends: jobs: - job: Publish displayName: Publish package - environment: ${{ parameters.environmentName }} + #environment: ${{ parameters.environmentName }} templateContext: type: releaseJob isProduction: true From 10e960128c0e72ca1fe845270d676f4f54df5ced Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:26:04 -0500 Subject: [PATCH 09/18] Remove checkout --- azure-pipelines/1es-release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index ed7b15a97d..75cc388532 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -66,7 +66,7 @@ extends: # deploy: steps: - - checkout: none + # - checkout: none # Locate the desired .tgz file and set the relevant variables - powershell: | From d730dea9123a0c7add6f3da6f4481d32ee6d54cd Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:35:20 -0500 Subject: [PATCH 10/18] Remove environment for real --- azure-pipelines/1es-release-npm.yml | 58 ++++++++++++----------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 75cc388532..bfe1634929 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -12,12 +12,6 @@ parameters: - name: publishVersion type: string - # Customize the environment to associate the deployment with. - # Useful to control which group of people should be required to approve the deployment. - - name: environmentName - type: string - default: AzCodeDeploy - # When true, skips the deployment job which actually publishes the extension - name: dryRun type: boolean @@ -52,7 +46,6 @@ extends: jobs: - job: Publish displayName: Publish package - #environment: ${{ parameters.environmentName }} templateContext: type: releaseJob isProduction: true @@ -61,13 +54,8 @@ extends: pipeline: build targetPath: $(System.DefaultWorkingDirectory) artifactName: ${{ parameters.artifactName }} - # strategy: - # runOnce: - # deploy: steps: - # - checkout: none - # Locate the desired .tgz file and set the relevant variables - powershell: | # Find the desired .tgz file @@ -135,29 +123,29 @@ extends: publishVersion: ${{ parameters.publishVersion }} # Publish the package to NPM - # - ${{ if eq(parameters.dryRun, true) }}: - # - template: MicroBuild.Publish.yml@MicroBuildTemplate - # parameters: - # intent: "PackageDistribution" - # contentType: "npm" - # contentSource: "Folder" - # folderLocation: "$(tgzFolderName)" - # waitForReleaseCompletion: true - # owners: "${{ parameters.OwnerAlias }}@microsoft.com" - # approvers: "${{ parameters.ApproverAlias }}@microsoft.com" + - ${{ if eq(parameters.dryRun, true) }}: + - template: MicroBuild.Publish.yml@MicroBuildTemplate + parameters: + intent: "PackageDistribution" + contentType: "npm" + contentSource: "Folder" + folderLocation: "$(tgzFolderName)" + waitForReleaseCompletion: true + owners: "${{ parameters.OwnerAlias }}@microsoft.com" + approvers: "${{ parameters.ApproverAlias }}@microsoft.com" # Create a release on GitHub containing the package - # - task: GitHubRelease@1 - # displayName: "\U0001F449 GitHub release (create)" - # condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) - # inputs: - # gitHubConnection: "GitHub-AzureTools" - # tagSource: userSpecifiedTag - # tag: "${{ parameters.PackageToPublish }}-v$(Version)" - # title: "${{ parameters.PackageToPublish }} v$(Version)" - # releaseNotesSource: inline - # assets: "$(tgzFileName)" - # isDraft: true - # isPreRelease: true - # addChangeLog: false + - task: GitHubRelease@1 + displayName: "\U0001F449 GitHub release (create)" + condition: and(succeeded(), ${{ eq(parameters.dryRun, false) }}) + inputs: + gitHubConnection: "GitHub-AzureTools" + tagSource: userSpecifiedTag + tag: "${{ parameters.PackageToPublish }}-v$(Version)" + title: "${{ parameters.PackageToPublish }} v$(Version)" + releaseNotesSource: inline + assets: "$(tgzFolderName)/$(tgzFileName)" + isDraft: true + isPreRelease: true + addChangeLog: false From 579a512ac13fd2aa7ad18dd21ef33f97d6959524 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:54:57 -0500 Subject: [PATCH 11/18] Fix condition on ESRP release --- azure-pipelines/1es-release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index bfe1634929..8ef942115e 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -123,7 +123,7 @@ extends: publishVersion: ${{ parameters.publishVersion }} # Publish the package to NPM - - ${{ if eq(parameters.dryRun, true) }}: + - ${{ if ne(parameters.dryRun, true) }}: - template: MicroBuild.Publish.yml@MicroBuildTemplate parameters: intent: "PackageDistribution" From d1830c47117d153a73ad4423188cac481d4f2ef4 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 8 Jan 2025 17:16:08 -0500 Subject: [PATCH 12/18] Fix pathing issues --- azure-pipelines/1es-release-npm.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 8ef942115e..39acdfcc71 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -70,8 +70,8 @@ extends: exit 1 } else { # Set the pipeline variable - $tgzFileName = $tgzFiles.Name - $tgzFolderName = Split-Path -Path $tgzFileName -Parent + $tgzFileName = $tgzFiles.FullName + $tgzFolderName = $tgzFiles.DirectoryName Write-Output "##vso[task.setvariable variable=tgzFileName;]$tgzFileName" Write-Output "##vso[task.setvariable variable=tgzFolderName;]$tgzFolderName" Write-Output "Found .tgz file: $tgzFileName" @@ -144,7 +144,7 @@ extends: tag: "${{ parameters.PackageToPublish }}-v$(Version)" title: "${{ parameters.PackageToPublish }} v$(Version)" releaseNotesSource: inline - assets: "$(tgzFolderName)/$(tgzFileName)" + assets: "$(tgzFileName)" isDraft: true isPreRelease: true addChangeLog: false From e8f864b959cef628c3a7f932edba7e9d8a9ff665 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:12:06 -0500 Subject: [PATCH 13/18] Minor changes --- azure-pipelines/1es-release-npm.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index 39acdfcc71..dd9dff16e0 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -7,12 +7,12 @@ parameters: type: string default: Build Root - # The intended extension version to publish. + # The intended package version to publish. # This is used to verify the version in package.json matches the version to publish to avoid accidental publishing. - name: publishVersion type: string - # When true, skips the deployment job which actually publishes the extension + # When true, skips the deployment job which actually publishes the package - name: dryRun type: boolean default: false @@ -78,7 +78,7 @@ extends: } displayName: "\U0001F449 Find and Set .tgz File/Folder Variables" - # Modify the build number to include repo name, extension version, and if dry run is true + # Modify the build number to include package name, package version, and if dry run is true - powershell: | # Get the version from package.json @@ -87,21 +87,18 @@ extends: $isDryRun = "$env:dryRun" $currentBuildNumber = "$(Build.BuildId)" - $repoName = "$(Build.Repository.Name)" - $repoNameParts = $repoName -split '/' - $repoNameWithoutOwner = $repoNameParts[-1] - $dry = "" if ($isDryRun -eq 'True') { Write-Output "Dry run was set to True. Adding 'dry' to the build number." $dry = "dry" } - $newBuildNumber = "$repoNameWithoutOwner-$npmVersionString-$dry-$currentBuildNumber" + $newBuildNumber = "$env:packageToPublish-$npmVersionString-$dry-$currentBuildNumber" Write-Output "##vso[build.updatebuildnumber]$newBuildNumber" displayName: "\U0001F449 Prepend version from package.json to build number" env: dryRun: ${{ parameters.dryRun }} + packageToPublish: ${{ parameters.packageToPublish }} # For safety, verify the version in package.json matches the version to publish entered by the releaser # If they don't match, this step fails @@ -111,7 +108,6 @@ extends: $npmVersionString = (Get-Content $packageJsonPath | ConvertFrom-Json).version $publishVersion = "$env:publishVersion" Write-Output "Publishing version: $publishVersion" - # Check if more than one .vsix file is found if ($npmVersionString -eq $publishVersion) { Write-Output "Publish version matches package.json version. Proceeding with release." } else { From 5667713ea91f3f16ef375433a83f592eee143247 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:47:45 -0500 Subject: [PATCH 14/18] Changes to release pipeline --- .azure-pipelines/release-npm.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/release-npm.yml b/.azure-pipelines/release-npm.yml index e40d7bdcf4..2ff024fd85 100644 --- a/.azure-pipelines/release-npm.yml +++ b/.azure-pipelines/release-npm.yml @@ -3,7 +3,7 @@ pr: none # Disable PR trigger # Choose a package to publish at the time of job creation parameters: - - name: PackageToPublish + - name: packageToPublish displayName: Package to Publish type: string values: @@ -16,10 +16,13 @@ parameters: - microsoft-vscode-azext-github - microsoft-vscode-azext-serviceconnector - microsoft-vscode-azext-utils - - name: BranchToPublish - displayName: Branch to Publish + - name: publishVersion + displayName: Publish Version type: string - default: "refs/heads/main" + - name: dryRun + displayName: Dry Run + type: boolean + default: true # Grab the base templates from https://github.com/microsoft/vscode-azuretools/tree/main/azure-pipelines resources: @@ -29,13 +32,17 @@ resources: name: microsoft/vscode-azuretools ref: main endpoint: GitHub-AzureTools + pipelines: + - pipeline: build # This must be "build" + source: \Azure Tools\VSCode\Packages\vscode-azuretools # name of the pipeline that produces the artifacts # Use those base templates extends: template: azure-pipelines/1es-release-npm.yml@templates parameters: - PackageToPublish: ${{ parameters.PackageToPublish }} - BranchToPublish: ${{ parameters.BranchToPublish }} - PipelineDefinition: 20425 + packageToPublish: ${{ parameters.packageToPublish }} + artifactName: Build ${{ parameters.packageToPublish}} + publishVersion: ${{ parameters.publishVersion }} + dryRun: ${{ parameters.dryRun }} OwnerAlias: "jinglou" ApproverAlias: "bwater" From 9554b8dfdd406406cde5f75c855fe07fdf0d195d Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:23:37 -0500 Subject: [PATCH 15/18] Fix wrong branch being used for pipeline --- .azure-pipelines/release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/release-npm.yml b/.azure-pipelines/release-npm.yml index 2ff024fd85..265f9c78ab 100644 --- a/.azure-pipelines/release-npm.yml +++ b/.azure-pipelines/release-npm.yml @@ -30,7 +30,7 @@ resources: - repository: templates type: github name: microsoft/vscode-azuretools - ref: main + ref: bmw/npmReleasePipeline # TODO endpoint: GitHub-AzureTools pipelines: - pipeline: build # This must be "build" From d8a4f286a6645e43caeb3a1b02c77985b8bc2682 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:29:41 -0500 Subject: [PATCH 16/18] Don't forget a TODO --- .azure-pipelines/release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/release-npm.yml b/.azure-pipelines/release-npm.yml index 265f9c78ab..4f7f01d009 100644 --- a/.azure-pipelines/release-npm.yml +++ b/.azure-pipelines/release-npm.yml @@ -22,7 +22,7 @@ parameters: - name: dryRun displayName: Dry Run type: boolean - default: true + default: true # TODO # Grab the base templates from https://github.com/microsoft/vscode-azuretools/tree/main/azure-pipelines resources: From 2f0476c52d1bc19d8d1df32f0a50de806d6261da Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:30:42 -0500 Subject: [PATCH 17/18] Fix TODOs --- .azure-pipelines/release-npm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/release-npm.yml b/.azure-pipelines/release-npm.yml index 4f7f01d009..7795186f81 100644 --- a/.azure-pipelines/release-npm.yml +++ b/.azure-pipelines/release-npm.yml @@ -22,7 +22,7 @@ parameters: - name: dryRun displayName: Dry Run type: boolean - default: true # TODO + default: false # Grab the base templates from https://github.com/microsoft/vscode-azuretools/tree/main/azure-pipelines resources: @@ -30,7 +30,7 @@ resources: - repository: templates type: github name: microsoft/vscode-azuretools - ref: bmw/npmReleasePipeline # TODO + ref: main endpoint: GitHub-AzureTools pipelines: - pipeline: build # This must be "build" From db9ee63b8863fb25a556f68ba207cbe78b71e529 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:03:13 -0500 Subject: [PATCH 18/18] Flip the boolean --- azure-pipelines/1es-release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/1es-release-npm.yml b/azure-pipelines/1es-release-npm.yml index dd9dff16e0..0e72daab01 100644 --- a/azure-pipelines/1es-release-npm.yml +++ b/azure-pipelines/1es-release-npm.yml @@ -119,7 +119,7 @@ extends: publishVersion: ${{ parameters.publishVersion }} # Publish the package to NPM - - ${{ if ne(parameters.dryRun, true) }}: + - ${{ if eq(parameters.dryRun, false) }}: - template: MicroBuild.Publish.yml@MicroBuildTemplate parameters: intent: "PackageDistribution"