Skip to content

Commit

Permalink
Update release pipeline to use 1es templates (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejizba authored Jun 11, 2024
1 parent 6947a95 commit 7a80fec
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 31 deletions.
78 changes: 48 additions & 30 deletions azure-pipelines/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,54 @@ trigger: none
pr: none

resources:
repositories:
- repository: 1es
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
pipelines:
- pipeline: nodeLibraryCI
project: 'Azure Functions'
source: azure-functions-nodejs-library.build
- pipeline: officialBuild
project: internal
source: nodejs-library.official
branch: v4.x

jobs:
- job: Release
pool:
name: '1ES-Hosted-AzFunc'
demands:
- ImageOverride -equals MMSUbuntu20.04TLS
steps:
- download: nodeLibraryCI
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: 18.x
- script: npm ci
displayName: 'npm ci'
- script: 'npm run validateRelease -- --publishTag ${{ parameters.NpmPublishTag }} --dropPath "$(Pipeline.Workspace)/nodeLibraryCI/drop"'
displayName: 'validate release'
- script: mv *.tgz package.tgz
displayName: 'Rename tgz file' # because the publish command below requires an exact path
workingDirectory: '$(Pipeline.Workspace)/nodeLibraryCI/drop'
- task: Npm@1
displayName: 'npm publish'
inputs:
command: custom
workingDir: '$(Pipeline.Workspace)/nodeLibraryCI/drop'
verbose: true
customCommand: 'publish package.tgz --tag ${{ parameters.NpmPublishTag }} --dry-run ${{ lower(parameters.NpmPublishDryRun) }}'
customEndpoint: 'Functions Node.js Library Publish'
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1es
parameters:
sdl:
sourceAnalysisPool:
name: 1es-pool-azfunc
image: 1es-windows-2022
os: windows
codeql:
runSourceLanguagesInSourceAnalysis: true

stages:
- stage: Release
pool:
name: 1es-pool-azfunc
image: 1es-ubuntu-22.04
os: linux
jobs:
- job: Release
steps:
- download: officialBuild
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: 18.x
- script: npm ci
displayName: 'npm ci'
- script: 'npm run validateRelease -- --publishTag ${{ parameters.NpmPublishTag }} --dropPath "$(Pipeline.Workspace)/officialBuild/drop"'
displayName: 'validate release'
- script: mv *.tgz package.tgz
displayName: 'Rename tgz file' # because the publish command below requires an exact path
workingDirectory: '$(Pipeline.Workspace)/officialBuild/drop'
- task: Npm@1
displayName: 'npm publish'
inputs:
command: custom
workingDir: '$(Pipeline.Workspace)/officialBuild/drop'
verbose: true
customCommand: 'publish package.tgz --tag ${{ parameters.NpmPublishTag }} --dry-run ${{ lower(parameters.NpmPublishDryRun) }}'
customEndpoint: nodejs-library-npm
2 changes: 1 addition & 1 deletion scripts/validateRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm run validateRelease -- --publishTag preview --dropPath /example/path/`);
}

function validateRelease(publishTag: string, dropPath: string): void {
const files = readdirSync(dropPath);
const files = readdirSync(dropPath).filter((f) => f.endsWith('.tgz'));
if (files.length !== 1) {
throw new Error('Drop path should have one tgz file');
}
Expand Down

0 comments on commit 7a80fec

Please sign in to comment.