|
3 | 3 | # Add steps that analyze code, save build artifacts, deploy, and more: |
4 | 4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript |
5 | 5 |
|
6 | | -# Node.js |
7 | | -# Build a general Node.js project with npm. |
8 | | -# Add steps that analyze code, save build artifacts, deploy, and more: |
9 | | -# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript |
10 | | - |
11 | 6 | trigger: |
12 | 7 | branches: |
13 | 8 | include: |
|
30 | 25 | include: |
31 | 26 | - tools/js-sdk-release-tools |
32 | 27 |
|
33 | | -variables: |
34 | | - - template: ../../eng/pipelines/templates/variables/globals.yml |
35 | | - - name: NodeVersion |
36 | | - value: '14.x' |
37 | | - - name: VAR_ARTIFACT_NAME |
38 | | - value: 'drop' |
39 | | - - name: VAR_BUILD_ARTIFACT_STAGING_DIRECTORY |
40 | | - value: $(Build.ArtifactStagingDirectory) |
| 28 | +extends: |
| 29 | + template: /eng/pipelines/templates/stages/1es-redirect.yml |
| 30 | + parameters: |
| 31 | + stages: |
| 32 | + - stage: InstallAndBuild |
| 33 | + variables: |
| 34 | + - template: /eng/pipelines/templates/variables/globals.yml |
| 35 | + - template: /eng/pipelines/templates/variables/image.yml |
| 36 | + - name: NodeVersion |
| 37 | + value: '18.x' |
| 38 | + |
| 39 | + jobs: |
| 40 | + - job: Build |
| 41 | + pool: |
| 42 | + name: $(LINUXNEXTPOOL) |
| 43 | + image: $(LINUXNEXTVMIMAGE) |
| 44 | + os: linux |
| 45 | + steps: |
| 46 | + - task: NodeTool@0 |
| 47 | + inputs: |
| 48 | + versionSpec: '$(NodeVersion)' |
| 49 | + displayName: 'Install Node.js' |
| 50 | + |
| 51 | + - script: | |
| 52 | + npm install |
| 53 | + displayName: 'npm install' |
| 54 | + workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
41 | 55 |
|
42 | | -stages: |
43 | | - - stage: InstallAndBuild |
44 | | - jobs: |
45 | | - - job: Build |
46 | | - strategy: |
47 | | - matrix: |
48 | | - linux: |
49 | | - imageName: ubuntu-22.04 |
50 | | - mac: |
51 | | - imageName: 'macos-latest' |
52 | | - windows: |
53 | | - imageName: 'windows-latest' |
54 | | - pool: |
55 | | - vmImage: $(imageName) |
56 | | - steps: |
57 | | - - task: NodeTool@0 |
58 | | - inputs: |
59 | | - versionSpec: '$(NodeVersion)' |
60 | | - displayName: 'Install Node.js' |
| 56 | + - script: | |
| 57 | + npm pack |
| 58 | + displayName: 'npm pack' |
| 59 | + workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
61 | 60 |
|
62 | | - - script: | |
63 | | - npm install |
64 | | - displayName: 'npm install' |
65 | | - workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
| 61 | + - script: 'cp azure-tools-js-sdk-release-tools-*.tgz $(Build.ArtifactStagingDirectory)' |
| 62 | + displayName: 'copy to staging dir' |
| 63 | + workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
66 | 64 |
|
67 | | - - script: | |
68 | | - npm pack |
69 | | - displayName: 'npm pack' |
70 | | - workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
71 | | - condition: contains(variables['imageName'], 'ubuntu') |
| 65 | + - task: 1ES.PublishPipelineArtifact@1 |
| 66 | + inputs: |
| 67 | + targetPath: '$(Build.ArtifactStagingDirectory)' |
| 68 | + ArtifactName: 'drop' |
72 | 69 |
|
73 | | - - script: 'cp azure-tools-js-sdk-release-tools-*.tgz $(VAR_BUILD_ARTIFACT_STAGING_DIRECTORY)' |
74 | | - displayName: 'copy to staging dir' |
75 | | - workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
76 | | - condition: contains(variables['imageName'], 'ubuntu') |
| 70 | + - ${{if ne(variables['Build.Reason'], 'PullRequest')}}: |
| 71 | + - stage: Release |
| 72 | + dependsOn: InstallAndBuild |
| 73 | + condition: succeeded() |
| 74 | + variables: |
| 75 | + - template: /eng/pipelines/templates/variables/globals.yml |
| 76 | + - template: /eng/pipelines/templates/variables/image.yml |
| 77 | + - name: NodeVersion |
| 78 | + value: '18.x' |
77 | 79 |
|
78 | | - - task: PublishBuildArtifacts@1 |
79 | | - inputs: |
80 | | - PathtoPublish: '$(VAR_BUILD_ARTIFACT_STAGING_DIRECTORY)' |
81 | | - ArtifactName: '$(VAR_ARTIFACT_NAME)' |
82 | | - publishLocation: 'Container' |
83 | | - condition: contains(variables['imageName'], 'ubuntu') |
| 80 | + jobs: |
| 81 | + - job: approve |
| 82 | + pool: server |
| 83 | + steps: |
| 84 | + - task: ManualValidation@0 |
| 85 | + inputs: |
| 86 | + notifyUsers: 'Click to approve if it''s an expected public release.' |
84 | 87 |
|
85 | | - - ${{if ne(variables['Build.Reason'], 'PullRequest')}}: |
86 | | - - stage: Release |
87 | | - dependsOn: InstallAndBuild |
88 | | - condition: succeeded() |
89 | | - jobs: |
90 | | - - job: approve |
91 | | - pool: server |
92 | | - steps: |
93 | | - - task: ManualValidation@0 |
94 | | - inputs: |
95 | | - notifyUsers: 'Click to approve if it''s an expected public release.' |
96 | | - - job: release |
97 | | - dependsOn: approve |
98 | | - condition: and(succeeded(), ne(variables['USER_SKIP_PUBLIC_RELEASE'], 'true')) |
99 | | - steps: |
100 | | - - task: NodeTool@0 |
101 | | - inputs: |
102 | | - versionSpec: '$(NodeVersion)' |
103 | | - displayName: 'Install Node.js' |
104 | | - - task: DownloadBuildArtifacts@0 |
105 | | - inputs: |
106 | | - buildType: 'current' |
107 | | - downloadType: 'single' |
108 | | - artifactName: '$(VAR_ARTIFACT_NAME)' |
109 | | - downloadPath: '$(VAR_BUILD_ARTIFACT_STAGING_DIRECTORY)' |
110 | | - - script: | |
111 | | - echo -e "\e[32m[$(date -u)] LOG: Ensure latest npm is installed" |
112 | | - sudo npm install -g npm || { echo 'npm install failed' ; exit 1; } |
113 | | - sudo npm install -g pnpm || { echo 'pnpm install failed' ; exit 1; } |
| 88 | + - job: release |
| 89 | + dependsOn: approve |
| 90 | + condition: and(succeeded(), ne(variables['USER_SKIP_PUBLIC_RELEASE'], 'true')) |
| 91 | + pool: |
| 92 | + name: $(LINUXNEXTPOOL) |
| 93 | + image: $(LINUXNEXTVMIMAGE) |
| 94 | + os: linux |
| 95 | + steps: |
| 96 | + - task: NodeTool@0 |
| 97 | + inputs: |
| 98 | + versionSpec: '$(NodeVersion)' |
| 99 | + displayName: 'Install Node.js' |
| 100 | + |
| 101 | + - task: DownloadPipelineArtifact@2 |
| 102 | + inputs: |
| 103 | + artifactName: 'drop' |
| 104 | + targetPath: '$(Build.ArtifactStagingDirectory)' |
114 | 105 |
|
115 | | - echo -e "\e[32m[$(date -u)] LOG: publish the package" |
116 | | - echo "//registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)" >> ~/.npmrc |
117 | | - for file in $(VAR_BUILD_ARTIFACT_STAGING_DIRECTORY)/$(VAR_ARTIFACT_NAME)/*.tgz |
118 | | - do |
119 | | - echo -e "\e[32m[$(date -u)] LOG: File: $file" |
120 | | - npm publish $file --access public || { echo 'publish $file failed' ; exit 1; } |
121 | | - done |
122 | | - rm ~/.npmrc || { echo 'rm ~/.npmrc failed' ; exit 1; } |
123 | | - displayName: Publish |
124 | | - workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
| 106 | + - script: | |
| 107 | + echo -e "\e[32m[$(date -u)] LOG: Ensure latest npm is installed" |
| 108 | + sudo npm install -g npm || { echo 'npm install failed' ; exit 1; } |
| 109 | + sudo npm install -g pnpm || { echo 'pnpm install failed' ; exit 1; } |
125 | 110 |
|
| 111 | + echo -e "\e[32m[$(date -u)] LOG: publish the package" |
| 112 | + echo "//registry.npmjs.org/:_authToken=$(azure-sdk-npm-token)" >> ~/.npmrc |
| 113 | + for file in $(Build.ArtifactStagingDirectory)/*.tgz |
| 114 | + do |
| 115 | + echo -e "\e[32m[$(date -u)] LOG: File: $file" |
| 116 | + npm publish $file --access public || { echo 'publish $file failed' ; exit 1; } |
| 117 | + done |
| 118 | + rm ~/.npmrc || { echo 'rm ~/.npmrc failed' ; exit 1; } |
| 119 | + displayName: Publish |
| 120 | + workingDirectory: $(System.DefaultWorkingDirectory)/tools/js-sdk-release-tools |
0 commit comments