Skip to content

Commit

Permalink
update publish to marketplace flow
Browse files Browse the repository at this point in the history
  • Loading branch information
dilin-MS2 committed Jan 9, 2020
1 parent 6007360 commit 3e07c08
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
42 changes: 27 additions & 15 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ pool:
vmImage: $(imageName)
demands: npm

variables:
nightly_build_id: dilin.test-hawk-project-nightly
rc_id: dilin.test-hawk-project-rc

steps:

- task: UseNode@1
Expand Down Expand Up @@ -47,27 +51,20 @@ steps:
is_prod_tag=^refs\/tags\/v?[0-9]+\.[0-9]+\.[0-9]+$
is_test_tag=^refs\/tags\/v?[0-9]+\.[0-9]+\.[0-9]+-[rR][cC]
# Update marketplace token
[[ $BUILD_SOURCEBRANCH =~ $is_prod_tag ]] && is_prod=true && marketplace_token=$DILIN_MARKETPLACE_TOKEN
[[ $BUILD_SOURCEBRANCH =~ $is_test_tag ]] && is_test=true && marketplace_token=$DILIN_TEST_MARKETPLACE_TOKEN
[[ "$BUILD_REASON" == "Schedule" ]] && marketplace_token=$DILIN_TEST_MARKETPLACE_TOKEN
[[ $BUILD_SOURCEBRANCH =~ $is_prod_tag ]] && is_prod=true
[[ $BUILD_SOURCEBRANCH =~ $is_test_tag ]] && is_test=true
[[ $BUILD_SOURCEBRANCH =~ $is_prod_tag || $BUILD_SOURCEBRANCH =~ $is_test_tag || "$BUILD_REASON" == "Schedule" ]] && deploy_to_marketplace=true
# Set job variable
echo "##vso[task.setvariable variable=is_prod]$is_prod"
echo "##vso[task.setvariable variable=is_test]$is_test"
echo "##vso[task.setvariable variable=marketplace_token]$marketplace_token"
echo "##vso[task.setvariable variable=deploy_to_marketplace]$deploy_to_marketplace"
env:
# Pass secrect variable
DILIN_MARKETPLACE_TOKEN: $(dilin_marketplace_token)
DILIN_TEST_MARKETPLACE_TOKEN: $(dilin_test_marketplace_token)
displayName: 'Define runtime variable'
- script: npm install -g vsce
displayName: 'install vsce in Linux or MacOS'
displayName: 'install vsce'
condition: and(succeeded(), eq(variables['deploy_to_marketplace'], 'true'))

- script: node scripts/updateConfig.js
displayName: 'Update configuration'
condition: and(succeeded(), eq(variables['deploy_to_marketplace'], 'true'))
Expand Down Expand Up @@ -100,8 +97,23 @@ steps:
isPreRelease: $(is_test)
condition: and(succeeded(), eq(variables['deploy_to_marketplace'], 'true'), ne(variables['Build.reason'], 'Schedule'), eq(variables['Agent.OS'], 'Linux'))

# Deploy to marketplace (prod / rc / nightly build)
- bash: vsce publish -p $(marketplace_token) --packagePath *.vsix
- bash: vsce publish -p $MARKETPLACE_TOKEN --packagePath *.vsix
workingDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: 'Deploy to marketplace'
condition: and(succeeded(), eq(variables['deploy_to_marketplace'], 'true'), eq(variables['Agent.OS'], 'Linux'))
displayName: 'Deploy production candidate to marketplace'
condition: and(succeeded(), eq(variables['is_prod'], 'true'), eq(variables['Agent.OS'], 'Linux'))
env:
MARKETPLACE_TOKEN: $(dilin_marketplace_token)

- bash: yes | vsce unpublish -p $MARKETPLACE_TOKEN $(rc_id) && vsce publish -p $MARKETPLACE_TOKEN --packagePath *.vsix
workingDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: 'Deploy RC candidate to marketplace'
condition: and(succeeded(), eq(variables['is_test'], 'true'), eq(variables['Agent.OS'], 'Linux'))
env:
MARKETPLACE_TOKEN: $(dilin_test_marketplace_token)

- bash: yes | vsce unpublish -p $MARKETPLACE_TOKEN $(nightly_build_id) && vsce publish -p MARKETPLACE_TOKEN --packagePath *.vsix
workingDirectory: '$(Build.ArtifactStagingDirectory)'
displayName: 'Deploy nightly build candidate to marketplace'
condition: and(succeeded(), eq(variables['Build.reason'], 'Schedule'), eq(variables['Agent.OS'], 'Linux'))
env:
MARKETPLACE_TOKEN: $(dilin_test_marketplace_token)
1 change: 0 additions & 1 deletion scripts/updateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2) + '\n');
* @param {*} packageJson package json oject
* @param {*} testName test extension name
* @param {*} testDisplayName test extension displate name
* @param {*} testPublisher test publisher
*/
function updateConfigForNonProduction(packageJson, testName, testDisplayName) {
// Update package.json
Expand Down

0 comments on commit 3e07c08

Please sign in to comment.