-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azure-pipelines: Add a pipeline definition to facilitate releasing pa…
…ckages to NPM (#1604)
- Loading branch information
1 parent
b0dc641
commit 1aa8b77
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
parameters: | ||
- name: PackageToPublish | ||
displayName: Package to Publish | ||
type: string | ||
- name: PipelineDefinition | ||
displayName: Pipeline Definition ID | ||
type: number | ||
- name: BranchToPublish | ||
displayName: Branch to Publish | ||
type: string | ||
default: "refs/heads/main" | ||
|
||
jobs: | ||
- job: Release | ||
pool: | ||
vmImage: ubuntu-latest | ||
steps: | ||
- task: DownloadPipelineArtifact@2 | ||
inputs: | ||
buildType: "specific" | ||
project: "AzCode" | ||
definition: ${{ parameters.PipelineDefinition }} | ||
buildVersionToDownload: "latestFromBranch" | ||
branchName: ${{ parameters.BranchToPublish }} | ||
targetPath: $(System.DefaultWorkingDirectory) | ||
- task: CmdLine@2 | ||
displayName: 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" | ||
else | ||
echo "Failed to parse tarball path \"$TarballPath\"" | ||
exit 1 | ||
fi | ||
workingDirectory: $(System.DefaultWorkingDirectory) | ||
- task: CmdLine@2 | ||
displayName: Create .npmrc | ||
inputs: | ||
script: echo "registry=https://registry.npmjs.org" >> .npmrc | ||
workingDirectory: $(System.DefaultWorkingDirectory) | ||
- task: npmAuthenticate@0 | ||
displayName: "npm Authenticate" | ||
inputs: | ||
workingFile: "$(System.DefaultWorkingDirectory)/.npmrc" | ||
customEndpoint: "npm token" | ||
- task: CmdLine@2 | ||
displayName: NPM Publish | ||
inputs: | ||
script: npm --userconfig .npmrc publish --access public '$(System.DefaultWorkingDirectory)/$(TarballPath)' | ||
- task: GitHubRelease@1 | ||
displayName: "GitHub release (create)" | ||
inputs: | ||
gitHubConnection: "AzCode-Bot" | ||
tagSource: userSpecifiedTag | ||
tag: "${{ parameters.PackageToPublish }}-v$(Version)" | ||
title: "${{ parameters.PackageToPublish }} v$(Version)" | ||
releaseNotesSource: inline | ||
assets: "$(System.DefaultWorkingDirectory)/$(TarballPath)" | ||
isDraft: true | ||
isPreRelease: true | ||
addChangeLog: false |